niceeval 0.16.3-canary.99 → 0.17.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (258) hide show
  1. package/dist/cli/bootstrap.cjs +7 -1
  2. package/dist/cli/bootstrap.cjs.map +1 -1
  3. package/dist/cli/project-configuration.cjs +8 -11
  4. package/dist/cli/project-configuration.cjs.map +1 -1
  5. package/dist/expect/index.cjs.map +1 -1
  6. package/dist/expect/index.d.cts +2 -1
  7. package/dist/expect/index.d.mts +2 -1
  8. package/dist/expect/index.d.ts +2 -1
  9. package/dist/experiment/host/cli/contribution.cjs +6 -11
  10. package/dist/experiment/host/cli/contribution.cjs.map +1 -1
  11. package/dist/experiment/host/cli/contribution.d.cts +0 -16
  12. package/dist/experiment/host/cli/contribution.d.mts +0 -16
  13. package/dist/experiment/host/cli/contribution.d.ts +0 -16
  14. package/dist/experiment/host/operations.cjs +3 -3
  15. package/dist/experiment/host/operations.cjs.map +1 -1
  16. package/dist/experiment/host/types.cjs.map +1 -1
  17. package/dist/experiment/host/types.d.cts +0 -4
  18. package/dist/experiment/host/types.d.mts +0 -4
  19. package/dist/experiment/host/types.d.ts +0 -4
  20. package/dist/fresh-import.cjs +2 -2
  21. package/dist/fresh-import.cjs.map +1 -1
  22. package/dist/fresh-import.d.cts +3 -3
  23. package/dist/fresh-import.d.mts +3 -3
  24. package/dist/fresh-import.d.ts +3 -3
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +2 -1
  27. package/dist/index.d.mts +2 -1
  28. package/dist/index.d.ts +2 -1
  29. package/dist/inspection/codec.cjs.map +1 -1
  30. package/dist/inspection/codec.d.cts +1 -1
  31. package/dist/inspection/codec.d.mts +1 -1
  32. package/dist/inspection/codec.d.ts +1 -1
  33. package/dist/inspection/facts.cjs +66 -9
  34. package/dist/inspection/facts.cjs.map +1 -1
  35. package/dist/inspection/facts.d.cts +4 -0
  36. package/dist/inspection/facts.d.mts +4 -0
  37. package/dist/inspection/facts.d.ts +4 -0
  38. package/dist/inspection/facts.js +4 -2
  39. package/dist/inspection/index.cjs +1 -3
  40. package/dist/inspection/index.cjs.map +1 -1
  41. package/dist/inspection/index.d.cts +1 -1
  42. package/dist/inspection/index.d.mts +1 -1
  43. package/dist/inspection/index.d.ts +1 -1
  44. package/dist/inspection/index.js +44 -48
  45. package/dist/inspection/limits.cjs +3 -1
  46. package/dist/inspection/limits.cjs.map +1 -1
  47. package/dist/inspection/limits.d.cts +2 -0
  48. package/dist/inspection/limits.d.mts +2 -0
  49. package/dist/inspection/limits.d.ts +2 -0
  50. package/dist/inspection/limits.js +6 -4
  51. package/dist/inspection/project-source.cjs +4 -1
  52. package/dist/inspection/project-source.cjs.map +1 -1
  53. package/dist/inspection/protocol.cjs +10 -18
  54. package/dist/inspection/protocol.cjs.map +1 -1
  55. package/dist/inspection/protocol.d.cts +111 -173
  56. package/dist/inspection/protocol.d.mts +111 -173
  57. package/dist/inspection/protocol.d.ts +111 -173
  58. package/dist/inspection/public.mjs +73 -109
  59. package/dist/inspection/results.cjs +12 -48
  60. package/dist/inspection/results.cjs.map +1 -1
  61. package/dist/inspection/results.d.cts +124 -122
  62. package/dist/inspection/results.d.mts +124 -122
  63. package/dist/inspection/results.d.ts +124 -122
  64. package/dist/inspection/results.js +16 -20
  65. package/dist/inspection/select.cjs +80 -117
  66. package/dist/inspection/select.cjs.map +1 -1
  67. package/dist/inspection/source.cjs +14 -15
  68. package/dist/inspection/source.cjs.map +1 -1
  69. package/dist/inspection/source.d.cts +6 -3
  70. package/dist/inspection/source.d.mts +6 -3
  71. package/dist/inspection/source.d.ts +6 -3
  72. package/dist/inspection/trace.cjs +1 -1
  73. package/dist/inspection/trace.cjs.map +1 -1
  74. package/dist/load-config.cjs +17 -11
  75. package/dist/load-config.cjs.map +1 -1
  76. package/dist/load-config.d.cts +3 -2
  77. package/dist/load-config.d.mts +3 -2
  78. package/dist/load-config.d.ts +3 -2
  79. package/dist/o11y/adapter-usage-projection.cjs +5 -1
  80. package/dist/o11y/adapter-usage-projection.cjs.map +1 -1
  81. package/dist/o11y/adapter-usage-projection.d.cts +109 -1
  82. package/dist/o11y/adapter-usage-projection.d.mts +109 -1
  83. package/dist/o11y/adapter-usage-projection.d.ts +109 -1
  84. package/dist/o11y/cache-read.cjs +113 -0
  85. package/dist/o11y/cache-read.cjs.map +1 -0
  86. package/dist/o11y/cache-read.d.cts +80 -0
  87. package/dist/o11y/cache-read.d.mts +80 -0
  88. package/dist/o11y/cache-read.d.ts +80 -0
  89. package/dist/o11y/cache-read.js +8 -0
  90. package/dist/o11y/cache-read.js.map +1 -0
  91. package/dist/o11y/eval-usage.cjs +22 -1
  92. package/dist/o11y/eval-usage.cjs.map +1 -1
  93. package/dist/o11y/eval-usage.d.cts +9 -1
  94. package/dist/o11y/eval-usage.d.mts +9 -1
  95. package/dist/o11y/eval-usage.d.ts +9 -1
  96. package/dist/record/host/sqlite-host.cjs +188 -53
  97. package/dist/record/host/sqlite-host.cjs.map +1 -1
  98. package/dist/record/host/sqlite-host.d.cts +37 -1
  99. package/dist/record/host/sqlite-host.d.mts +37 -1
  100. package/dist/record/host/sqlite-host.d.ts +37 -1
  101. package/dist/record/host/sqlite-host.js +16 -8
  102. package/dist/record/maintenance/runtime.cjs +3 -3
  103. package/dist/record/maintenance/runtime.cjs.map +1 -1
  104. package/dist/record/sqlite/admission-repository.cjs +18 -18
  105. package/dist/record/sqlite/admission-repository.cjs.map +1 -1
  106. package/dist/record/sqlite/case-repository.cjs +6 -6
  107. package/dist/record/sqlite/case-repository.cjs.map +1 -1
  108. package/dist/record/sqlite/coordination-repository.cjs +25 -25
  109. package/dist/record/sqlite/coordination-repository.cjs.map +1 -1
  110. package/dist/record/sqlite/current-schema.cjs +115 -111
  111. package/dist/record/sqlite/current-schema.cjs.map +1 -1
  112. package/dist/record/sqlite/current-schema.d.cts +3 -3
  113. package/dist/record/sqlite/current-schema.d.mts +3 -3
  114. package/dist/record/sqlite/current-schema.d.ts +3 -3
  115. package/dist/record/sqlite/database.cjs +56 -53
  116. package/dist/record/sqlite/database.cjs.map +1 -1
  117. package/dist/record/sqlite/index.cjs +3 -1
  118. package/dist/record/sqlite/index.cjs.map +1 -1
  119. package/dist/record/sqlite/index.d.cts +5 -2
  120. package/dist/record/sqlite/index.d.mts +5 -2
  121. package/dist/record/sqlite/index.d.ts +5 -2
  122. package/dist/record/sqlite/legacy-schema-018.cjs +443 -0
  123. package/dist/record/sqlite/legacy-schema-018.cjs.map +1 -0
  124. package/dist/record/sqlite/legacy-schema-018.d.cts +6 -0
  125. package/dist/record/sqlite/legacy-schema-018.d.mts +6 -0
  126. package/dist/record/sqlite/legacy-schema-018.d.ts +6 -0
  127. package/dist/record/sqlite/legacy-schema-018.js +6 -0
  128. package/dist/record/sqlite/legacy-schema-018.js.map +1 -0
  129. package/dist/record/sqlite/migration.cjs +105 -46
  130. package/dist/record/sqlite/migration.cjs.map +1 -1
  131. package/dist/record/sqlite/migration.d.cts +2 -1
  132. package/dist/record/sqlite/migration.d.mts +2 -1
  133. package/dist/record/sqlite/migration.d.ts +2 -1
  134. package/dist/record/sqlite/portable-capture.cjs +13 -13
  135. package/dist/record/sqlite/portable-capture.cjs.map +1 -1
  136. package/dist/record/sqlite/registry-repository.cjs +22 -22
  137. package/dist/record/sqlite/registry-repository.cjs.map +1 -1
  138. package/dist/record/sqlite/schema.cjs +10 -2
  139. package/dist/record/sqlite/schema.cjs.map +1 -1
  140. package/dist/record/sqlite/schema.d.cts +4 -1
  141. package/dist/record/sqlite/schema.d.mts +4 -1
  142. package/dist/record/sqlite/schema.d.ts +4 -1
  143. package/dist/record/sqlite/schema.js +20 -14
  144. package/dist/record/sqlite/storage-worker.cjs +1 -1
  145. package/dist/record/sqlite/storage-worker.cjs.map +1 -1
  146. package/dist/record/sqlite/storage.cjs +316 -232
  147. package/dist/record/sqlite/storage.cjs.map +1 -1
  148. package/dist/record/sqlite/storage.d.cts +10 -2
  149. package/dist/record/sqlite/storage.d.mts +10 -2
  150. package/dist/record/sqlite/storage.d.ts +10 -2
  151. package/dist/record/sqlite/storage.js +54 -50
  152. package/dist/record/sqlite/types.cjs +1 -1
  153. package/dist/record/sqlite/types.cjs.map +1 -1
  154. package/dist/record/sqlite/types.d.cts +13 -1
  155. package/dist/record/sqlite/types.d.mts +13 -1
  156. package/dist/record/sqlite/types.d.ts +13 -1
  157. package/dist/run/cli/contribution.cjs +17 -12
  158. package/dist/run/cli/contribution.cjs.map +1 -1
  159. package/dist/run/host/lifecycle-adapter.cjs +1 -1
  160. package/dist/run/host/lifecycle-adapter.cjs.map +1 -1
  161. package/dist/run/storage/owner-identity.cjs +78 -16
  162. package/dist/run/storage/owner-identity.cjs.map +1 -1
  163. package/dist/run/storage/owner-identity.d.cts +2 -1
  164. package/dist/run/storage/owner-identity.d.mts +2 -1
  165. package/dist/run/storage/owner-identity.d.ts +2 -1
  166. package/dist/run/storage/sqlite.cjs +55 -55
  167. package/dist/run/storage/sqlite.cjs.map +1 -1
  168. package/dist/runner/accept.cjs +12 -42
  169. package/dist/runner/accept.cjs.map +1 -1
  170. package/dist/runner/accept.d.cts +2 -3
  171. package/dist/runner/accept.d.mts +2 -3
  172. package/dist/runner/accept.d.ts +2 -3
  173. package/dist/runner/adapter-usage.cjs +2 -2
  174. package/dist/runner/adapter-usage.cjs.map +1 -1
  175. package/dist/runner/adoption.cjs +14 -26
  176. package/dist/runner/adoption.cjs.map +1 -1
  177. package/dist/runner/adoption.d.cts +5 -13
  178. package/dist/runner/adoption.d.mts +5 -13
  179. package/dist/runner/adoption.d.ts +5 -13
  180. package/dist/runner/adoption.js +2 -4
  181. package/dist/runner/record.cjs +24 -18
  182. package/dist/runner/record.cjs.map +1 -1
  183. package/dist/runner/rename-experiment.cjs +5 -7
  184. package/dist/runner/rename-experiment.cjs.map +1 -1
  185. package/dist/runner/reuse-plan.cjs +37 -18
  186. package/dist/runner/reuse-plan.cjs.map +1 -1
  187. package/dist/runner/reuse-plan.d.cts +4 -1
  188. package/dist/runner/reuse-plan.d.mts +4 -1
  189. package/dist/runner/reuse-plan.d.ts +4 -1
  190. package/dist/runner/setup-prefix-plan.cjs +17 -12
  191. package/dist/runner/setup-prefix-plan.cjs.map +1 -1
  192. package/dist/runner/setup-prefix-plan.d.cts +0 -2
  193. package/dist/runner/setup-prefix-plan.d.mts +0 -2
  194. package/dist/runner/setup-prefix-plan.d.ts +0 -2
  195. package/dist/runner/setup-prefix-plan.js +8 -12
  196. package/dist/sandbox/backend.cjs +10 -1
  197. package/dist/sandbox/backend.cjs.map +1 -1
  198. package/dist/sandbox/backend.d.cts +16 -8
  199. package/dist/sandbox/backend.d.mts +16 -8
  200. package/dist/sandbox/backend.d.ts +16 -8
  201. package/dist/sandbox/backend.js +28 -26
  202. package/dist/sandbox/docker.cjs +7 -1
  203. package/dist/sandbox/docker.cjs.map +1 -1
  204. package/dist/sandbox/e2b-cache-repository.cjs +13 -3
  205. package/dist/sandbox/e2b-cache-repository.cjs.map +1 -1
  206. package/dist/sandbox/e2b-cache-repository.d.cts +3 -0
  207. package/dist/sandbox/e2b-cache-repository.d.mts +3 -0
  208. package/dist/sandbox/e2b-cache-repository.d.ts +3 -0
  209. package/dist/sandbox/e2b-cache-repository.js +16 -12
  210. package/dist/sandbox/e2b.cjs +2 -2
  211. package/dist/sandbox/e2b.cjs.map +1 -1
  212. package/dist/sandbox/incus/materialize.cjs +1 -1
  213. package/dist/sandbox/incus/materialize.cjs.map +1 -1
  214. package/dist/show/contribution.cjs +3 -3
  215. package/dist/show/contribution.cjs.map +1 -1
  216. package/dist/show/model.cjs +14 -13
  217. package/dist/show/model.cjs.map +1 -1
  218. package/dist/show/model.d.cts +7 -7
  219. package/dist/show/model.d.mts +7 -7
  220. package/dist/show/model.d.ts +7 -7
  221. package/dist/show/render.cjs +14 -0
  222. package/dist/show/render.cjs.map +1 -1
  223. package/dist/user-database/storage-worker.cjs +13 -3
  224. package/dist/user-database/storage-worker.cjs.map +1 -1
  225. package/dist/view/app-dist/.vite/manifest.json +2 -2
  226. package/dist/view/app-dist/assets/{index-CmVoXbwG.js → index-B3ijZRph.js} +17 -17
  227. package/dist/view/app-dist/assets/{quality-cost-scatter-BuLISaH4.js → quality-cost-scatter-B--DfJ9s.js} +1 -1
  228. package/dist/view/app-dist/index.html +1 -1
  229. package/dist/view/application-runtime.cjs +8 -0
  230. package/dist/view/application-runtime.cjs.map +1 -0
  231. package/dist/view/application-runtime.d.cts +9 -0
  232. package/dist/view/application-runtime.d.mts +9 -0
  233. package/dist/view/application-runtime.d.ts +9 -0
  234. package/dist/view/application-runtime.js +6 -0
  235. package/dist/view/application-runtime.js.map +1 -0
  236. package/dist/view/cli/contribution.cjs +5 -2
  237. package/dist/view/cli/contribution.cjs.map +1 -1
  238. package/dist/view/cli/contribution.d.cts +2 -1
  239. package/dist/view/cli/contribution.d.mts +2 -1
  240. package/dist/view/cli/contribution.d.ts +2 -1
  241. package/dist/view/function-runtime.mjs +1019 -456
  242. package/dist/view/http-protocol.d.cts +1 -9
  243. package/dist/view/http-protocol.d.mts +1 -9
  244. package/dist/view/http-protocol.d.ts +1 -9
  245. package/dist/view/inspection-host.cjs +39 -30
  246. package/dist/view/inspection-host.cjs.map +1 -1
  247. package/dist/view/inspection-host.d.cts +7545 -2
  248. package/dist/view/inspection-host.d.mts +7545 -2
  249. package/dist/view/inspection-host.d.ts +7545 -2
  250. package/dist/view/server.cjs +8 -5
  251. package/dist/view/server.cjs.map +1 -1
  252. package/dist/view/server.d.cts +4 -2
  253. package/dist/view/server.d.mts +4 -2
  254. package/dist/view/server.d.ts +4 -2
  255. package/docs-site/zh/reference/cli.mdx +1 -2
  256. package/docs-site/zh/tutorials/control-run-cost.mdx +61 -0
  257. package/docs-site/zh/tutorials/niceeval-taste-application.mdx +21 -0
  258. package/package.json +1 -1
