memoryking 0.1.0__py3-none-any.whl

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 (179) hide show
  1. memoryking/__init__.py +3 -0
  2. memoryking/__main__.py +1328 -0
  3. memoryking/adapters/__init__.py +1 -0
  4. memoryking/adapters/adapter_state.py +242 -0
  5. memoryking/adapters/anchor_schema.sql +7 -0
  6. memoryking/adapters/atlas.py +441 -0
  7. memoryking/adapters/browser_commands.py +125 -0
  8. memoryking/adapters/dashboard.py +510 -0
  9. memoryking/adapters/dense_search.py +86 -0
  10. memoryking/adapters/egress_policy.py +244 -0
  11. memoryking/adapters/egress_schema.sql +13 -0
  12. memoryking/adapters/embedding.schema.json +302 -0
  13. memoryking/adapters/embedding_store.py +469 -0
  14. memoryking/adapters/execution.py +369 -0
  15. memoryking/adapters/experience.py +423 -0
  16. memoryking/adapters/experience.schema.json +1508 -0
  17. memoryking/adapters/experience_records.py +239 -0
  18. memoryking/adapters/experience_schema.sql +23 -0
  19. memoryking/adapters/handoff.py +494 -0
  20. memoryking/adapters/handoff.schema.json +299 -0
  21. memoryking/adapters/handoff_schema.sql +17 -0
  22. memoryking/adapters/index_schema.sql +11 -0
  23. memoryking/adapters/inference.py +454 -0
  24. memoryking/adapters/inference.schema.json +541 -0
  25. memoryking/adapters/inspection.py +1128 -0
  26. memoryking/adapters/inspection.schema.json +568 -0
  27. memoryking/adapters/knowledge.schema.json +633 -0
  28. memoryking/adapters/knowledge_schema.sql +37 -0
  29. memoryking/adapters/knowledge_store.py +800 -0
  30. memoryking/adapters/legacy_snapshot.py +358 -0
  31. memoryking/adapters/legacy_tables.py +49 -0
  32. memoryking/adapters/local_contract.py +45 -0
  33. memoryking/adapters/local_embeddings.py +189 -0
  34. memoryking/adapters/local_files.py +242 -0
  35. memoryking/adapters/local_ipc.py +258 -0
  36. memoryking/adapters/local_schema.sql +44 -0
  37. memoryking/adapters/local_store.py +632 -0
  38. memoryking/adapters/local_wire.schema.json +7672 -0
  39. memoryking/adapters/models/minilm-l6-v2-onnx.json +57 -0
  40. memoryking/adapters/models/ms-marco-minilm-l6-v2-onnx.json +57 -0
  41. memoryking/adapters/optional_schema.sql +43 -0
  42. memoryking/adapters/plan_dashboard.py +51 -0
  43. memoryking/adapters/plans.py +253 -0
  44. memoryking/adapters/postgres_admin.py +300 -0
  45. memoryking/adapters/postgres_anchor_schema.sql +9 -0
  46. memoryking/adapters/postgres_counter.sql +14 -0
  47. memoryking/adapters/postgres_egress_schema.sql +15 -0
  48. memoryking/adapters/postgres_experience_schema.sql +39 -0
  49. memoryking/adapters/postgres_index_schema.sql +7 -0
  50. memoryking/adapters/postgres_optional_schema.sql +71 -0
  51. memoryking/adapters/postgres_pool.py +77 -0
  52. memoryking/adapters/postgres_recovery.py +525 -0
  53. memoryking/adapters/postgres_schema.sql +365 -0
  54. memoryking/adapters/postgres_sql.py +102 -0
  55. memoryking/adapters/postgres_store.py +428 -0
  56. memoryking/adapters/postgres_summary_schema.sql +12 -0
  57. memoryking/adapters/postgres_trust_schema.sql +20 -0
  58. memoryking/adapters/processing.schema.json +471 -0
  59. memoryking/adapters/processing_store.py +346 -0
  60. memoryking/adapters/projects.py +83 -0
  61. memoryking/adapters/proposals.py +238 -0
  62. memoryking/adapters/ranking.py +315 -0
  63. memoryking/adapters/repository.schema.json +664 -0
  64. memoryking/adapters/repository_git.py +264 -0
  65. memoryking/adapters/repository_schema.sql +25 -0
  66. memoryking/adapters/repository_store.py +960 -0
  67. memoryking/adapters/retrieval.py +1285 -0
  68. memoryking/adapters/retrieval.schema.json +553 -0
  69. memoryking/adapters/retrieval_schema.sql +10 -0
  70. memoryking/adapters/shared_control.py +40 -0
  71. memoryking/adapters/shared_dashboard.py +636 -0
  72. memoryking/adapters/shared_gateway.py +63 -0
  73. memoryking/adapters/shared_http.py +216 -0
  74. memoryking/adapters/shared_mcp.py +159 -0
  75. memoryking/adapters/shared_service.py +124 -0
  76. memoryking/adapters/stdio.py +193 -0
  77. memoryking/adapters/stdio.tools.json +6776 -0
  78. memoryking/adapters/summary_schema.sql +10 -0
  79. memoryking/adapters/team.py +253 -0
  80. memoryking/adapters/timeline.py +80 -0
  81. memoryking/adapters/token_count.py +55 -0
  82. memoryking/adapters/tokenizers/LICENSE +21 -0
  83. memoryking/adapters/tokenizers/cl100k_base.tiktoken +100256 -0
  84. memoryking/adapters/trust.py +123 -0
  85. memoryking/adapters/trust_schema.sql +13 -0
  86. memoryking/adapters/web/app.css +1251 -0
  87. memoryking/adapters/web/app.js +907 -0
  88. memoryking/adapters/web/brand.js +44 -0
  89. memoryking/adapters/web/crown-mono.svg +1 -0
  90. memoryking/adapters/web/crown.svg +8 -0
  91. memoryking/adapters/web/elephant.png +0 -0
  92. memoryking/adapters/web/favicon.svg +8 -0
  93. memoryking/adapters/web/graph-layout.js +52 -0
  94. memoryking/adapters/web/graph-worker.js +10 -0
  95. memoryking/adapters/web/graph.js +570 -0
  96. memoryking/adapters/web/index.html +208 -0
  97. memoryking/adapters/web/observatory.js +1208 -0
  98. memoryking/adapters/web/team.js +151 -0
  99. memoryking/adapters/web/wordmark.svg +1 -0
  100. memoryking/adapters/working.py +971 -0
  101. memoryking/adapters/working.schema.json +1717 -0
  102. memoryking/adapters/working_schema.sql +24 -0
  103. memoryking/application/__init__.py +1 -0
  104. memoryking/application/conformance.py +50 -0
  105. memoryking/application/legacy_import.py +337 -0
  106. memoryking/application/local_port.py +9 -0
  107. memoryking/application/storage.py +117 -0
  108. memoryking/application/store_core.py +1292 -0
  109. memoryking/backups.py +131 -0
  110. memoryking/contracts/__init__.py +6 -0
  111. memoryking/contracts/__main__.py +20 -0
  112. memoryking/contracts/canonical.py +88 -0
  113. memoryking/contracts/embedding.schema.json +302 -0
  114. memoryking/contracts/embedding_generated.py +65 -0
  115. memoryking/contracts/experience.schema.json +1508 -0
  116. memoryking/contracts/experience_generated.py +239 -0
  117. memoryking/contracts/generated.py +122 -0
  118. memoryking/contracts/handoff.schema.json +299 -0
  119. memoryking/contracts/handoff_generated.py +69 -0
  120. memoryking/contracts/inference.schema.json +541 -0
  121. memoryking/contracts/inference_generated.py +106 -0
  122. memoryking/contracts/processing.schema.json +471 -0
  123. memoryking/contracts/processing_generated.py +82 -0
  124. memoryking/contracts/py.typed +0 -0
  125. memoryking/contracts/repository.schema.json +664 -0
  126. memoryking/contracts/repository_generated.py +144 -0
  127. memoryking/contracts/retrieval.schema.json +553 -0
  128. memoryking/contracts/retrieval_generated.py +110 -0
  129. memoryking/contracts/schema.json +696 -0
  130. memoryking/contracts/validation.py +92 -0
  131. memoryking/contracts/working.schema.json +1717 -0
  132. memoryking/contracts/working_generated.py +291 -0
  133. memoryking/domain/__init__.py +1 -0
  134. memoryking/domain/anchors.py +97 -0
  135. memoryking/domain/briefing.py +108 -0
  136. memoryking/domain/briefing_text.py +222 -0
  137. memoryking/domain/checkpoint.py +118 -0
  138. memoryking/domain/compression.py +64 -0
  139. memoryking/domain/delta.py +129 -0
  140. memoryking/domain/embeddings.py +90 -0
  141. memoryking/domain/hints.py +465 -0
  142. memoryking/domain/http_status.py +45 -0
  143. memoryking/domain/learning.py +62 -0
  144. memoryking/domain/local.py +65 -0
  145. memoryking/domain/plans.py +140 -0
  146. memoryking/domain/repository.py +118 -0
  147. memoryking/domain/selectors.py +356 -0
  148. memoryking/domain/summary.py +88 -0
  149. memoryking/domain/usage.py +163 -0
  150. memoryking/embedding_loop.py +98 -0
  151. memoryking/embedding_worker.py +131 -0
  152. memoryking/harness.py +882 -0
  153. memoryking/harness_context.py +376 -0
  154. memoryking/hooks.py +171 -0
  155. memoryking/host_hooks.py +454 -0
  156. memoryking/lean.py +352 -0
  157. memoryking/memory_tool.py +776 -0
  158. memoryking/migration.py +194 -0
  159. memoryking/model_install.py +78 -0
  160. memoryking/observability.py +101 -0
  161. memoryking/observability_metrics.py +100 -0
  162. memoryking/profiles.py +150 -0
  163. memoryking/providers.py +330 -0
  164. memoryking/py.typed +0 -0
  165. memoryking/pytest_plugin.py +69 -0
  166. memoryking/reference_agent.py +152 -0
  167. memoryking/repository_worker.py +57 -0
  168. memoryking/resume_adapter.py +154 -0
  169. memoryking/sdk.py +302 -0
  170. memoryking/shared.py +301 -0
  171. memoryking/shared_sdk.py +101 -0
  172. memoryking/vault.py +176 -0
  173. memoryking-0.1.0.dist-info/METADATA +157 -0
  174. memoryking-0.1.0.dist-info/RECORD +179 -0
  175. memoryking-0.1.0.dist-info/WHEEL +5 -0
  176. memoryking-0.1.0.dist-info/entry_points.txt +7 -0
  177. memoryking-0.1.0.dist-info/licenses/LICENSE +202 -0
  178. memoryking-0.1.0.dist-info/licenses/NOTICE +12 -0
  179. memoryking-0.1.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,633 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "title": "Knowledge command v1",