@@ -2,12 +2,12 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.RECORD_SQLITE_BASELINE_SQL = void 0;
4
4
  /**
5
- * Exact current ProjectDatabase 0.18 schema, independent of frozen historical
5
+ * Exact current ProjectDatabase 0.19 schema, independent of frozen historical
6
6
  * baselines. Keep these bytes stable within this format: they own its fingerprint.
7
- * The disjoint namespace fences writers prepared against the 0.17 tables.
7
+ * The disjoint namespace fences writers prepared against the 0.18 tables.
8
8
  */
9
9
  exports.RECORD_SQLITE_BASELINE_SQL = `
10
- CREATE TABLE ne18_record_metadata (
10
+ CREATE TABLE ne19_record_metadata (
11
11
  singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
12
12
  format TEXT NOT NULL,
13
13
  storage_revision INTEGER NOT NULL CHECK (storage_revision > 0),
@@ -26,7 +26,7 @@ CREATE TABLE ne18_record_metadata (
26
26
  CHECK ((barrier_state = 'portable') = (portable_revision IS NOT NULL)),
27
27
  CHECK ((barrier_state = 'open') = (portable_gate_id IS NULL))
28
28
  ) STRICT;
29
- CREATE TABLE ne18_coordination_state (
29
+ CREATE TABLE ne19_coordination_state (
30
30
  singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
31
31
  revision INTEGER NOT NULL CHECK (revision >= 0),
32
32
  operational_generation TEXT NOT NULL,
@@ -78,7 +78,7 @@ CREATE TABLE ne18_coordination_state (
78
78
  (barrier_status = 'active' AND barrier_active_at IS NOT NULL)
79
79
  )
80
80
  ) STRICT;
81
- CREATE TABLE ne18_coordination_tickets (
81
+ CREATE TABLE ne19_coordination_tickets (
82
82
  ticket_id TEXT PRIMARY KEY,
83
83
  sequence INTEGER NOT NULL UNIQUE CHECK (sequence > 0),
84
84
  host TEXT NOT NULL,
@@ -88,8 +88,9 @@ CREATE TABLE ne18_coordination_tickets (
88
88
  deadline INTEGER NOT NULL CHECK (deadline > 0),
89
89
  enqueued_at INTEGER NOT NULL CHECK (enqueued_at > 0)
90
90
  ) STRICT;
91
- CREATE TABLE ne18_runs (
91
+ CREATE TABLE ne19_runs (
92
92
  run_id TEXT PRIMARY KEY,
93
+ experiment_id TEXT NOT NULL,
93
94
  status TEXT NOT NULL CHECK (status IN ('open','sealing','sealed')),
94
95
  writer_generation TEXT NOT NULL,
95
96
  started_at TEXT NOT NULL,
@@ -108,8 +109,8 @@ CREATE TABLE ne18_runs (
108
109
  CHECK ((status = 'sealed') = (logical_seal_identity IS NOT NULL)),
109
110
  CHECK (status = 'open' OR core_payload IS NOT NULL)
110
111
  ) STRICT;
111
- CREATE TABLE ne18_slots (
112
- run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,
112
+ CREATE TABLE ne19_slots (
113
+ run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
113
114
  slot_id TEXT NOT NULL,
114
115
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
115
116
  core_payload BLOB NOT NULL,
@@ -117,8 +118,8 @@ CREATE TABLE ne18_slots (
117
118
  PRIMARY KEY (run_id, slot_id),
118
119
  UNIQUE (run_id, ordinal)
119
120
  ) STRICT;
120
- CREATE TABLE ne18_attempts (
121
- origin_run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,
121
+ CREATE TABLE ne19_attempts (
122
+ origin_run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
122
123
  attempt_id TEXT NOT NULL,
123
124
  attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),
124
125
  publication_state TEXT NOT NULL DEFAULT 'staging' CHECK (publication_state IN ('staging','sealing','published')),
@@ -127,7 +128,7 @@ CREATE TABLE ne18_attempts (
127
128
  CHECK ((core_payload IS NULL) = (core_digest IS NULL)),
128
129
  PRIMARY KEY (origin_run_id, attempt_id)
129
130
  ) STRICT;
130
- CREATE TABLE ne18_members (
131
+ CREATE TABLE ne19_members (
131
132
  target_run_id TEXT NOT NULL,
132
133
  slot_id TEXT NOT NULL,
133
134
  origin_run_id TEXT,
@@ -140,12 +141,12 @@ CREATE TABLE ne18_members (
140
141
  (action IN ('executed','carried','accepted') AND origin_run_id IS NOT NULL AND attempt_id IS NOT NULL) OR
141
142
  (action IN ('not-dispatched','interrupted') AND origin_run_id IS NULL AND attempt_id IS NULL)
142
143
  ),
143
- FOREIGN KEY (target_run_id, slot_id) REFERENCES ne18_slots(run_id, slot_id) ON DELETE CASCADE
144
+ FOREIGN KEY (target_run_id, slot_id) REFERENCES ne19_slots(run_id, slot_id) ON DELETE CASCADE
144
145
  ) STRICT;
145
- CREATE TABLE ne18_attachments (
146
+ CREATE TABLE ne19_attachments (
146
147
  attachment_id TEXT PRIMARY KEY,
147
148
  owner_kind TEXT NOT NULL CHECK (owner_kind IN ('run','attempt')),
148
- owner_run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,
149
+ owner_run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
149
150
  owner_attempt_id TEXT,
150
151
  family TEXT NOT NULL,
151
152
  family_revision INTEGER NOT NULL CHECK (family_revision > 0),
@@ -158,10 +159,10 @@ CREATE TABLE ne18_attachments (
158
159
  CHECK ((logical_inventory IS NULL) = (inventory_digest IS NULL)),
159
160
  CHECK ((owner_kind = 'run' AND owner_attempt_id IS NULL) OR (owner_kind = 'attempt' AND owner_attempt_id IS NOT NULL)),
160
161
  UNIQUE (owner_kind, owner_run_id, owner_attempt_id, family),
161
- FOREIGN KEY (owner_run_id, owner_attempt_id) REFERENCES ne18_attempts(origin_run_id, attempt_id) ON DELETE CASCADE
162
+ FOREIGN KEY (owner_run_id, owner_attempt_id) REFERENCES ne19_attempts(origin_run_id, attempt_id) ON DELETE CASCADE
162
163
  ) STRICT;
163
- CREATE TABLE ne18_attachment_references (
164
- attachment_id TEXT NOT NULL REFERENCES ne18_attachments(attachment_id) ON DELETE CASCADE,
164
+ CREATE TABLE ne19_attachment_references (
165
+ attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,
165
166
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
166
167
  target_owner_kind TEXT NOT NULL CHECK (target_owner_kind IN ('run','attempt')),
167
168
  target_family TEXT NOT NULL,
@@ -169,8 +170,8 @@ CREATE TABLE ne18_attachment_references (
169
170
  reference_digest TEXT NOT NULL CHECK (length(reference_digest) = 64),
170
171
  PRIMARY KEY (attachment_id, ordinal)
171
172
  ) STRICT;
172
- CREATE TABLE ne18_collection_items (
173
- attachment_id TEXT NOT NULL REFERENCES ne18_attachments(attachment_id) ON DELETE CASCADE,
173
+ CREATE TABLE ne19_collection_items (
174
+ attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,
174
175
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
175
176
  logical_identity TEXT NOT NULL,
176
177
  canonical_payload BLOB NOT NULL,
@@ -178,9 +179,9 @@ CREATE TABLE ne18_collection_items (
178
179
  PRIMARY KEY (attachment_id, ordinal),
179
180
  UNIQUE (attachment_id, logical_identity)
180
181
  ) STRICT;
181
- CREATE TABLE ne18_contents (
182
+ CREATE TABLE ne19_contents (
182
183
  content_id TEXT PRIMARY KEY,
183
- attachment_id TEXT NOT NULL REFERENCES ne18_attachments(attachment_id) ON DELETE CASCADE,
184
+ attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,
184
185
  logical_handle TEXT NOT NULL,
185
186
  byte_length INTEGER CHECK (byte_length IS NULL OR byte_length >= 0),
186
187
  overall_digest TEXT CHECK (overall_digest IS NULL OR length(overall_digest) = 64),
@@ -188,15 +189,15 @@ CREATE TABLE ne18_contents (
188
189
  CHECK ((byte_length IS NULL) = (overall_digest IS NULL) AND (overall_digest IS NULL) = (chunk_count IS NULL)),
189
190
  UNIQUE (attachment_id, logical_handle)
190
191
  ) STRICT;
191
- CREATE TABLE ne18_content_chunks (
192
- content_id TEXT NOT NULL REFERENCES ne18_contents(content_id) ON DELETE CASCADE,
192
+ CREATE TABLE ne19_content_chunks (
193
+ content_id TEXT NOT NULL REFERENCES ne19_contents(content_id) ON DELETE CASCADE,
193
194
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
194
195
  bytes BLOB NOT NULL CHECK (length(bytes) <= 262144),
195
196
  chunk_digest TEXT NOT NULL CHECK (length(chunk_digest) = 64),
196
197
  PRIMARY KEY (content_id, ordinal)
197
198
  ) STRICT;
198
- CREATE TABLE ne18_run_seal_entries (
199
- run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,
199
+ CREATE TABLE ne19_run_seal_entries (
200
+ run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,
200
201
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
201
202
  entry_kind TEXT NOT NULL CHECK (entry_kind IN ('record','run','slot','member','attempt','attachment','attachment-reference','collection-item','content','content-chunk')),
202
203
  logical_identity TEXT NOT NULL,
@@ -204,54 +205,54 @@ CREATE TABLE ne18_run_seal_entries (
204
205
  PRIMARY KEY (run_id, ordinal),
205
206
  UNIQUE (run_id, entry_kind, logical_identity)
206
207
  ) STRICT;
207
- CREATE INDEX ne18_attachments_owner_family ON ne18_attachments(owner_kind, owner_run_id, owner_attempt_id, family);
208
- CREATE UNIQUE INDEX ne18_attachments_owner_family_unique ON ne18_attachments(owner_kind, owner_run_id, coalesce(owner_attempt_id,''), family);
209
- CREATE INDEX ne18_members_origin_attempt ON ne18_members(origin_run_id, attempt_id, target_run_id);
210
- CREATE INDEX ne18_attempts_locator ON ne18_attempts(attempt_locator, origin_run_id, attempt_id);
211
- CREATE INDEX ne18_references_target_family ON ne18_attachment_references(target_owner_kind, target_family);
212
- CREATE INDEX ne18_content_chunks_page ON ne18_content_chunks(content_id, ordinal);
213
- CREATE INDEX ne18_coordination_tickets_fifo ON ne18_coordination_tickets(sequence);
214
- CREATE TRIGGER ne18_coordination_ticket_barrier_insert BEFORE INSERT ON ne18_coordination_tickets WHEN (SELECT barrier_state FROM ne18_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;
215
- CREATE TRIGGER ne18_coordination_writer_barrier_update BEFORE UPDATE ON ne18_coordination_state WHEN NEW.writer_ticket_id IS NOT NULL AND (SELECT barrier_state FROM ne18_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;
216
- CREATE TRIGGER ne18_runs_sealed_update BEFORE UPDATE ON ne18_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;
217
- CREATE TRIGGER ne18_runs_sealed_delete BEFORE DELETE ON ne18_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;
218
- CREATE TRIGGER ne18_slots_sealed_insert BEFORE INSERT ON ne18_slots WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
219
- CREATE TRIGGER ne18_slots_sealed_update BEFORE UPDATE ON ne18_slots WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
220
- CREATE TRIGGER ne18_slots_sealed_delete BEFORE DELETE ON ne18_slots WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
221
- CREATE TRIGGER ne18_attempts_sealed_insert BEFORE INSERT ON ne18_attempts WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
222
- CREATE TRIGGER ne18_attempts_sealed_update BEFORE UPDATE ON ne18_attempts WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
223
- CREATE TRIGGER ne18_attempts_sealed_delete BEFORE DELETE ON ne18_attempts WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
224
- CREATE TRIGGER ne18_members_sealed_insert BEFORE INSERT ON ne18_members WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
225
- CREATE TRIGGER ne18_members_sealed_update BEFORE UPDATE ON ne18_members WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
226
- CREATE TRIGGER ne18_members_sealed_delete BEFORE DELETE ON ne18_members WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
227
- CREATE TRIGGER ne18_attachments_sealed_insert BEFORE INSERT ON ne18_attachments WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
228
- CREATE TRIGGER ne18_attachments_attempt_published_insert BEFORE INSERT ON ne18_attachments WHEN NEW.owner_kind='attempt' AND (SELECT publication_state FROM ne18_attempts WHERE origin_run_id=NEW.owner_run_id AND attempt_id=NEW.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
229
- CREATE TRIGGER ne18_attachments_sealed_update BEFORE UPDATE ON ne18_attachments WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
230
- CREATE TRIGGER ne18_attachments_attempt_published_update BEFORE UPDATE ON ne18_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne18_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
231
- CREATE TRIGGER ne18_attachments_sealed_delete BEFORE DELETE ON ne18_attachments WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
232
- CREATE TRIGGER ne18_attachments_attempt_published_delete BEFORE DELETE ON ne18_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne18_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
233
- CREATE TRIGGER ne18_references_sealed_insert BEFORE INSERT ON ne18_attachment_references WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
234
- CREATE TRIGGER ne18_references_sealed_update BEFORE UPDATE ON ne18_attachment_references WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
235
- CREATE TRIGGER ne18_references_sealed_delete BEFORE DELETE ON ne18_attachment_references WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
236
- CREATE TRIGGER ne18_items_sealed_insert BEFORE INSERT ON ne18_collection_items WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
237
- CREATE TRIGGER ne18_items_sealed_update BEFORE UPDATE ON ne18_collection_items WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
238
- CREATE TRIGGER ne18_items_sealed_delete BEFORE DELETE ON ne18_collection_items WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
239
- CREATE TRIGGER ne18_contents_sealed_insert BEFORE INSERT ON ne18_contents WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
240
- CREATE TRIGGER ne18_contents_sealed_update BEFORE UPDATE ON ne18_contents WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
241
- CREATE TRIGGER ne18_contents_sealed_delete BEFORE DELETE ON ne18_contents WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
242
- CREATE TRIGGER ne18_chunks_sealed_insert BEFORE INSERT ON ne18_content_chunks WHEN (SELECT r.status FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=NEW.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
243
- CREATE TRIGGER ne18_chunks_sealed_update BEFORE UPDATE ON ne18_content_chunks WHEN (SELECT r.status FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
244
- CREATE TRIGGER ne18_chunks_sealed_delete BEFORE DELETE ON ne18_content_chunks WHEN (SELECT r.status FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
245
- CREATE TRIGGER ne18_seal_entries_sealed_insert BEFORE INSERT ON ne18_run_seal_entries WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.run_id) != 'sealing' BEGIN SELECT RAISE(ABORT, 'Seal candidates require sealing state'); END;
246
- CREATE TRIGGER ne18_seal_entries_sealed_update BEFORE UPDATE ON ne18_run_seal_entries BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;
247
- CREATE TRIGGER ne18_seal_entries_sealed_delete BEFORE DELETE ON ne18_run_seal_entries WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;
208
+ CREATE INDEX ne19_attachments_owner_family ON ne19_attachments(owner_kind, owner_run_id, owner_attempt_id, family);
209
+ CREATE UNIQUE INDEX ne19_attachments_owner_family_unique ON ne19_attachments(owner_kind, owner_run_id, coalesce(owner_attempt_id,''), family);
210
+ CREATE INDEX ne19_members_origin_attempt ON ne19_members(origin_run_id, attempt_id, target_run_id);
211
+ CREATE INDEX ne19_attempts_locator ON ne19_attempts(attempt_locator, origin_run_id, attempt_id);
212
+ CREATE INDEX ne19_references_target_family ON ne19_attachment_references(target_owner_kind, target_family);
213
+ CREATE INDEX ne19_content_chunks_page ON ne19_content_chunks(content_id, ordinal);
214
+ CREATE INDEX ne19_coordination_tickets_fifo ON ne19_coordination_tickets(sequence);
215
+ CREATE TRIGGER ne19_coordination_ticket_barrier_insert BEFORE INSERT ON ne19_coordination_tickets WHEN (SELECT barrier_state FROM ne19_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;
216
+ CREATE TRIGGER ne19_coordination_writer_barrier_update BEFORE UPDATE ON ne19_coordination_state WHEN NEW.writer_ticket_id IS NOT NULL AND (SELECT barrier_state FROM ne19_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;
217
+ CREATE TRIGGER ne19_runs_sealed_update BEFORE UPDATE ON ne19_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;
218
+ CREATE TRIGGER ne19_runs_sealed_delete BEFORE DELETE ON ne19_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;
219
+ CREATE TRIGGER ne19_slots_sealed_insert BEFORE INSERT ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
220
+ CREATE TRIGGER ne19_slots_sealed_update BEFORE UPDATE ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
221
+ CREATE TRIGGER ne19_slots_sealed_delete BEFORE DELETE ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
222
+ CREATE TRIGGER ne19_attempts_sealed_insert BEFORE INSERT ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
223
+ CREATE TRIGGER ne19_attempts_sealed_update BEFORE UPDATE ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
224
+ CREATE TRIGGER ne19_attempts_sealed_delete BEFORE DELETE ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
225
+ CREATE TRIGGER ne19_members_sealed_insert BEFORE INSERT ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
226
+ CREATE TRIGGER ne19_members_sealed_update BEFORE UPDATE ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
227
+ CREATE TRIGGER ne19_members_sealed_delete BEFORE DELETE ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
228
+ CREATE TRIGGER ne19_attachments_sealed_insert BEFORE INSERT ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
229
+ CREATE TRIGGER ne19_attachments_attempt_published_insert BEFORE INSERT ON ne19_attachments WHEN NEW.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=NEW.owner_run_id AND attempt_id=NEW.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
230
+ CREATE TRIGGER ne19_attachments_sealed_update BEFORE UPDATE ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
231
+ CREATE TRIGGER ne19_attachments_attempt_published_update BEFORE UPDATE ON ne19_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
232
+ CREATE TRIGGER ne19_attachments_sealed_delete BEFORE DELETE ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
233
+ CREATE TRIGGER ne19_attachments_attempt_published_delete BEFORE DELETE ON ne19_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;
234
+ CREATE TRIGGER ne19_references_sealed_insert BEFORE INSERT ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
235
+ CREATE TRIGGER ne19_references_sealed_update BEFORE UPDATE ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
236
+ CREATE TRIGGER ne19_references_sealed_delete BEFORE DELETE ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
237
+ CREATE TRIGGER ne19_items_sealed_insert BEFORE INSERT ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
238
+ CREATE TRIGGER ne19_items_sealed_update BEFORE UPDATE ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
239
+ CREATE TRIGGER ne19_items_sealed_delete BEFORE DELETE ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
240
+ CREATE TRIGGER ne19_contents_sealed_insert BEFORE INSERT ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
241
+ CREATE TRIGGER ne19_contents_sealed_update BEFORE UPDATE ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
242
+ CREATE TRIGGER ne19_contents_sealed_delete BEFORE DELETE ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
243
+ CREATE TRIGGER ne19_chunks_sealed_insert BEFORE INSERT ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=NEW.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
244
+ CREATE TRIGGER ne19_chunks_sealed_update BEFORE UPDATE ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
245
+ CREATE TRIGGER ne19_chunks_sealed_delete BEFORE DELETE ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;
246
+ CREATE TRIGGER ne19_seal_entries_sealed_insert BEFORE INSERT ON ne19_run_seal_entries WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.run_id) != 'sealing' BEGIN SELECT RAISE(ABORT, 'Seal candidates require sealing state'); END;
247
+ CREATE TRIGGER ne19_seal_entries_sealed_update BEFORE UPDATE ON ne19_run_seal_entries BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;
248
+ CREATE TRIGGER ne19_seal_entries_sealed_delete BEFORE DELETE ON ne19_run_seal_entries WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;
248
249
 
249
250
 
250
- CREATE TABLE ne18_run_publication_clock (
251
+ CREATE TABLE ne19_run_publication_clock (
251
252
  singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
252
253
  revision INTEGER NOT NULL CHECK (revision >= 0)
253
254
  ) STRICT;
254
- CREATE TABLE ne18_run_resources (
255
+ CREATE TABLE ne19_run_resources (
255
256
  run_id TEXT PRIMARY KEY,
256
257
  invocation_id TEXT NOT NULL,
257
258
  experiment_id TEXT NOT NULL,
@@ -265,8 +266,8 @@ CREATE TABLE ne18_run_resources (
265
266
  CHECK ((terminal_state IS NULL) = (completed_at IS NULL)),
266
267
  CHECK ((terminal_state IS NULL) = (close_revision IS NULL))
267
268
  ) STRICT;
268
- CREATE TABLE ne18_run_expected_slots (
269
- run_id TEXT NOT NULL REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,
269
+ CREATE TABLE ne19_run_expected_slots (
270
+ run_id TEXT NOT NULL REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
270
271
  slot_id TEXT NOT NULL,
271
272
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
272
273
  eval_id TEXT NOT NULL,
@@ -275,7 +276,7 @@ CREATE TABLE ne18_run_expected_slots (
275
276
  PRIMARY KEY (run_id, slot_id),
276
277
  UNIQUE (run_id, ordinal)
277
278
  ) STRICT;
278
- CREATE TABLE ne18_attempt_publications (
279
+ CREATE TABLE ne19_attempt_publications (
279
280
  attempt_id TEXT PRIMARY KEY,
280
281
  attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),
281
282
  origin_run_id TEXT NOT NULL,
@@ -283,31 +284,31 @@ CREATE TABLE ne18_attempt_publications (
283
284
  closure_payload BLOB NOT NULL,
284
285
  closure_digest TEXT NOT NULL CHECK (length(closure_digest) = 64),
285
286
  published_revision INTEGER NOT NULL UNIQUE CHECK (published_revision > 0),
286
- FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
287
+ FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
287
288
  ) STRICT;
288
- CREATE TABLE ne18_run_slot_bindings (
289
+ CREATE TABLE ne19_run_slot_bindings (
289
290
  target_run_id TEXT NOT NULL,
290
291
  slot_id TEXT NOT NULL,
291
- attempt_id TEXT NOT NULL REFERENCES ne18_attempt_publications(attempt_id) ON DELETE RESTRICT,
292
+ attempt_id TEXT NOT NULL REFERENCES ne19_attempt_publications(attempt_id) ON DELETE RESTRICT,
292
293
  origin_run_id TEXT NOT NULL,
293
294
  origin_slot_id TEXT NOT NULL,
294
295
  attempt_publication_revision INTEGER NOT NULL CHECK (attempt_publication_revision > 0),
295
296
  action TEXT NOT NULL CHECK (action IN ('executed','carried','accepted')),
296
297
  binding_revision INTEGER NOT NULL UNIQUE CHECK (binding_revision > 0),
297
298
  PRIMARY KEY (target_run_id, slot_id),
298
- FOREIGN KEY (target_run_id, slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT,
299
- FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
299
+ FOREIGN KEY (target_run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT,
300
+ FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
300
301
  ) STRICT;
301
- CREATE TABLE ne18_run_slot_absences (
302
+ CREATE TABLE ne19_run_slot_absences (
302
303
  run_id TEXT NOT NULL,
303
304
  slot_id TEXT NOT NULL,
304
305
  reason TEXT NOT NULL CHECK (reason IN ('early-exit-satisfied','budget-exhausted','stopped-by-failure','interrupted-before-publication','dispatch-failed')),
305
306
  absence_revision INTEGER NOT NULL CHECK (absence_revision > 0),
306
307
  PRIMARY KEY (run_id, slot_id),
307
- FOREIGN KEY (run_id, slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
308
+ FOREIGN KEY (run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
308
309
  ) STRICT;
309
- CREATE TABLE ne18_run_recoveries (
310
- run_id TEXT PRIMARY KEY REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,
310
+ CREATE TABLE ne19_run_recoveries (
311
+ run_id TEXT PRIMARY KEY REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
311
312
  previous_writer_generation TEXT NOT NULL,
312
313
  recovery_writer_generation TEXT NOT NULL,
313
314
  evidence_kind TEXT NOT NULL,
@@ -315,22 +316,25 @@ CREATE TABLE ne18_run_recoveries (
315
316
  evidence_observed_at TEXT NOT NULL,
316
317
  recovery_revision INTEGER NOT NULL UNIQUE CHECK (recovery_revision > 0)
317
318
  ) STRICT;
318
- CREATE TABLE ne18_run_deletion_tombstones (
319
- run_id TEXT PRIMARY KEY REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,
319
+ CREATE TABLE ne19_run_deletion_tombstones (
320
+ run_id TEXT PRIMARY KEY REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
320
321
  terminal_state TEXT NOT NULL CHECK (terminal_state IN ('completed','interrupted','failed')),
321
322
  deleted_at TEXT NOT NULL,
322
323
  deletion_revision INTEGER NOT NULL UNIQUE CHECK (deletion_revision > 0)
323
324
  ) STRICT;
324
- CREATE INDEX ne18_run_resources_list ON ne18_run_resources(created_revision, run_id);
325
- CREATE INDEX ne18_run_resources_invocation ON ne18_run_resources(invocation_id, created_revision, run_id);
326
- CREATE INDEX ne18_attempt_publications_origin ON ne18_attempt_publications(origin_run_id, origin_slot_id);
327
- CREATE INDEX ne18_attempt_publications_locator ON ne18_attempt_publications(attempt_locator, origin_run_id, attempt_id);
328
- CREATE INDEX ne18_run_slot_bindings_attempt ON ne18_run_slot_bindings(attempt_id, target_run_id, slot_id);
329
- CREATE INDEX ne18_run_deletion_revision ON ne18_run_deletion_tombstones(deletion_revision, run_id);
330
- INSERT INTO ne18_run_publication_clock(singleton,revision) VALUES (1,0);
325
+ CREATE INDEX ne19_runs_experiment ON ne19_runs(experiment_id,run_id);
326
+ CREATE INDEX ne19_run_resources_experiment ON ne19_run_resources(experiment_id,created_revision,run_id);
327
+ CREATE INDEX ne19_run_expected_slots_position ON ne19_run_expected_slots(eval_id,attempt_ordinal,run_id);
328
+ CREATE INDEX ne19_run_resources_list ON ne19_run_resources(created_revision, run_id);
329
+ CREATE INDEX ne19_run_resources_invocation ON ne19_run_resources(invocation_id, created_revision, run_id);
330
+ CREATE INDEX ne19_attempt_publications_origin ON ne19_attempt_publications(origin_run_id, origin_slot_id);
331
+ CREATE INDEX ne19_attempt_publications_locator ON ne19_attempt_publications(attempt_locator, origin_run_id, attempt_id);
332
+ CREATE INDEX ne19_run_slot_bindings_attempt ON ne19_run_slot_bindings(attempt_id, target_run_id, slot_id);
333
+ CREATE INDEX ne19_run_deletion_revision ON ne19_run_deletion_tombstones(deletion_revision, run_id);
334
+ INSERT INTO ne19_run_publication_clock(singleton,revision) VALUES (1,0);
331
335
 
332
336
 
333
- CREATE TABLE ne18_invocation_sessions (
337
+ CREATE TABLE ne19_invocation_sessions (
334
338
  invocation_id TEXT PRIMARY KEY,
335
339
  state TEXT NOT NULL CHECK (state IN ('active','recovering','completed','interrupted','failed')),
336
340
  owner_id TEXT NOT NULL,
@@ -350,25 +354,25 @@ CREATE TABLE ne18_invocation_sessions (
350
354
  CHECK (state IN ('active','recovering') OR active_projection IS NULL),
351
355
  CHECK ((state = 'recovering') = (recovering_at IS NOT NULL))
352
356
  ) STRICT;
353
- CREATE TABLE ne18_invocation_session_experiments (
354
- invocation_id TEXT NOT NULL REFERENCES ne18_invocation_sessions(invocation_id) ON DELETE RESTRICT,
357
+ CREATE TABLE ne19_invocation_session_experiments (
358
+ invocation_id TEXT NOT NULL REFERENCES ne19_invocation_sessions(invocation_id) ON DELETE RESTRICT,
355
359
  experiment_id TEXT NOT NULL,
356
- run_id TEXT NOT NULL UNIQUE REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,
360
+ run_id TEXT NOT NULL UNIQUE REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
357
361
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
358
362
  PRIMARY KEY (invocation_id, experiment_id),
359
363
  UNIQUE (invocation_id, ordinal)
360
364
  ) STRICT;
361
- CREATE TABLE ne18_invocation_session_queued_attempts (
362
- invocation_id TEXT NOT NULL REFERENCES ne18_invocation_sessions(invocation_id) ON DELETE RESTRICT,
365
+ CREATE TABLE ne19_invocation_session_queued_attempts (
366
+ invocation_id TEXT NOT NULL REFERENCES ne19_invocation_sessions(invocation_id) ON DELETE RESTRICT,
363
367
  attempt_id TEXT NOT NULL,
364
- run_id TEXT NOT NULL REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,
368
+ run_id TEXT NOT NULL REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,
365
369
  slot_id TEXT NOT NULL,
366
370
  ordinal INTEGER NOT NULL CHECK (ordinal >= 0),
367
371
  PRIMARY KEY (invocation_id, attempt_id),
368
372
  UNIQUE (invocation_id, ordinal),
369
- FOREIGN KEY (run_id, slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
373
+ FOREIGN KEY (run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT
370
374
  ) STRICT;
371
- CREATE TABLE ne18_case_locks (
375
+ CREATE TABLE ne19_case_locks (
372
376
  case_id TEXT PRIMARY KEY,
373
377
  owner_id TEXT NOT NULL,
374
378
  owner_generation INTEGER NOT NULL CHECK (owner_generation > 0),
@@ -379,11 +383,11 @@ CREATE TABLE ne18_case_locks (
379
383
  acquired_at TEXT NOT NULL,
380
384
  heartbeat_at TEXT NOT NULL
381
385
  ) STRICT;
382
- CREATE INDEX ne18_invocation_sessions_state ON ne18_invocation_sessions(state, started_at, invocation_id);
383
- CREATE INDEX ne18_invocation_session_experiments_invocation ON ne18_invocation_session_experiments(invocation_id, ordinal);
384
- CREATE INDEX ne18_invocation_session_queued_attempts_run ON ne18_invocation_session_queued_attempts(run_id, slot_id);
385
- CREATE INDEX ne18_case_locks_owner ON ne18_case_locks(owner_id, owner_generation);
386
- CREATE TABLE ne18_teardown_obligations (
386
+ CREATE INDEX ne19_invocation_sessions_state ON ne19_invocation_sessions(state, started_at, invocation_id);
387
+ CREATE INDEX ne19_invocation_session_experiments_invocation ON ne19_invocation_session_experiments(invocation_id, ordinal);
388
+ CREATE INDEX ne19_invocation_session_queued_attempts_run ON ne19_invocation_session_queued_attempts(run_id, slot_id);
389
+ CREATE INDEX ne19_case_locks_owner ON ne19_case_locks(owner_id, owner_generation);
390
+ CREATE TABLE ne19_teardown_obligations (
387
391
  obligation_id TEXT PRIMARY KEY,
388
392
  experiment_id TEXT NOT NULL,
389
393
  owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),
@@ -392,7 +396,7 @@ CREATE TABLE ne18_teardown_obligations (
392
396
  payload BLOB NOT NULL,
393
397
  UNIQUE (experiment_id, owner_pid)
394
398
  ) STRICT;
395
- CREATE TABLE ne18_shared_state_generations (
399
+ CREATE TABLE ne19_shared_state_generations (
396
400
  state_key TEXT NOT NULL,
397
401
  generation INTEGER NOT NULL CHECK (generation > 0),
398
402
  parent_generation INTEGER NOT NULL CHECK (parent_generation >= 0),
@@ -406,7 +410,7 @@ CREATE TABLE ne18_shared_state_generations (
406
410
  PRIMARY KEY (state_key, generation),
407
411
  CHECK (parent_generation = generation - 1)
408
412
  ) STRICT;
409
- CREATE TABLE ne18_kept_sandboxes (
413
+ CREATE TABLE ne19_kept_sandboxes (
410
414
  entry_id TEXT PRIMARY KEY,
411
415
  provider TEXT NOT NULL,
412
416
  sandbox_id TEXT NOT NULL,
@@ -415,8 +419,8 @@ CREATE TABLE ne18_kept_sandboxes (
415
419
  payload BLOB NOT NULL,
416
420
  UNIQUE (provider, sandbox_id)
417
421
  ) STRICT;
418
- CREATE TABLE ne18_kept_sandbox_operation_leases (
419
- entry_id TEXT PRIMARY KEY REFERENCES ne18_kept_sandboxes(entry_id) ON DELETE CASCADE,
422
+ CREATE TABLE ne19_kept_sandbox_operation_leases (
423
+ entry_id TEXT PRIMARY KEY REFERENCES ne19_kept_sandboxes(entry_id) ON DELETE CASCADE,
420
424
  generation INTEGER NOT NULL CHECK (generation > 0),
421
425
  token TEXT NOT NULL,
422
426
  holder TEXT NOT NULL,
@@ -427,12 +431,12 @@ CREATE TABLE ne18_kept_sandbox_operation_leases (
427
431
  acquired_at TEXT NOT NULL,
428
432
  ttl_ms INTEGER NOT NULL CHECK (ttl_ms > 0)
429
433
  ) STRICT;
430
- CREATE INDEX ne18_teardown_obligations_experiment ON ne18_teardown_obligations(experiment_id, owner_pid);
431
- CREATE INDEX ne18_shared_state_generations_head ON ne18_shared_state_generations(state_key, generation DESC);
432
- CREATE INDEX ne18_kept_sandboxes_kept_at ON ne18_kept_sandboxes(kept_at, entry_id);
434
+ CREATE INDEX ne19_teardown_obligations_experiment ON ne19_teardown_obligations(experiment_id, owner_pid);
435
+ CREATE INDEX ne19_shared_state_generations_head ON ne19_shared_state_generations(state_key, generation DESC);
436
+ CREATE INDEX ne19_kept_sandboxes_kept_at ON ne19_kept_sandboxes(kept_at, entry_id);
433
437
 
434
438
 
435
- CREATE TABLE ne18_migration_state (
439
+ CREATE TABLE ne19_migration_state (
436
440
  singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
437
441
  state TEXT NOT NULL CHECK (state IN ('committed','ready')),
438
442
  source_format TEXT,
@@ -1 +1 @@
1
- {"version":3,"file":"current-schema.js","sourceRoot":"","sources":["current-schema.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAibhC,CAAC","sourcesContent":["/**\n * Exact current ProjectDatabase 0.18 schema, independent of frozen historical\n * baselines. Keep these bytes stable within this format: they own its fingerprint.\n * The disjoint namespace fences writers prepared against the 0.17 tables.\n */\nexport const RECORD_SQLITE_BASELINE_SQL = `\nCREATE TABLE ne18_record_metadata (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n format TEXT NOT NULL,\n storage_revision INTEGER NOT NULL CHECK (storage_revision > 0),\n storage_generation TEXT NOT NULL,\n schema_fingerprint TEXT NOT NULL CHECK (length(schema_fingerprint) = 64),\n created_at TEXT NOT NULL,\n barrier_state TEXT NOT NULL CHECK (barrier_state IN ('open','draining','portable')),\n portable_generation TEXT,\n portable_revision INTEGER CHECK (portable_revision IS NULL OR portable_revision >= 0),\n portable_gate_id TEXT,\n record_payload BLOB,\n record_digest TEXT,\n CHECK ((record_payload IS NULL) = (record_digest IS NULL)),\n CHECK (record_digest IS NULL OR length(record_digest) = 64),\n CHECK ((barrier_state = 'portable') = (portable_generation IS NOT NULL)),\n CHECK ((barrier_state = 'portable') = (portable_revision IS NOT NULL)),\n CHECK ((barrier_state = 'open') = (portable_gate_id IS NULL))\n) STRICT;\nCREATE TABLE ne18_coordination_state (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n revision INTEGER NOT NULL CHECK (revision >= 0),\n operational_generation TEXT NOT NULL,\n next_writer_sequence INTEGER NOT NULL CHECK (next_writer_sequence > 0),\n writer_ticket_id TEXT,\n writer_sequence INTEGER CHECK (writer_sequence IS NULL OR writer_sequence > 0),\n writer_host TEXT,\n writer_pid INTEGER CHECK (writer_pid IS NULL OR writer_pid > 0),\n writer_boot_id TEXT,\n writer_process_start TEXT,\n writer_deadline INTEGER CHECK (writer_deadline IS NULL OR writer_deadline > 0),\n writer_enqueued_at INTEGER CHECK (writer_enqueued_at IS NULL OR writer_enqueued_at > 0),\n writer_nonce TEXT,\n writer_admitted_at INTEGER CHECK (writer_admitted_at IS NULL OR writer_admitted_at > 0),\n writer_lease_expires_at INTEGER CHECK (writer_lease_expires_at IS NULL OR writer_lease_expires_at > 0),\n barrier_id TEXT,\n barrier_nonce TEXT,\n barrier_host TEXT,\n barrier_pid INTEGER CHECK (barrier_pid IS NULL OR barrier_pid > 0),\n barrier_boot_id TEXT,\n barrier_process_start TEXT,\n barrier_deadline INTEGER CHECK (barrier_deadline IS NULL OR barrier_deadline > 0),\n barrier_requested_at INTEGER CHECK (barrier_requested_at IS NULL OR barrier_requested_at > 0),\n barrier_lease_expires_at INTEGER CHECK (barrier_lease_expires_at IS NULL OR barrier_lease_expires_at > 0),\n barrier_status TEXT CHECK (barrier_status IS NULL OR barrier_status IN ('requested','active')),\n barrier_active_at INTEGER CHECK (barrier_active_at IS NULL OR barrier_active_at > 0),\n CHECK ((writer_ticket_id IS NULL) = (writer_sequence IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_host IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_pid IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_boot_id IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_process_start IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_deadline IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_enqueued_at IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_nonce IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_admitted_at IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_lease_expires_at IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_nonce IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_host IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_pid IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_boot_id IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_process_start IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_deadline IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_requested_at IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_lease_expires_at IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_status IS NULL)),\n CHECK (\n (barrier_status IS NULL AND barrier_active_at IS NULL) OR\n (barrier_status = 'requested' AND barrier_active_at IS NULL) OR\n (barrier_status = 'active' AND barrier_active_at IS NOT NULL)\n )\n) STRICT;\nCREATE TABLE ne18_coordination_tickets (\n ticket_id TEXT PRIMARY KEY,\n sequence INTEGER NOT NULL UNIQUE CHECK (sequence > 0),\n host TEXT NOT NULL,\n pid INTEGER NOT NULL CHECK (pid > 0),\n boot_id TEXT NOT NULL,\n process_start TEXT NOT NULL,\n deadline INTEGER NOT NULL CHECK (deadline > 0),\n enqueued_at INTEGER NOT NULL CHECK (enqueued_at > 0)\n) STRICT;\nCREATE TABLE ne18_runs (\n run_id TEXT PRIMARY KEY,\n status TEXT NOT NULL CHECK (status IN ('open','sealing','sealed')),\n writer_generation TEXT NOT NULL,\n started_at TEXT NOT NULL,\n core_payload BLOB,\n core_digest TEXT CHECK (core_digest IS NULL OR length(core_digest) = 64),\n mutation_sequence INTEGER NOT NULL DEFAULT 0 CHECK (mutation_sequence >= 0),\n candidate_seal_identity TEXT CHECK (candidate_seal_identity IS NULL OR length(candidate_seal_identity) = 64),\n candidate_seal_entry_count INTEGER CHECK (candidate_seal_entry_count IS NULL OR candidate_seal_entry_count >= 0),\n candidate_seal_staged_count INTEGER NOT NULL DEFAULT 0 CHECK (candidate_seal_staged_count >= 0),\n logical_seal_identity TEXT,\n CHECK ((core_payload IS NULL) = (core_digest IS NULL)),\n CHECK ((candidate_seal_identity IS NULL) = (candidate_seal_entry_count IS NULL)),\n CHECK ((status = 'open') = (candidate_seal_identity IS NULL)),\n CHECK (candidate_seal_entry_count IS NULL OR candidate_seal_staged_count <= candidate_seal_entry_count),\n CHECK (status != 'open' OR candidate_seal_staged_count = 0),\n CHECK ((status = 'sealed') = (logical_seal_identity IS NOT NULL)),\n CHECK (status = 'open' OR core_payload IS NOT NULL)\n) STRICT;\nCREATE TABLE ne18_slots (\n run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,\n slot_id TEXT NOT NULL,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n core_payload BLOB NOT NULL,\n core_digest TEXT NOT NULL CHECK (length(core_digest) = 64),\n PRIMARY KEY (run_id, slot_id),\n UNIQUE (run_id, ordinal)\n) STRICT;\nCREATE TABLE ne18_attempts (\n origin_run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,\n attempt_id TEXT NOT NULL,\n attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),\n publication_state TEXT NOT NULL DEFAULT 'staging' CHECK (publication_state IN ('staging','sealing','published')),\n core_payload BLOB,\n core_digest TEXT CHECK (core_digest IS NULL OR length(core_digest) = 64),\n CHECK ((core_payload IS NULL) = (core_digest IS NULL)),\n PRIMARY KEY (origin_run_id, attempt_id)\n) STRICT;\nCREATE TABLE ne18_members (\n target_run_id TEXT NOT NULL,\n slot_id TEXT NOT NULL,\n origin_run_id TEXT,\n attempt_id TEXT,\n action TEXT NOT NULL CHECK (action IN ('executed','carried','accepted','not-dispatched','interrupted')),\n core_payload BLOB NOT NULL,\n core_digest TEXT NOT NULL CHECK (length(core_digest) = 64),\n PRIMARY KEY (target_run_id, slot_id),\n CHECK (\n (action IN ('executed','carried','accepted') AND origin_run_id IS NOT NULL AND attempt_id IS NOT NULL) OR\n (action IN ('not-dispatched','interrupted') AND origin_run_id IS NULL AND attempt_id IS NULL)\n ),\n FOREIGN KEY (target_run_id, slot_id) REFERENCES ne18_slots(run_id, slot_id) ON DELETE CASCADE\n) STRICT;\nCREATE TABLE ne18_attachments (\n attachment_id TEXT PRIMARY KEY,\n owner_kind TEXT NOT NULL CHECK (owner_kind IN ('run','attempt')),\n owner_run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,\n owner_attempt_id TEXT,\n family TEXT NOT NULL,\n family_revision INTEGER NOT NULL CHECK (family_revision > 0),\n logical_identity TEXT,\n canonical_payload BLOB,\n canonical_digest TEXT CHECK (canonical_digest IS NULL OR length(canonical_digest) = 64),\n logical_inventory BLOB,\n inventory_digest TEXT CHECK (inventory_digest IS NULL OR length(inventory_digest) = 64),\n CHECK ((canonical_payload IS NULL) = (canonical_digest IS NULL)),\n CHECK ((logical_inventory IS NULL) = (inventory_digest IS NULL)),\n CHECK ((owner_kind = 'run' AND owner_attempt_id IS NULL) OR (owner_kind = 'attempt' AND owner_attempt_id IS NOT NULL)),\n UNIQUE (owner_kind, owner_run_id, owner_attempt_id, family),\n FOREIGN KEY (owner_run_id, owner_attempt_id) REFERENCES ne18_attempts(origin_run_id, attempt_id) ON DELETE CASCADE\n) STRICT;\nCREATE TABLE ne18_attachment_references (\n attachment_id TEXT NOT NULL REFERENCES ne18_attachments(attachment_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n target_owner_kind TEXT NOT NULL CHECK (target_owner_kind IN ('run','attempt')),\n target_family TEXT NOT NULL,\n canonical_payload BLOB NOT NULL,\n reference_digest TEXT NOT NULL CHECK (length(reference_digest) = 64),\n PRIMARY KEY (attachment_id, ordinal)\n) STRICT;\nCREATE TABLE ne18_collection_items (\n attachment_id TEXT NOT NULL REFERENCES ne18_attachments(attachment_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n logical_identity TEXT NOT NULL,\n canonical_payload BLOB NOT NULL,\n canonical_digest TEXT NOT NULL CHECK (length(canonical_digest) = 64),\n PRIMARY KEY (attachment_id, ordinal),\n UNIQUE (attachment_id, logical_identity)\n) STRICT;\nCREATE TABLE ne18_contents (\n content_id TEXT PRIMARY KEY,\n attachment_id TEXT NOT NULL REFERENCES ne18_attachments(attachment_id) ON DELETE CASCADE,\n logical_handle TEXT NOT NULL,\n byte_length INTEGER CHECK (byte_length IS NULL OR byte_length >= 0),\n overall_digest TEXT CHECK (overall_digest IS NULL OR length(overall_digest) = 64),\n chunk_count INTEGER CHECK (chunk_count IS NULL OR chunk_count >= 0),\n CHECK ((byte_length IS NULL) = (overall_digest IS NULL) AND (overall_digest IS NULL) = (chunk_count IS NULL)),\n UNIQUE (attachment_id, logical_handle)\n) STRICT;\nCREATE TABLE ne18_content_chunks (\n content_id TEXT NOT NULL REFERENCES ne18_contents(content_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n bytes BLOB NOT NULL CHECK (length(bytes) <= 262144),\n chunk_digest TEXT NOT NULL CHECK (length(chunk_digest) = 64),\n PRIMARY KEY (content_id, ordinal)\n) STRICT;\nCREATE TABLE ne18_run_seal_entries (\n run_id TEXT NOT NULL REFERENCES ne18_runs(run_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n entry_kind TEXT NOT NULL CHECK (entry_kind IN ('record','run','slot','member','attempt','attachment','attachment-reference','collection-item','content','content-chunk')),\n logical_identity TEXT NOT NULL,\n digest TEXT NOT NULL CHECK (length(digest) = 64),\n PRIMARY KEY (run_id, ordinal),\n UNIQUE (run_id, entry_kind, logical_identity)\n) STRICT;\nCREATE INDEX ne18_attachments_owner_family ON ne18_attachments(owner_kind, owner_run_id, owner_attempt_id, family);\nCREATE UNIQUE INDEX ne18_attachments_owner_family_unique ON ne18_attachments(owner_kind, owner_run_id, coalesce(owner_attempt_id,''), family);\nCREATE INDEX ne18_members_origin_attempt ON ne18_members(origin_run_id, attempt_id, target_run_id);\nCREATE INDEX ne18_attempts_locator ON ne18_attempts(attempt_locator, origin_run_id, attempt_id);\nCREATE INDEX ne18_references_target_family ON ne18_attachment_references(target_owner_kind, target_family);\nCREATE INDEX ne18_content_chunks_page ON ne18_content_chunks(content_id, ordinal);\nCREATE INDEX ne18_coordination_tickets_fifo ON ne18_coordination_tickets(sequence);\nCREATE TRIGGER ne18_coordination_ticket_barrier_insert BEFORE INSERT ON ne18_coordination_tickets WHEN (SELECT barrier_state FROM ne18_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;\nCREATE TRIGGER ne18_coordination_writer_barrier_update BEFORE UPDATE ON ne18_coordination_state WHEN NEW.writer_ticket_id IS NOT NULL AND (SELECT barrier_state FROM ne18_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;\nCREATE TRIGGER ne18_runs_sealed_update BEFORE UPDATE ON ne18_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;\nCREATE TRIGGER ne18_runs_sealed_delete BEFORE DELETE ON ne18_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;\nCREATE TRIGGER ne18_slots_sealed_insert BEFORE INSERT ON ne18_slots WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_slots_sealed_update BEFORE UPDATE ON ne18_slots WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_slots_sealed_delete BEFORE DELETE ON ne18_slots WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_attempts_sealed_insert BEFORE INSERT ON ne18_attempts WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_attempts_sealed_update BEFORE UPDATE ON ne18_attempts WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_attempts_sealed_delete BEFORE DELETE ON ne18_attempts WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_members_sealed_insert BEFORE INSERT ON ne18_members WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_members_sealed_update BEFORE UPDATE ON ne18_members WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_members_sealed_delete BEFORE DELETE ON ne18_members WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_attachments_sealed_insert BEFORE INSERT ON ne18_attachments WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_attachments_attempt_published_insert BEFORE INSERT ON ne18_attachments WHEN NEW.owner_kind='attempt' AND (SELECT publication_state FROM ne18_attempts WHERE origin_run_id=NEW.owner_run_id AND attempt_id=NEW.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;\nCREATE TRIGGER ne18_attachments_sealed_update BEFORE UPDATE ON ne18_attachments WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_attachments_attempt_published_update BEFORE UPDATE ON ne18_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne18_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;\nCREATE TRIGGER ne18_attachments_sealed_delete BEFORE DELETE ON ne18_attachments WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_attachments_attempt_published_delete BEFORE DELETE ON ne18_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne18_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;\nCREATE TRIGGER ne18_references_sealed_insert BEFORE INSERT ON ne18_attachment_references WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_references_sealed_update BEFORE UPDATE ON ne18_attachment_references WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_references_sealed_delete BEFORE DELETE ON ne18_attachment_references WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_items_sealed_insert BEFORE INSERT ON ne18_collection_items WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_items_sealed_update BEFORE UPDATE ON ne18_collection_items WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_items_sealed_delete BEFORE DELETE ON ne18_collection_items WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_contents_sealed_insert BEFORE INSERT ON ne18_contents WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_contents_sealed_update BEFORE UPDATE ON ne18_contents WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_contents_sealed_delete BEFORE DELETE ON ne18_contents WHEN (SELECT r.status FROM ne18_attachments a JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_chunks_sealed_insert BEFORE INSERT ON ne18_content_chunks WHEN (SELECT r.status FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=NEW.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_chunks_sealed_update BEFORE UPDATE ON ne18_content_chunks WHEN (SELECT r.status FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_chunks_sealed_delete BEFORE DELETE ON ne18_content_chunks WHEN (SELECT r.status FROM ne18_contents c JOIN ne18_attachments a ON a.attachment_id=c.attachment_id JOIN ne18_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne18_seal_entries_sealed_insert BEFORE INSERT ON ne18_run_seal_entries WHEN (SELECT status FROM ne18_runs WHERE run_id = NEW.run_id) != 'sealing' BEGIN SELECT RAISE(ABORT, 'Seal candidates require sealing state'); END;\nCREATE TRIGGER ne18_seal_entries_sealed_update BEFORE UPDATE ON ne18_run_seal_entries BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;\nCREATE TRIGGER ne18_seal_entries_sealed_delete BEFORE DELETE ON ne18_run_seal_entries WHEN (SELECT status FROM ne18_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;\n\n\nCREATE TABLE ne18_run_publication_clock (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n revision INTEGER NOT NULL CHECK (revision >= 0)\n) STRICT;\nCREATE TABLE ne18_run_resources (\n run_id TEXT PRIMARY KEY,\n invocation_id TEXT NOT NULL,\n experiment_id TEXT NOT NULL,\n started_at TEXT NOT NULL,\n initial_writer_generation TEXT NOT NULL,\n current_writer_generation TEXT NOT NULL,\n terminal_state TEXT CHECK (terminal_state IS NULL OR terminal_state IN ('completed','interrupted','failed')),\n completed_at TEXT,\n created_revision INTEGER NOT NULL UNIQUE CHECK (created_revision > 0),\n close_revision INTEGER UNIQUE CHECK (close_revision IS NULL OR close_revision > created_revision),\n CHECK ((terminal_state IS NULL) = (completed_at IS NULL)),\n CHECK ((terminal_state IS NULL) = (close_revision IS NULL))\n) STRICT;\nCREATE TABLE ne18_run_expected_slots (\n run_id TEXT NOT NULL REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,\n slot_id TEXT NOT NULL,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n eval_id TEXT NOT NULL,\n attempt_ordinal INTEGER NOT NULL CHECK (attempt_ordinal >= 0),\n execution_identity_digest TEXT NOT NULL CHECK (length(execution_identity_digest) = 64),\n PRIMARY KEY (run_id, slot_id),\n UNIQUE (run_id, ordinal)\n) STRICT;\nCREATE TABLE ne18_attempt_publications (\n attempt_id TEXT PRIMARY KEY,\n attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),\n origin_run_id TEXT NOT NULL,\n origin_slot_id TEXT NOT NULL,\n closure_payload BLOB NOT NULL,\n closure_digest TEXT NOT NULL CHECK (length(closure_digest) = 64),\n published_revision INTEGER NOT NULL UNIQUE CHECK (published_revision > 0),\n FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne18_run_slot_bindings (\n target_run_id TEXT NOT NULL,\n slot_id TEXT NOT NULL,\n attempt_id TEXT NOT NULL REFERENCES ne18_attempt_publications(attempt_id) ON DELETE RESTRICT,\n origin_run_id TEXT NOT NULL,\n origin_slot_id TEXT NOT NULL,\n attempt_publication_revision INTEGER NOT NULL CHECK (attempt_publication_revision > 0),\n action TEXT NOT NULL CHECK (action IN ('executed','carried','accepted')),\n binding_revision INTEGER NOT NULL UNIQUE CHECK (binding_revision > 0),\n PRIMARY KEY (target_run_id, slot_id),\n FOREIGN KEY (target_run_id, slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT,\n FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne18_run_slot_absences (\n run_id TEXT NOT NULL,\n slot_id TEXT NOT NULL,\n reason TEXT NOT NULL CHECK (reason IN ('early-exit-satisfied','budget-exhausted','stopped-by-failure','interrupted-before-publication','dispatch-failed')),\n absence_revision INTEGER NOT NULL CHECK (absence_revision > 0),\n PRIMARY KEY (run_id, slot_id),\n FOREIGN KEY (run_id, slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne18_run_recoveries (\n run_id TEXT PRIMARY KEY REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,\n previous_writer_generation TEXT NOT NULL,\n recovery_writer_generation TEXT NOT NULL,\n evidence_kind TEXT NOT NULL,\n evidence_identity TEXT NOT NULL,\n evidence_observed_at TEXT NOT NULL,\n recovery_revision INTEGER NOT NULL UNIQUE CHECK (recovery_revision > 0)\n) STRICT;\nCREATE TABLE ne18_run_deletion_tombstones (\n run_id TEXT PRIMARY KEY REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,\n terminal_state TEXT NOT NULL CHECK (terminal_state IN ('completed','interrupted','failed')),\n deleted_at TEXT NOT NULL,\n deletion_revision INTEGER NOT NULL UNIQUE CHECK (deletion_revision > 0)\n) STRICT;\nCREATE INDEX ne18_run_resources_list ON ne18_run_resources(created_revision, run_id);\nCREATE INDEX ne18_run_resources_invocation ON ne18_run_resources(invocation_id, created_revision, run_id);\nCREATE INDEX ne18_attempt_publications_origin ON ne18_attempt_publications(origin_run_id, origin_slot_id);\nCREATE INDEX ne18_attempt_publications_locator ON ne18_attempt_publications(attempt_locator, origin_run_id, attempt_id);\nCREATE INDEX ne18_run_slot_bindings_attempt ON ne18_run_slot_bindings(attempt_id, target_run_id, slot_id);\nCREATE INDEX ne18_run_deletion_revision ON ne18_run_deletion_tombstones(deletion_revision, run_id);\nINSERT INTO ne18_run_publication_clock(singleton,revision) VALUES (1,0);\n\n\nCREATE TABLE ne18_invocation_sessions (\n invocation_id TEXT PRIMARY KEY,\n state TEXT NOT NULL CHECK (state IN ('active','recovering','completed','interrupted','failed')),\n owner_id TEXT NOT NULL,\n owner_generation INTEGER NOT NULL CHECK (owner_generation > 0),\n owner_host TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_boot_id TEXT NOT NULL,\n owner_process_start TEXT NOT NULL,\n started_at TEXT NOT NULL,\n heartbeat_at TEXT NOT NULL,\n active_projection BLOB,\n recovering_at TEXT,\n closed_at TEXT,\n terminal_projection BLOB,\n CHECK ((state IN ('completed','interrupted','failed')) = (closed_at IS NOT NULL)),\n CHECK ((state IN ('completed','interrupted','failed')) = (terminal_projection IS NOT NULL)),\n CHECK (state IN ('active','recovering') OR active_projection IS NULL),\n CHECK ((state = 'recovering') = (recovering_at IS NOT NULL))\n) STRICT;\nCREATE TABLE ne18_invocation_session_experiments (\n invocation_id TEXT NOT NULL REFERENCES ne18_invocation_sessions(invocation_id) ON DELETE RESTRICT,\n experiment_id TEXT NOT NULL,\n run_id TEXT NOT NULL UNIQUE REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n PRIMARY KEY (invocation_id, experiment_id),\n UNIQUE (invocation_id, ordinal)\n) STRICT;\nCREATE TABLE ne18_invocation_session_queued_attempts (\n invocation_id TEXT NOT NULL REFERENCES ne18_invocation_sessions(invocation_id) ON DELETE RESTRICT,\n attempt_id TEXT NOT NULL,\n run_id TEXT NOT NULL REFERENCES ne18_run_resources(run_id) ON DELETE RESTRICT,\n slot_id TEXT NOT NULL,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n PRIMARY KEY (invocation_id, attempt_id),\n UNIQUE (invocation_id, ordinal),\n FOREIGN KEY (run_id, slot_id) REFERENCES ne18_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne18_case_locks (\n case_id TEXT PRIMARY KEY,\n owner_id TEXT NOT NULL,\n owner_generation INTEGER NOT NULL CHECK (owner_generation > 0),\n owner_host TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_boot_id TEXT NOT NULL,\n owner_process_start TEXT NOT NULL,\n acquired_at TEXT NOT NULL,\n heartbeat_at TEXT NOT NULL\n) STRICT;\nCREATE INDEX ne18_invocation_sessions_state ON ne18_invocation_sessions(state, started_at, invocation_id);\nCREATE INDEX ne18_invocation_session_experiments_invocation ON ne18_invocation_session_experiments(invocation_id, ordinal);\nCREATE INDEX ne18_invocation_session_queued_attempts_run ON ne18_invocation_session_queued_attempts(run_id, slot_id);\nCREATE INDEX ne18_case_locks_owner ON ne18_case_locks(owner_id, owner_generation);\nCREATE TABLE ne18_teardown_obligations (\n obligation_id TEXT PRIMARY KEY,\n experiment_id TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_host TEXT NOT NULL,\n generation INTEGER NOT NULL DEFAULT 1 CHECK (generation > 0),\n payload BLOB NOT NULL,\n UNIQUE (experiment_id, owner_pid)\n) STRICT;\nCREATE TABLE ne18_shared_state_generations (\n state_key TEXT NOT NULL,\n generation INTEGER NOT NULL CHECK (generation > 0),\n parent_generation INTEGER NOT NULL CHECK (parent_generation >= 0),\n state_kind TEXT NOT NULL CHECK (state_kind IN ('active','recovering','free')),\n owner_token TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_host TEXT NOT NULL,\n owner_process_identity TEXT NOT NULL,\n heartbeat_at TEXT NOT NULL,\n payload BLOB NOT NULL,\n PRIMARY KEY (state_key, generation),\n CHECK (parent_generation = generation - 1)\n) STRICT;\nCREATE TABLE ne18_kept_sandboxes (\n entry_id TEXT PRIMARY KEY,\n provider TEXT NOT NULL,\n sandbox_id TEXT NOT NULL,\n kept_at TEXT NOT NULL,\n operation_generation INTEGER NOT NULL DEFAULT 0 CHECK (operation_generation >= 0),\n payload BLOB NOT NULL,\n UNIQUE (provider, sandbox_id)\n) STRICT;\nCREATE TABLE ne18_kept_sandbox_operation_leases (\n entry_id TEXT PRIMARY KEY REFERENCES ne18_kept_sandboxes(entry_id) ON DELETE CASCADE,\n generation INTEGER NOT NULL CHECK (generation > 0),\n token TEXT NOT NULL,\n holder TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_host TEXT NOT NULL,\n owner_process_identity TEXT NOT NULL,\n operation TEXT NOT NULL,\n acquired_at TEXT NOT NULL,\n ttl_ms INTEGER NOT NULL CHECK (ttl_ms > 0)\n) STRICT;\nCREATE INDEX ne18_teardown_obligations_experiment ON ne18_teardown_obligations(experiment_id, owner_pid);\nCREATE INDEX ne18_shared_state_generations_head ON ne18_shared_state_generations(state_key, generation DESC);\nCREATE INDEX ne18_kept_sandboxes_kept_at ON ne18_kept_sandboxes(kept_at, entry_id);\n\n\nCREATE TABLE ne18_migration_state (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n state TEXT NOT NULL CHECK (state IN ('committed','ready')),\n source_format TEXT,\n source_digest TEXT CHECK (source_digest IS NULL OR length(source_digest) = 64),\n CHECK ((source_format IS NULL) = (source_digest IS NULL)),\n CHECK (state != 'committed' OR source_format IS NOT NULL)\n) STRICT;`;\n"]}
1
+ {"version":3,"file":"current-schema.js","sourceRoot":"","sources":["current-schema.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,0BAA0B,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAqbhC,CAAC","sourcesContent":["/**\n * Exact current ProjectDatabase 0.19 schema, independent of frozen historical\n * baselines. Keep these bytes stable within this format: they own its fingerprint.\n * The disjoint namespace fences writers prepared against the 0.18 tables.\n */\nexport const RECORD_SQLITE_BASELINE_SQL = `\nCREATE TABLE ne19_record_metadata (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n format TEXT NOT NULL,\n storage_revision INTEGER NOT NULL CHECK (storage_revision > 0),\n storage_generation TEXT NOT NULL,\n schema_fingerprint TEXT NOT NULL CHECK (length(schema_fingerprint) = 64),\n created_at TEXT NOT NULL,\n barrier_state TEXT NOT NULL CHECK (barrier_state IN ('open','draining','portable')),\n portable_generation TEXT,\n portable_revision INTEGER CHECK (portable_revision IS NULL OR portable_revision >= 0),\n portable_gate_id TEXT,\n record_payload BLOB,\n record_digest TEXT,\n CHECK ((record_payload IS NULL) = (record_digest IS NULL)),\n CHECK (record_digest IS NULL OR length(record_digest) = 64),\n CHECK ((barrier_state = 'portable') = (portable_generation IS NOT NULL)),\n CHECK ((barrier_state = 'portable') = (portable_revision IS NOT NULL)),\n CHECK ((barrier_state = 'open') = (portable_gate_id IS NULL))\n) STRICT;\nCREATE TABLE ne19_coordination_state (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n revision INTEGER NOT NULL CHECK (revision >= 0),\n operational_generation TEXT NOT NULL,\n next_writer_sequence INTEGER NOT NULL CHECK (next_writer_sequence > 0),\n writer_ticket_id TEXT,\n writer_sequence INTEGER CHECK (writer_sequence IS NULL OR writer_sequence > 0),\n writer_host TEXT,\n writer_pid INTEGER CHECK (writer_pid IS NULL OR writer_pid > 0),\n writer_boot_id TEXT,\n writer_process_start TEXT,\n writer_deadline INTEGER CHECK (writer_deadline IS NULL OR writer_deadline > 0),\n writer_enqueued_at INTEGER CHECK (writer_enqueued_at IS NULL OR writer_enqueued_at > 0),\n writer_nonce TEXT,\n writer_admitted_at INTEGER CHECK (writer_admitted_at IS NULL OR writer_admitted_at > 0),\n writer_lease_expires_at INTEGER CHECK (writer_lease_expires_at IS NULL OR writer_lease_expires_at > 0),\n barrier_id TEXT,\n barrier_nonce TEXT,\n barrier_host TEXT,\n barrier_pid INTEGER CHECK (barrier_pid IS NULL OR barrier_pid > 0),\n barrier_boot_id TEXT,\n barrier_process_start TEXT,\n barrier_deadline INTEGER CHECK (barrier_deadline IS NULL OR barrier_deadline > 0),\n barrier_requested_at INTEGER CHECK (barrier_requested_at IS NULL OR barrier_requested_at > 0),\n barrier_lease_expires_at INTEGER CHECK (barrier_lease_expires_at IS NULL OR barrier_lease_expires_at > 0),\n barrier_status TEXT CHECK (barrier_status IS NULL OR barrier_status IN ('requested','active')),\n barrier_active_at INTEGER CHECK (barrier_active_at IS NULL OR barrier_active_at > 0),\n CHECK ((writer_ticket_id IS NULL) = (writer_sequence IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_host IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_pid IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_boot_id IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_process_start IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_deadline IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_enqueued_at IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_nonce IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_admitted_at IS NULL)),\n CHECK ((writer_ticket_id IS NULL) = (writer_lease_expires_at IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_nonce IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_host IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_pid IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_boot_id IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_process_start IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_deadline IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_requested_at IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_lease_expires_at IS NULL)),\n CHECK ((barrier_id IS NULL) = (barrier_status IS NULL)),\n CHECK (\n (barrier_status IS NULL AND barrier_active_at IS NULL) OR\n (barrier_status = 'requested' AND barrier_active_at IS NULL) OR\n (barrier_status = 'active' AND barrier_active_at IS NOT NULL)\n )\n) STRICT;\nCREATE TABLE ne19_coordination_tickets (\n ticket_id TEXT PRIMARY KEY,\n sequence INTEGER NOT NULL UNIQUE CHECK (sequence > 0),\n host TEXT NOT NULL,\n pid INTEGER NOT NULL CHECK (pid > 0),\n boot_id TEXT NOT NULL,\n process_start TEXT NOT NULL,\n deadline INTEGER NOT NULL CHECK (deadline > 0),\n enqueued_at INTEGER NOT NULL CHECK (enqueued_at > 0)\n) STRICT;\nCREATE TABLE ne19_runs (\n run_id TEXT PRIMARY KEY,\n experiment_id TEXT NOT NULL,\n status TEXT NOT NULL CHECK (status IN ('open','sealing','sealed')),\n writer_generation TEXT NOT NULL,\n started_at TEXT NOT NULL,\n core_payload BLOB,\n core_digest TEXT CHECK (core_digest IS NULL OR length(core_digest) = 64),\n mutation_sequence INTEGER NOT NULL DEFAULT 0 CHECK (mutation_sequence >= 0),\n candidate_seal_identity TEXT CHECK (candidate_seal_identity IS NULL OR length(candidate_seal_identity) = 64),\n candidate_seal_entry_count INTEGER CHECK (candidate_seal_entry_count IS NULL OR candidate_seal_entry_count >= 0),\n candidate_seal_staged_count INTEGER NOT NULL DEFAULT 0 CHECK (candidate_seal_staged_count >= 0),\n logical_seal_identity TEXT,\n CHECK ((core_payload IS NULL) = (core_digest IS NULL)),\n CHECK ((candidate_seal_identity IS NULL) = (candidate_seal_entry_count IS NULL)),\n CHECK ((status = 'open') = (candidate_seal_identity IS NULL)),\n CHECK (candidate_seal_entry_count IS NULL OR candidate_seal_staged_count <= candidate_seal_entry_count),\n CHECK (status != 'open' OR candidate_seal_staged_count = 0),\n CHECK ((status = 'sealed') = (logical_seal_identity IS NOT NULL)),\n CHECK (status = 'open' OR core_payload IS NOT NULL)\n) STRICT;\nCREATE TABLE ne19_slots (\n run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,\n slot_id TEXT NOT NULL,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n core_payload BLOB NOT NULL,\n core_digest TEXT NOT NULL CHECK (length(core_digest) = 64),\n PRIMARY KEY (run_id, slot_id),\n UNIQUE (run_id, ordinal)\n) STRICT;\nCREATE TABLE ne19_attempts (\n origin_run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,\n attempt_id TEXT NOT NULL,\n attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),\n publication_state TEXT NOT NULL DEFAULT 'staging' CHECK (publication_state IN ('staging','sealing','published')),\n core_payload BLOB,\n core_digest TEXT CHECK (core_digest IS NULL OR length(core_digest) = 64),\n CHECK ((core_payload IS NULL) = (core_digest IS NULL)),\n PRIMARY KEY (origin_run_id, attempt_id)\n) STRICT;\nCREATE TABLE ne19_members (\n target_run_id TEXT NOT NULL,\n slot_id TEXT NOT NULL,\n origin_run_id TEXT,\n attempt_id TEXT,\n action TEXT NOT NULL CHECK (action IN ('executed','carried','accepted','not-dispatched','interrupted')),\n core_payload BLOB NOT NULL,\n core_digest TEXT NOT NULL CHECK (length(core_digest) = 64),\n PRIMARY KEY (target_run_id, slot_id),\n CHECK (\n (action IN ('executed','carried','accepted') AND origin_run_id IS NOT NULL AND attempt_id IS NOT NULL) OR\n (action IN ('not-dispatched','interrupted') AND origin_run_id IS NULL AND attempt_id IS NULL)\n ),\n FOREIGN KEY (target_run_id, slot_id) REFERENCES ne19_slots(run_id, slot_id) ON DELETE CASCADE\n) STRICT;\nCREATE TABLE ne19_attachments (\n attachment_id TEXT PRIMARY KEY,\n owner_kind TEXT NOT NULL CHECK (owner_kind IN ('run','attempt')),\n owner_run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,\n owner_attempt_id TEXT,\n family TEXT NOT NULL,\n family_revision INTEGER NOT NULL CHECK (family_revision > 0),\n logical_identity TEXT,\n canonical_payload BLOB,\n canonical_digest TEXT CHECK (canonical_digest IS NULL OR length(canonical_digest) = 64),\n logical_inventory BLOB,\n inventory_digest TEXT CHECK (inventory_digest IS NULL OR length(inventory_digest) = 64),\n CHECK ((canonical_payload IS NULL) = (canonical_digest IS NULL)),\n CHECK ((logical_inventory IS NULL) = (inventory_digest IS NULL)),\n CHECK ((owner_kind = 'run' AND owner_attempt_id IS NULL) OR (owner_kind = 'attempt' AND owner_attempt_id IS NOT NULL)),\n UNIQUE (owner_kind, owner_run_id, owner_attempt_id, family),\n FOREIGN KEY (owner_run_id, owner_attempt_id) REFERENCES ne19_attempts(origin_run_id, attempt_id) ON DELETE CASCADE\n) STRICT;\nCREATE TABLE ne19_attachment_references (\n attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n target_owner_kind TEXT NOT NULL CHECK (target_owner_kind IN ('run','attempt')),\n target_family TEXT NOT NULL,\n canonical_payload BLOB NOT NULL,\n reference_digest TEXT NOT NULL CHECK (length(reference_digest) = 64),\n PRIMARY KEY (attachment_id, ordinal)\n) STRICT;\nCREATE TABLE ne19_collection_items (\n attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n logical_identity TEXT NOT NULL,\n canonical_payload BLOB NOT NULL,\n canonical_digest TEXT NOT NULL CHECK (length(canonical_digest) = 64),\n PRIMARY KEY (attachment_id, ordinal),\n UNIQUE (attachment_id, logical_identity)\n) STRICT;\nCREATE TABLE ne19_contents (\n content_id TEXT PRIMARY KEY,\n attachment_id TEXT NOT NULL REFERENCES ne19_attachments(attachment_id) ON DELETE CASCADE,\n logical_handle TEXT NOT NULL,\n byte_length INTEGER CHECK (byte_length IS NULL OR byte_length >= 0),\n overall_digest TEXT CHECK (overall_digest IS NULL OR length(overall_digest) = 64),\n chunk_count INTEGER CHECK (chunk_count IS NULL OR chunk_count >= 0),\n CHECK ((byte_length IS NULL) = (overall_digest IS NULL) AND (overall_digest IS NULL) = (chunk_count IS NULL)),\n UNIQUE (attachment_id, logical_handle)\n) STRICT;\nCREATE TABLE ne19_content_chunks (\n content_id TEXT NOT NULL REFERENCES ne19_contents(content_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n bytes BLOB NOT NULL CHECK (length(bytes) <= 262144),\n chunk_digest TEXT NOT NULL CHECK (length(chunk_digest) = 64),\n PRIMARY KEY (content_id, ordinal)\n) STRICT;\nCREATE TABLE ne19_run_seal_entries (\n run_id TEXT NOT NULL REFERENCES ne19_runs(run_id) ON DELETE CASCADE,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n entry_kind TEXT NOT NULL CHECK (entry_kind IN ('record','run','slot','member','attempt','attachment','attachment-reference','collection-item','content','content-chunk')),\n logical_identity TEXT NOT NULL,\n digest TEXT NOT NULL CHECK (length(digest) = 64),\n PRIMARY KEY (run_id, ordinal),\n UNIQUE (run_id, entry_kind, logical_identity)\n) STRICT;\nCREATE INDEX ne19_attachments_owner_family ON ne19_attachments(owner_kind, owner_run_id, owner_attempt_id, family);\nCREATE UNIQUE INDEX ne19_attachments_owner_family_unique ON ne19_attachments(owner_kind, owner_run_id, coalesce(owner_attempt_id,''), family);\nCREATE INDEX ne19_members_origin_attempt ON ne19_members(origin_run_id, attempt_id, target_run_id);\nCREATE INDEX ne19_attempts_locator ON ne19_attempts(attempt_locator, origin_run_id, attempt_id);\nCREATE INDEX ne19_references_target_family ON ne19_attachment_references(target_owner_kind, target_family);\nCREATE INDEX ne19_content_chunks_page ON ne19_content_chunks(content_id, ordinal);\nCREATE INDEX ne19_coordination_tickets_fifo ON ne19_coordination_tickets(sequence);\nCREATE TRIGGER ne19_coordination_ticket_barrier_insert BEFORE INSERT ON ne19_coordination_tickets WHEN (SELECT barrier_state FROM ne19_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;\nCREATE TRIGGER ne19_coordination_writer_barrier_update BEFORE UPDATE ON ne19_coordination_state WHEN NEW.writer_ticket_id IS NOT NULL AND (SELECT barrier_state FROM ne19_record_metadata WHERE singleton=1)!='open' BEGIN SELECT RAISE(ABORT, 'ProjectDatabase writer barrier is not open'); END;\nCREATE TRIGGER ne19_runs_sealed_update BEFORE UPDATE ON ne19_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;\nCREATE TRIGGER ne19_runs_sealed_delete BEFORE DELETE ON ne19_runs WHEN OLD.status = 'sealed' BEGIN SELECT RAISE(ABORT, 'sealed run is immutable'); END;\nCREATE TRIGGER ne19_slots_sealed_insert BEFORE INSERT ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_slots_sealed_update BEFORE UPDATE ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_slots_sealed_delete BEFORE DELETE ON ne19_slots WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_attempts_sealed_insert BEFORE INSERT ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_attempts_sealed_update BEFORE UPDATE ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_attempts_sealed_delete BEFORE DELETE ON ne19_attempts WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.origin_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_members_sealed_insert BEFORE INSERT ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_members_sealed_update BEFORE UPDATE ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_members_sealed_delete BEFORE DELETE ON ne19_members WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.target_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_attachments_sealed_insert BEFORE INSERT ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_attachments_attempt_published_insert BEFORE INSERT ON ne19_attachments WHEN NEW.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=NEW.owner_run_id AND attempt_id=NEW.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;\nCREATE TRIGGER ne19_attachments_sealed_update BEFORE UPDATE ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_attachments_attempt_published_update BEFORE UPDATE ON ne19_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;\nCREATE TRIGGER ne19_attachments_sealed_delete BEFORE DELETE ON ne19_attachments WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.owner_run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_attachments_attempt_published_delete BEFORE DELETE ON ne19_attachments WHEN OLD.owner_kind='attempt' AND (SELECT publication_state FROM ne19_attempts WHERE origin_run_id=OLD.owner_run_id AND attempt_id=OLD.owner_attempt_id)='published' BEGIN SELECT RAISE(ABORT, 'published attempt is immutable'); END;\nCREATE TRIGGER ne19_references_sealed_insert BEFORE INSERT ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_references_sealed_update BEFORE UPDATE ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_references_sealed_delete BEFORE DELETE ON ne19_attachment_references WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_items_sealed_insert BEFORE INSERT ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_items_sealed_update BEFORE UPDATE ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_items_sealed_delete BEFORE DELETE ON ne19_collection_items WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_contents_sealed_insert BEFORE INSERT ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=NEW.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_contents_sealed_update BEFORE UPDATE ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_contents_sealed_delete BEFORE DELETE ON ne19_contents WHEN (SELECT r.status FROM ne19_attachments a JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE a.attachment_id=OLD.attachment_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_chunks_sealed_insert BEFORE INSERT ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=NEW.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_chunks_sealed_update BEFORE UPDATE ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_chunks_sealed_delete BEFORE DELETE ON ne19_content_chunks WHEN (SELECT r.status FROM ne19_contents c JOIN ne19_attachments a ON a.attachment_id=c.attachment_id JOIN ne19_runs r ON r.run_id=a.owner_run_id WHERE c.content_id=OLD.content_id) != 'open' BEGIN SELECT RAISE(ABORT, 'run closure is immutable'); END;\nCREATE TRIGGER ne19_seal_entries_sealed_insert BEFORE INSERT ON ne19_run_seal_entries WHEN (SELECT status FROM ne19_runs WHERE run_id = NEW.run_id) != 'sealing' BEGIN SELECT RAISE(ABORT, 'Seal candidates require sealing state'); END;\nCREATE TRIGGER ne19_seal_entries_sealed_update BEFORE UPDATE ON ne19_run_seal_entries BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;\nCREATE TRIGGER ne19_seal_entries_sealed_delete BEFORE DELETE ON ne19_run_seal_entries WHEN (SELECT status FROM ne19_runs WHERE run_id = OLD.run_id) != 'open' BEGIN SELECT RAISE(ABORT, 'Seal entries are immutable'); END;\n\n\nCREATE TABLE ne19_run_publication_clock (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n revision INTEGER NOT NULL CHECK (revision >= 0)\n) STRICT;\nCREATE TABLE ne19_run_resources (\n run_id TEXT PRIMARY KEY,\n invocation_id TEXT NOT NULL,\n experiment_id TEXT NOT NULL,\n started_at TEXT NOT NULL,\n initial_writer_generation TEXT NOT NULL,\n current_writer_generation TEXT NOT NULL,\n terminal_state TEXT CHECK (terminal_state IS NULL OR terminal_state IN ('completed','interrupted','failed')),\n completed_at TEXT,\n created_revision INTEGER NOT NULL UNIQUE CHECK (created_revision > 0),\n close_revision INTEGER UNIQUE CHECK (close_revision IS NULL OR close_revision > created_revision),\n CHECK ((terminal_state IS NULL) = (completed_at IS NULL)),\n CHECK ((terminal_state IS NULL) = (close_revision IS NULL))\n) STRICT;\nCREATE TABLE ne19_run_expected_slots (\n run_id TEXT NOT NULL REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,\n slot_id TEXT NOT NULL,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n eval_id TEXT NOT NULL,\n attempt_ordinal INTEGER NOT NULL CHECK (attempt_ordinal >= 0),\n execution_identity_digest TEXT NOT NULL CHECK (length(execution_identity_digest) = 64),\n PRIMARY KEY (run_id, slot_id),\n UNIQUE (run_id, ordinal)\n) STRICT;\nCREATE TABLE ne19_attempt_publications (\n attempt_id TEXT PRIMARY KEY,\n attempt_locator TEXT NOT NULL CHECK (length(attempt_locator) = 14 AND substr(attempt_locator,1,2) = '@1'),\n origin_run_id TEXT NOT NULL,\n origin_slot_id TEXT NOT NULL,\n closure_payload BLOB NOT NULL,\n closure_digest TEXT NOT NULL CHECK (length(closure_digest) = 64),\n published_revision INTEGER NOT NULL UNIQUE CHECK (published_revision > 0),\n FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne19_run_slot_bindings (\n target_run_id TEXT NOT NULL,\n slot_id TEXT NOT NULL,\n attempt_id TEXT NOT NULL REFERENCES ne19_attempt_publications(attempt_id) ON DELETE RESTRICT,\n origin_run_id TEXT NOT NULL,\n origin_slot_id TEXT NOT NULL,\n attempt_publication_revision INTEGER NOT NULL CHECK (attempt_publication_revision > 0),\n action TEXT NOT NULL CHECK (action IN ('executed','carried','accepted')),\n binding_revision INTEGER NOT NULL UNIQUE CHECK (binding_revision > 0),\n PRIMARY KEY (target_run_id, slot_id),\n FOREIGN KEY (target_run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT,\n FOREIGN KEY (origin_run_id, origin_slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne19_run_slot_absences (\n run_id TEXT NOT NULL,\n slot_id TEXT NOT NULL,\n reason TEXT NOT NULL CHECK (reason IN ('early-exit-satisfied','budget-exhausted','stopped-by-failure','interrupted-before-publication','dispatch-failed')),\n absence_revision INTEGER NOT NULL CHECK (absence_revision > 0),\n PRIMARY KEY (run_id, slot_id),\n FOREIGN KEY (run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne19_run_recoveries (\n run_id TEXT PRIMARY KEY REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,\n previous_writer_generation TEXT NOT NULL,\n recovery_writer_generation TEXT NOT NULL,\n evidence_kind TEXT NOT NULL,\n evidence_identity TEXT NOT NULL,\n evidence_observed_at TEXT NOT NULL,\n recovery_revision INTEGER NOT NULL UNIQUE CHECK (recovery_revision > 0)\n) STRICT;\nCREATE TABLE ne19_run_deletion_tombstones (\n run_id TEXT PRIMARY KEY REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,\n terminal_state TEXT NOT NULL CHECK (terminal_state IN ('completed','interrupted','failed')),\n deleted_at TEXT NOT NULL,\n deletion_revision INTEGER NOT NULL UNIQUE CHECK (deletion_revision > 0)\n) STRICT;\nCREATE INDEX ne19_runs_experiment ON ne19_runs(experiment_id,run_id);\nCREATE INDEX ne19_run_resources_experiment ON ne19_run_resources(experiment_id,created_revision,run_id);\nCREATE INDEX ne19_run_expected_slots_position ON ne19_run_expected_slots(eval_id,attempt_ordinal,run_id);\nCREATE INDEX ne19_run_resources_list ON ne19_run_resources(created_revision, run_id);\nCREATE INDEX ne19_run_resources_invocation ON ne19_run_resources(invocation_id, created_revision, run_id);\nCREATE INDEX ne19_attempt_publications_origin ON ne19_attempt_publications(origin_run_id, origin_slot_id);\nCREATE INDEX ne19_attempt_publications_locator ON ne19_attempt_publications(attempt_locator, origin_run_id, attempt_id);\nCREATE INDEX ne19_run_slot_bindings_attempt ON ne19_run_slot_bindings(attempt_id, target_run_id, slot_id);\nCREATE INDEX ne19_run_deletion_revision ON ne19_run_deletion_tombstones(deletion_revision, run_id);\nINSERT INTO ne19_run_publication_clock(singleton,revision) VALUES (1,0);\n\n\nCREATE TABLE ne19_invocation_sessions (\n invocation_id TEXT PRIMARY KEY,\n state TEXT NOT NULL CHECK (state IN ('active','recovering','completed','interrupted','failed')),\n owner_id TEXT NOT NULL,\n owner_generation INTEGER NOT NULL CHECK (owner_generation > 0),\n owner_host TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_boot_id TEXT NOT NULL,\n owner_process_start TEXT NOT NULL,\n started_at TEXT NOT NULL,\n heartbeat_at TEXT NOT NULL,\n active_projection BLOB,\n recovering_at TEXT,\n closed_at TEXT,\n terminal_projection BLOB,\n CHECK ((state IN ('completed','interrupted','failed')) = (closed_at IS NOT NULL)),\n CHECK ((state IN ('completed','interrupted','failed')) = (terminal_projection IS NOT NULL)),\n CHECK (state IN ('active','recovering') OR active_projection IS NULL),\n CHECK ((state = 'recovering') = (recovering_at IS NOT NULL))\n) STRICT;\nCREATE TABLE ne19_invocation_session_experiments (\n invocation_id TEXT NOT NULL REFERENCES ne19_invocation_sessions(invocation_id) ON DELETE RESTRICT,\n experiment_id TEXT NOT NULL,\n run_id TEXT NOT NULL UNIQUE REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n PRIMARY KEY (invocation_id, experiment_id),\n UNIQUE (invocation_id, ordinal)\n) STRICT;\nCREATE TABLE ne19_invocation_session_queued_attempts (\n invocation_id TEXT NOT NULL REFERENCES ne19_invocation_sessions(invocation_id) ON DELETE RESTRICT,\n attempt_id TEXT NOT NULL,\n run_id TEXT NOT NULL REFERENCES ne19_run_resources(run_id) ON DELETE RESTRICT,\n slot_id TEXT NOT NULL,\n ordinal INTEGER NOT NULL CHECK (ordinal >= 0),\n PRIMARY KEY (invocation_id, attempt_id),\n UNIQUE (invocation_id, ordinal),\n FOREIGN KEY (run_id, slot_id) REFERENCES ne19_run_expected_slots(run_id, slot_id) ON DELETE RESTRICT\n) STRICT;\nCREATE TABLE ne19_case_locks (\n case_id TEXT PRIMARY KEY,\n owner_id TEXT NOT NULL,\n owner_generation INTEGER NOT NULL CHECK (owner_generation > 0),\n owner_host TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_boot_id TEXT NOT NULL,\n owner_process_start TEXT NOT NULL,\n acquired_at TEXT NOT NULL,\n heartbeat_at TEXT NOT NULL\n) STRICT;\nCREATE INDEX ne19_invocation_sessions_state ON ne19_invocation_sessions(state, started_at, invocation_id);\nCREATE INDEX ne19_invocation_session_experiments_invocation ON ne19_invocation_session_experiments(invocation_id, ordinal);\nCREATE INDEX ne19_invocation_session_queued_attempts_run ON ne19_invocation_session_queued_attempts(run_id, slot_id);\nCREATE INDEX ne19_case_locks_owner ON ne19_case_locks(owner_id, owner_generation);\nCREATE TABLE ne19_teardown_obligations (\n obligation_id TEXT PRIMARY KEY,\n experiment_id TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_host TEXT NOT NULL,\n generation INTEGER NOT NULL DEFAULT 1 CHECK (generation > 0),\n payload BLOB NOT NULL,\n UNIQUE (experiment_id, owner_pid)\n) STRICT;\nCREATE TABLE ne19_shared_state_generations (\n state_key TEXT NOT NULL,\n generation INTEGER NOT NULL CHECK (generation > 0),\n parent_generation INTEGER NOT NULL CHECK (parent_generation >= 0),\n state_kind TEXT NOT NULL CHECK (state_kind IN ('active','recovering','free')),\n owner_token TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_host TEXT NOT NULL,\n owner_process_identity TEXT NOT NULL,\n heartbeat_at TEXT NOT NULL,\n payload BLOB NOT NULL,\n PRIMARY KEY (state_key, generation),\n CHECK (parent_generation = generation - 1)\n) STRICT;\nCREATE TABLE ne19_kept_sandboxes (\n entry_id TEXT PRIMARY KEY,\n provider TEXT NOT NULL,\n sandbox_id TEXT NOT NULL,\n kept_at TEXT NOT NULL,\n operation_generation INTEGER NOT NULL DEFAULT 0 CHECK (operation_generation >= 0),\n payload BLOB NOT NULL,\n UNIQUE (provider, sandbox_id)\n) STRICT;\nCREATE TABLE ne19_kept_sandbox_operation_leases (\n entry_id TEXT PRIMARY KEY REFERENCES ne19_kept_sandboxes(entry_id) ON DELETE CASCADE,\n generation INTEGER NOT NULL CHECK (generation > 0),\n token TEXT NOT NULL,\n holder TEXT NOT NULL,\n owner_pid INTEGER NOT NULL CHECK (owner_pid > 0),\n owner_host TEXT NOT NULL,\n owner_process_identity TEXT NOT NULL,\n operation TEXT NOT NULL,\n acquired_at TEXT NOT NULL,\n ttl_ms INTEGER NOT NULL CHECK (ttl_ms > 0)\n) STRICT;\nCREATE INDEX ne19_teardown_obligations_experiment ON ne19_teardown_obligations(experiment_id, owner_pid);\nCREATE INDEX ne19_shared_state_generations_head ON ne19_shared_state_generations(state_key, generation DESC);\nCREATE INDEX ne19_kept_sandboxes_kept_at ON ne19_kept_sandboxes(kept_at, entry_id);\n\n\nCREATE TABLE ne19_migration_state (\n singleton INTEGER PRIMARY KEY CHECK (singleton = 1),\n state TEXT NOT NULL CHECK (state IN ('committed','ready')),\n source_format TEXT,\n source_digest TEXT CHECK (source_digest IS NULL OR length(source_digest) = 64),\n CHECK ((source_format IS NULL) = (source_digest IS NULL)),\n CHECK (state != 'committed' OR source_format IS NOT NULL)\n) STRICT;`;\n"]}