4
+ "oneOf": [
5
+ {
6
+ "type": "object",
7
+ "additionalProperties": false,
8
+ "properties": {
9
+ "version": {
10
+ "const": 1
11
+ },
12
+ "incarnation": {
13
+ "type": "string",
14
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
15
+ },
16
+ "action": {
17
+ "const": "propose"
18
+ },
19
+ "args": {
20
+ "type": "object",
21
+ "additionalProperties": false,
22
+ "properties": {
23
+ "project": {
24
+ "type": "string",
25
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
26
+ },
27
+ "logical_key": {
28
+ "type": "string",
29
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
30
+ },
31
+ "expected_version": {
32
+ "type": "integer",
33
+ "minimum": 0,
34
+ "maximum": 9007199254740991
35
+ },
36
+ "body": {
37
+ "type": "object",
38
+ "additionalProperties": false,
39
+ "properties": {
40
+ "text": {
41
+ "type": "string",
42
+ "minLength": 1,
43
+ "maxLength": 8192
44
+ },
45
+ "kind": {
46
+ "enum": [
47
+ "knowledge",
48
+ "constraint"
49
+ ]
50
+ },
51
+ "selector": {
52
+ "type": "object"
53
+ },
54
+ "valid_start": {
55
+ "anyOf": [
56
+ {
57
+ "type": "integer",
58
+ "minimum": 0,
59
+ "maximum": 9007199254740991
60
+ },
61
+ {
62
+ "type": "null"
63
+ }
64
+ ]
65
+ },
66
+ "valid_end": {
67
+ "anyOf": [
68
+ {
69
+ "type": "integer",
70
+ "minimum": 0,
71
+ "maximum": 9007199254740991
72
+ },
73
+ {
74
+ "type": "null"
75
+ }
76
+ ]
77
+ },
78
+ "task": {
79
+ "anyOf": [
80
+ {
81
+ "type": "string",
82
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
83
+ },
84
+ {
85
+ "type": "null"
86
+ }
87
+ ]
88
+ },
89
+ "run": {
90
+ "anyOf": [
91
+ {
92
+ "type": "string",
93
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
94
+ },
95
+ {
96
+ "type": "null"
97
+ }
98
+ ]
99
+ },
100
+ "readers": {
101
+ "anyOf": [
102
+ {
103
+ "type": "null"
104
+ },
105
+ {
106
+ "type": "array",
107
+ "minItems": 1,
108
+ "maxItems": 64,
109
+ "uniqueItems": true,
110
+ "items": {
111
+ "type": "string",
112
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
113
+ }
114
+ }
115
+ ]
116
+ },
117
+ "evidence": {
118
+ "type": "array",
119
+ "minItems": 1,
120
+ "maxItems": 16,
121
+ "uniqueItems": true,
122
+ "items": {
123
+ "type": "object",
124
+ "additionalProperties": false,
125
+ "properties": {
126
+ "observation": {
127
+ "type": "string",
128
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
129
+ },
130
+ "start_byte": {
131
+ "type": "integer",
132
+ "minimum": 0,
133
+ "maximum": 9007199254740991
134
+ },
135
+ "end_byte": {
136
+ "type": "integer",
137
+ "minimum": 0,
138
+ "maximum": 9007199254740991
139
+ },
140
+ "content_hash": {
141
+ "type": "string",
142
+ "pattern": "^[a-f0-9]{64}(?![\\s\\S])"
143
+ }
144
+ },
145
+ "required": [
146
+ "observation",
147
+ "start_byte",
148
+ "end_byte",
149
+ "content_hash"
150
+ ]
151
+ }
152
+ },
153
+ "authority": {
154
+ "enum": [
155
+ null,
156
+ "project",
157
+ "task"
158
+ ]
159
+ },
160
+ "rule_key": {
161
+ "anyOf": [
162
+ {
163
+ "type": "string",
164
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
165
+ },
166
+ {
167
+ "type": "null"
168
+ }
169
+ ]
170
+ },
171
+ "effect": {
172
+ "enum": [
173
+ null,
174
+ "require",
175
+ "prohibit"
176
+ ]
177
+ },
178
+ "rule_value": {
179
+ "anyOf": [
180
+ {
181
+ "type": "string",
182
+ "minLength": 1,
183
+ "maxLength": 256
184
+ },
185
+ {
186
+ "type": "null"
187
+ }
188
+ ]
189
+ },
190
+ "provenance": {
191
+ "type": "object",
192
+ "maxProperties": 16
193
+ }
194
+ },
195
+ "required": [
196
+ "text",
197
+ "kind",
198
+ "selector",
199
+ "valid_start",
200
+ "valid_end",
201
+ "task",
202
+ "run",
203
+ "readers",
204
+ "evidence",
205
+ "authority",
206
+ "rule_key",
207
+ "effect",
208
+ "rule_value",
209
+ "provenance"
210
+ ]
211
+ },
212
+ "preserve_legacy": {
213
+ "type": "boolean"
214
+ }
215
+ },
216
+ "required": [
217
+ "project",
218
+ "logical_key",
219
+ "expected_version",
220
+ "body"
221
+ ]
222
+ },
223
+ "key": {
224
+ "type": "string",
225
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
226
+ }
227
+ },
228
+ "required": [
229
+ "version",
230
+ "incarnation",
231
+ "action",
232
+ "args",
233
+ "key"
234
+ ]
235
+ },
236
+ {
237
+ "type": "object",
238
+ "additionalProperties": false,
239
+ "properties": {
240
+ "version": {
241
+ "const": 1
242
+ },
243
+ "incarnation": {
244
+ "type": "string",
245
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
246
+ },
247
+ "action": {
248
+ "const": "review"
249
+ },
250
+ "args": {
251
+ "type": "object",
252
+ "additionalProperties": false,
253
+ "properties": {
254
+ "project": {
255
+ "type": "string",
256
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
257
+ },
258
+ "revision": {
259
+ "type": "string",
260
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
261
+ },
262
+ "expected_version": {
263
+ "type": "integer",
264
+ "minimum": 0,
265
+ "maximum": 9007199254740991
266
+ },
267
+ "decision": {
268
+ "enum": [
269
+ "accept",
270
+ "reject",
271
+ "deprecate",
272
+ "quarantine",
273
+ "release_quarantine"
274
+ ]
275
+ },
276
+ "reason": {
277
+ "type": "string",
278
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
279
+ },
280
+ "breadth_reviewed": {
281
+ "type": "boolean"
282
+ },
283
+ "replacement": {
284
+ "type": "object",
285
+ "additionalProperties": false,
286
+ "properties": {
287
+ "predecessor": {
288
+ "type": "string",
289
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
290
+ },
291
+ "selector": {
292
+ "type": "object"
293
+ },
294
+ "valid_start": {
295
+ "anyOf": [
296
+ {
297
+ "type": "integer",
298
+ "minimum": 0,
299
+ "maximum": 9007199254740991
300
+ },
301
+ {
302
+ "type": "null"
303
+ }
304
+ ]
305
+ },
306
+ "valid_end": {
307
+ "anyOf": [
308
+ {
309
+ "type": "integer",
310
+ "minimum": 0,
311
+ "maximum": 9007199254740991
312
+ },
313
+ {
314
+ "type": "null"
315
+ }
316
+ ]
317
+ }
318
+ },
319
+ "required": [
320
+ "predecessor",
321
+ "selector",
322
+ "valid_start",
323
+ "valid_end"
324
+ ]
325
+ }
326
+ },
327
+ "required": [
328
+ "project",
329
+ "revision",
330
+ "expected_version",
331
+ "decision",
332
+ "reason",
333
+ "breadth_reviewed"
334
+ ]
335
+ },
336
+ "key": {
337
+ "type": "string",
338
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
339
+ }
340
+ },
341
+ "required": [
342
+ "version",
343
+ "incarnation",
344
+ "action",
345
+ "args",
346
+ "key"
347
+ ]
348
+ },
349
+ {
350
+ "type": "object",
351
+ "additionalProperties": false,
352
+ "properties": {
353
+ "version": {
354
+ "const": 1
355
+ },
356
+ "incarnation": {
357
+ "type": "string",
358
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
359
+ },
360
+ "action": {
361
+ "const": "query"
362
+ },
363
+ "args": {
364
+ "type": "object",
365
+ "additionalProperties": false,
366
+ "properties": {
367
+ "project": {
368
+ "type": "string",
369
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
370
+ },
371
+ "bindings": {
372
+ "type": "array",
373
+ "minItems": 1,
374
+ "maxItems": 256,
375
+ "items": {
376
+ "type": "object"
377
+ }
378
+ },
379
+ "valid_ms": {
380
+ "type": "integer",
381
+ "minimum": 0,
382
+ "maximum": 9007199254740991
383
+ },
384
+ "recorded_position": {
385
+ "type": "integer",
386
+ "minimum": 0,
387
+ "maximum": 9007199254740991
388
+ },
389
+ "task": {
390
+ "type": "string",
391
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
392
+ },
393
+ "run": {
394
+ "type": "string",
395
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
396
+ },
397
+ "diagnostic": {
398
+ "type": "boolean"
399
+ }
400
+ },
401
+ "required": [
402
+ "project",
403
+ "bindings"
404
+ ]
405
+ },
406
+ "key": {
407
+ "type": "string",
408
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
409
+ }
410
+ },
411
+ "required": [
412
+ "version",
413
+ "incarnation",
414
+ "action",
415
+ "args"
416
+ ]
417
+ },
418
+ {
419
+ "type": "object",
420
+ "additionalProperties": false,
421
+ "properties": {
422
+ "version": {
423
+ "const": 1
424
+ },
425
+ "incarnation": {
426
+ "type": "string",
427
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
428
+ },
429
+ "action": {
430
+ "const": "constraints"
431
+ },
432
+ "args": {
433
+ "type": "object",
434
+ "additionalProperties": false,
435
+ "properties": {
436
+ "project": {
437
+ "type": "string",
438
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
439
+ },
440
+ "bindings": {
441
+ "type": "array",
442
+ "minItems": 1,
443
+ "maxItems": 256,
444
+ "items": {
445
+ "type": "object"
446
+ }
447
+ },
448
+ "task": {
449
+ "type": "string",
450
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
451
+ },
452
+ "run": {
453
+ "type": "string",
454
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
455
+ }
456
+ },
457
+ "required": [
458
+ "project",
459
+ "bindings"
460
+ ]
461
+ },
462
+ "key": {
463
+ "type": "string",
464
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
465
+ }
466
+ },
467
+ "required": [
468
+ "version",
469
+ "incarnation",
470
+ "action",
471
+ "args"
472
+ ]
473
+ },
474
+ {
475
+ "type": "object",
476
+ "additionalProperties": false,
477
+ "properties": {
478
+ "version": {
479
+ "const": 1
480
+ },
481
+ "incarnation": {
482
+ "type": "string",
483
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
484
+ },
485
+ "action": {
486
+ "const": "attest"
487
+ },
488
+ "args": {
489
+ "type": "object",
490
+ "additionalProperties": false,
491
+ "properties": {
492
+ "project": {
493
+ "type": "string",
494
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
495
+ },
496
+ "revision": {
497
+ "type": "string",
498
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
499
+ },
500
+ "expires_ms": {
501
+ "type": "integer",
502
+ "minimum": 0,
503
+ "maximum": 9007199254740991
504
+ },
505
+ "statement": {
506
+ "type": "string",
507
+ "minLength": 1,
508
+ "maxLength": 2048
509
+ }
510
+ },
511
+ "required": [
512
+ "project",
513
+ "revision",
514
+ "expires_ms",
515
+ "statement"
516
+ ]
517
+ },
518
+ "key": {
519
+ "type": "string",
520
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
521
+ }
522
+ },
523
+ "required": [
524
+ "version",
525
+ "incarnation",
526
+ "action",
527
+ "args",
528
+ "key"
529
+ ]
530
+ },
531
+ {
532
+ "type": "object",
533
+ "additionalProperties": false,
534
+ "properties": {
535
+ "version": {
536
+ "const": 1
537
+ },
538
+ "incarnation": {
539
+ "type": "string",
540
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
541
+ },
542
+ "action": {
543
+ "const": "promote"
544
+ },
545
+ "args": {
546
+ "type": "object",
547
+ "additionalProperties": false,
548
+ "properties": {
549
+ "project": {
550
+ "type": "string",
551
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
552
+ },
553
+ "revision": {
554
+ "type": "string",
555
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
556
+ },
557
+ "logical_key": {
558
+ "type": "string",
559
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
560
+ },
561
+ "expected_version": {
562
+ "type": "integer",
563
+ "minimum": 0,
564
+ "maximum": 9007199254740991
565
+ }
566
+ },
567
+ "required": [
568
+ "project",
569
+ "revision",
570
+ "logical_key",
571
+ "expected_version"
572
+ ]
573
+ },
574
+ "key": {
575
+ "type": "string",
576
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
577
+ }
578
+ },
579
+ "required": [
580
+ "version",
581
+ "incarnation",
582
+ "action",
583
+ "args",
584
+ "key"
585
+ ]
586
+ },
587
+ {
588
+ "type": "object",
589
+ "additionalProperties": false,
590
+ "properties": {
591
+ "version": {
592
+ "const": 1
593
+ },
594
+ "incarnation": {
595
+ "type": "string",
596
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
597
+ },
598
+ "action": {
599
+ "const": "draft"
600
+ },
601
+ "args": {
602
+ "type": "object",
603
+ "additionalProperties": false,
604
+ "properties": {
605
+ "project": {
606
+ "type": "string",
607
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
608
+ },
609
+ "limit": {
610
+ "type": "integer",
611
+ "minimum": 1,
612
+ "maximum": 64
613
+ }
614
+ },
615
+ "required": [
616
+ "project"
617
+ ]
618
+ },
619
+ "key": {
620
+ "type": "string",
621
+ "pattern": "^[A-Za-z0-9_-]{1,96}(?![\\s\\S])"
622
+ }
623
+ },
624
+ "required": [
625
+ "version",
626
+ "incarnation",
627
+ "action",
628
+ "args",
629
+ "key"
630
+ ]
631
+ }
632
+ ]
633
+ }
@@ -0,0 +1,37 @@
1
+ BEGIN IMMEDIATE;
2
+ CREATE TABLE knowledge_state (tenant TEXT PRIMARY KEY REFERENCES tenants,
3
+ generation INTEGER NOT NULL DEFAULT 0, recovery_gap INTEGER NOT NULL DEFAULT 0);
4
+ INSERT INTO knowledge_state(tenant) SELECT tenant FROM tenants;
5
+ CREATE TABLE families (tenant TEXT NOT NULL REFERENCES tenants, id TEXT NOT NULL,
6
+ project TEXT NOT NULL, logical_key TEXT NOT NULL, version INTEGER NOT NULL DEFAULT 0,
7
+ PRIMARY KEY(tenant,id), UNIQUE(tenant,project,logical_key));
8
+ CREATE TABLE revisions (tenant TEXT NOT NULL, id TEXT NOT NULL, family TEXT NOT NULL,
9
+ body TEXT, body_hash TEXT NOT NULL, kind TEXT NOT NULL, issuer TEXT NOT NULL,
10
+ created INTEGER NOT NULL, origin TEXT NOT NULL, purged INTEGER NOT NULL DEFAULT 0,
11
+ PRIMARY KEY(tenant,id), FOREIGN KEY(tenant,family) REFERENCES families(tenant,id),
12
+ FOREIGN KEY(tenant,created) REFERENCES events(tenant,position));
13
+ CREATE TABLE evidence_spans (tenant TEXT NOT NULL, revision TEXT NOT NULL,
14
+ observation TEXT NOT NULL, start_byte INTEGER NOT NULL, end_byte INTEGER NOT NULL,
15
+ content_hash TEXT NOT NULL, PRIMARY KEY(tenant,revision,observation,start_byte,end_byte),
16
+ FOREIGN KEY(tenant,revision) REFERENCES revisions(tenant,id),
17
+ FOREIGN KEY(tenant,observation) REFERENCES observations(tenant,id));
18
+ CREATE TABLE lifecycle (tenant TEXT NOT NULL, revision TEXT NOT NULL, position INTEGER NOT NULL,
19
+ action TEXT NOT NULL, detail TEXT NOT NULL, PRIMARY KEY(tenant,position),
20
+ FOREIGN KEY(tenant,revision) REFERENCES revisions(tenant,id),
21
+ FOREIGN KEY(tenant,position) REFERENCES events(tenant,position));
22
+ CREATE TABLE replacements (tenant TEXT NOT NULL, predecessor TEXT NOT NULL, successor TEXT NOT NULL,
23
+ position INTEGER NOT NULL, selector TEXT NOT NULL, valid_start INTEGER, valid_end INTEGER,
24
+ PRIMARY KEY(tenant,predecessor,successor,position),
25
+ FOREIGN KEY(tenant,predecessor) REFERENCES revisions(tenant,id),
26
+ FOREIGN KEY(tenant,successor) REFERENCES revisions(tenant,id),
27
+ FOREIGN KEY(tenant,position) REFERENCES events(tenant,position));
28
+ CREATE TABLE conflicts (tenant TEXT NOT NULL, left_revision TEXT NOT NULL,
29
+ right_revision TEXT NOT NULL, position INTEGER NOT NULL,
30
+ PRIMARY KEY(tenant,left_revision,right_revision),
31
+ FOREIGN KEY(tenant,left_revision) REFERENCES revisions(tenant,id),
32
+ FOREIGN KEY(tenant,right_revision) REFERENCES revisions(tenant,id));
33
+ CREATE TABLE attestations (tenant TEXT NOT NULL, id TEXT NOT NULL, revision TEXT NOT NULL,
34
+ actor TEXT NOT NULL, position INTEGER NOT NULL, expires INTEGER NOT NULL, statement TEXT,
35
+ PRIMARY KEY(tenant,id), FOREIGN KEY(tenant,revision) REFERENCES revisions(tenant,id));
36
+ PRAGMA user_version=2;
37
+ COMMIT;