@usherlabs/cex-broker 0.2.49 → 0.2.51

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 (55) hide show
  1. package/dist/commands/cex-canonical-orderbook-export.js +7747 -883
  2. package/dist/commands/cex-canonical-orderbook-export.js.map +41 -10
  3. package/dist/commands/cli.js +127 -34
  4. package/dist/commands/market-data-vendor-backfill.js +8284 -6391
  5. package/dist/commands/market-data-vendor-backfill.js.map +16 -15
  6. package/dist/helpers/canonical-orderbook-export/parquet-projection.d.ts +19 -0
  7. package/dist/helpers/market-data-archive/canonical-orderbook.d.ts +1 -1
  8. package/dist/helpers/market-data-preparation/conformance-fixtures.d.ts +114 -2
  9. package/dist/helpers/market-data-preparation/contracts.d.ts +1298 -18
  10. package/dist/helpers/market-data-preparation/required-clock-qualification.d.ts +43 -0
  11. package/dist/helpers/market-data-preparation/source-tape-dependencies.d.ts +19 -0
  12. package/dist/helpers/market-data-preparation/source-tape-operation.d.ts +109 -0
  13. package/dist/helpers/market-data-source-forensics.d.ts +400 -0
  14. package/dist/helpers/market-data-vendor-backfill/conformance-fixtures.d.ts +3 -5
  15. package/dist/helpers/market-data-vendor-backfill/contracts.d.ts +21 -56
  16. package/dist/helpers/market-data-vendor-backfill/core.d.ts +1 -0
  17. package/dist/helpers/market-data-vendor-backfill/cryptohftdata.d.ts +45 -5
  18. package/dist/helpers/market-data-vendor-backfill/manifests.d.ts +31 -1083
  19. package/dist/helpers/market-data-vendor-backfill/promotion.d.ts +1 -0
  20. package/dist/helpers/source-tape-sandbox.d.ts +82 -0
  21. package/dist/helpers/source-tape.d.ts +165 -0
  22. package/dist/helpers/trace-context.d.ts +8 -0
  23. package/dist/index.js +128 -35
  24. package/dist/index.js.map +7 -6
  25. package/dist/market-data-preparation/fixtures/{conformance-v2.json → conformance-v3.json} +257 -60
  26. package/dist/market-data-preparation/policies/capability-policy.json +15 -4
  27. package/dist/market-data-preparation/policies/resource-policy.json +3 -3
  28. package/dist/market-data-preparation/policies/source-tape-capability-v1.json +35 -0
  29. package/dist/market-data-preparation/schema-manifest.json +30 -10
  30. package/dist/market-data-preparation/schemas/canonical-orderbook-export-request-v1.schema.json +5 -1
  31. package/dist/market-data-preparation/schemas/{canonical-orderbook-export-result-v1.schema.json → canonical-orderbook-export-result-v2.schema.json} +20 -6
  32. package/dist/market-data-preparation/schemas/order-book-depth-summary-parquet-projection-v1.schema.json +256 -0
  33. package/dist/market-data-preparation/schemas/order-book-levels-parquet-projection-v1.schema.json +220 -0
  34. package/dist/market-data-preparation/schemas/{preparation-product-pin-v1.schema.json → preparation-product-pin-v2.schema.json} +59 -9
  35. package/dist/market-data-preparation/schemas/promotion-receipt-v1.schema.json +5 -1
  36. package/dist/market-data-preparation/schemas/source-forensics-ledger-v1.schema.json +463 -0
  37. package/dist/market-data-preparation/schemas/source-qualification-record-v1.schema.json +394 -0
  38. package/dist/market-data-preparation.d.ts +7 -0
  39. package/dist/market-data-preparation.js +35443 -25203
  40. package/dist/market-data-preparation.js.map +118 -78
  41. package/dist/market-data-vendor-backfill.d.ts +8 -5
  42. package/dist/market-data-vendor-backfill.js +19444 -15553
  43. package/dist/market-data-vendor-backfill.js.map +65 -60
  44. package/package.json +1 -5
  45. package/dist/market-data-preparation/policies/capability-policy-v1.json +0 -28
  46. package/dist/market-data-vendor-backfill/fixtures/conformance-v1.json +0 -448
  47. package/dist/market-data-vendor-backfill/policies/capability-policy-v2.json +0 -28
  48. package/dist/market-data-vendor-backfill/policies/capability-policy.json +0 -28
  49. package/dist/market-data-vendor-backfill/policies/resource-policy.json +0 -16
  50. package/dist/market-data-vendor-backfill/schema-manifest.json +0 -31
  51. package/dist/market-data-vendor-backfill/schemas/archive-selection.schema.json +0 -224
  52. package/dist/market-data-vendor-backfill/schemas/promotion-receipt.schema.json +0 -171
  53. package/dist/market-data-vendor-backfill/schemas/request.schema.json +0 -166
  54. package/dist/market-data-vendor-backfill/schemas/required-clock.schema.json +0 -47
  55. package/dist/market-data-vendor-backfill/schemas/result.schema.json +0 -198
@@ -0,0 +1,394 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://schemas.usher.so/market-data-source-qualification-record/v1",
4
+ "title": "CEX market-data source qualification record v1",
5
+ "type": "object",
6
+ "additionalProperties": false,
7
+ "required": [
8
+ "schema_id",
9
+ "record_sha256",
10
+ "created_at",
11
+ "operation_kind",
12
+ "normalized_invocation_sha256",
13
+ "request_id",
14
+ "scope",
15
+ "ledger",
16
+ "source_reconstruction_accepted",
17
+ "source_event_enumeration_eligible"
18
+ ],
19
+ "properties": {
20
+ "schema_id": {
21
+ "const": "https://schemas.usher.so/market-data-source-qualification-record/v1"
22
+ },
23
+ "record_sha256": { "$ref": "#/$defs/sha256" },
24
+ "created_at": { "$ref": "#/$defs/timestamp" },
25
+ "operation_kind": {
26
+ "enum": ["required_clock_qualification", "source_tape"]
27
+ },
28
+ "normalized_invocation_sha256": { "$ref": "#/$defs/sha256" },
29
+ "request_id": { "$ref": "#/$defs/uuid" },
30
+ "scope": { "$ref": "#/$defs/scope" },
31
+ "ledger": { "$ref": "#/$defs/ledger" },
32
+ "source_reconstruction_accepted": { "type": "boolean" },
33
+ "source_event_enumeration_eligible": { "type": "boolean" },
34
+ "qualified": { "type": "boolean" },
35
+ "source_partition_complete": { "type": "boolean" },
36
+ "source_tape_eligible": { "type": "boolean" },
37
+ "initializer": {
38
+ "oneOf": [{ "$ref": "#/$defs/initializer" }, { "type": "null" }]
39
+ },
40
+ "outcome": {}
41
+ },
42
+ "oneOf": [
43
+ {
44
+ "properties": {
45
+ "operation_kind": { "const": "required_clock_qualification" },
46
+ "ledger": { "$ref": "#/$defs/clockLedger" },
47
+ "qualified": { "type": "boolean" },
48
+ "source_partition_complete": { "type": "boolean" },
49
+ "source_tape_eligible": {},
50
+ "initializer": {},
51
+ "outcome": { "$ref": "#/$defs/clockOutcome" }
52
+ },
53
+ "required": ["qualified", "source_partition_complete", "outcome"],
54
+ "not": {
55
+ "anyOf": [
56
+ {
57
+ "properties": { "source_tape_eligible": {} },
58
+ "required": ["source_tape_eligible"]
59
+ },
60
+ { "properties": { "initializer": {} }, "required": ["initializer"] }
61
+ ]
62
+ }
63
+ },
64
+ {
65
+ "properties": {
66
+ "operation_kind": { "const": "source_tape" },
67
+ "ledger": { "$ref": "#/$defs/tapeLedger" },
68
+ "source_tape_eligible": { "type": "boolean" },
69
+ "initializer": {
70
+ "oneOf": [{ "$ref": "#/$defs/initializer" }, { "type": "null" }]
71
+ },
72
+ "outcome": { "$ref": "#/$defs/tapeOutcome" },
73
+ "qualified": {},
74
+ "source_partition_complete": {}
75
+ },
76
+ "required": ["source_tape_eligible", "initializer", "outcome"],
77
+ "not": {
78
+ "anyOf": [
79
+ { "properties": { "qualified": {} }, "required": ["qualified"] },
80
+ {
81
+ "properties": { "source_partition_complete": {} },
82
+ "required": ["source_partition_complete"]
83
+ }
84
+ ]
85
+ }
86
+ }
87
+ ],
88
+ "$defs": {
89
+ "sha256": { "type": "string", "pattern": "^[0-9a-f]{64}$" },
90
+ "uuid": {
91
+ "type": "string",
92
+ "pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"
93
+ },
94
+ "uint": { "type": "integer", "minimum": 0, "maximum": 9007199254740991 },
95
+ "timestamp": {
96
+ "type": "string",
97
+ "pattern": "^[0-9]{4}-(0[1-9]|1[0-2])-([0-2][0-9]|3[01])T([01][0-9]|2[0-3]):[0-5][0-9]:[0-5][0-9]\\.[0-9]{3}Z$"
98
+ },
99
+ "scope": {
100
+ "type": "object",
101
+ "additionalProperties": false,
102
+ "required": ["exchange", "trading_pair", "market_type", "feed"],
103
+ "properties": {
104
+ "exchange": { "type": "string", "pattern": "^[a-z0-9_-]+$" },
105
+ "trading_pair": {
106
+ "type": "string",
107
+ "pattern": "^[A-Z0-9]+-[A-Z0-9]+$"
108
+ },
109
+ "market_type": { "enum": ["spot", "swap", "future"] },
110
+ "feed": { "const": "ORDERBOOK" }
111
+ }
112
+ },
113
+ "ledger": {
114
+ "type": "object",
115
+ "additionalProperties": false,
116
+ "required": [
117
+ "schema_id",
118
+ "file_name",
119
+ "sha256",
120
+ "bytes",
121
+ "retained_record_count",
122
+ "total_record_count",
123
+ "omitted_record_count",
124
+ "complete"
125
+ ],
126
+ "properties": {
127
+ "schema_id": {
128
+ "const": "https://schemas.usher.so/market-data-source-forensics-ledger/v1"
129
+ },
130
+ "file_name": {
131
+ "type": "string",
132
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$"
133
+ },
134
+ "sha256": { "$ref": "#/$defs/sha256" },
135
+ "bytes": { "$ref": "#/$defs/uint" },
136
+ "retained_record_count": { "$ref": "#/$defs/uint" },
137
+ "total_record_count": { "$ref": "#/$defs/uint" },
138
+ "omitted_record_count": { "$ref": "#/$defs/uint" },
139
+ "complete": { "type": "boolean" },
140
+ "disposition_complete": { "type": "boolean" },
141
+ "fresh_target_count": { "$ref": "#/$defs/uint" },
142
+ "inactive_target_count": { "$ref": "#/$defs/uint" },
143
+ "disqualifying_target_count": { "$ref": "#/$defs/uint" },
144
+ "omitted_target_disposition_count": { "$ref": "#/$defs/uint" },
145
+ "state_count": { "$ref": "#/$defs/uint" }
146
+ }
147
+ },
148
+ "clockLedger": {
149
+ "allOf": [
150
+ { "$ref": "#/$defs/ledger" },
151
+ {
152
+ "type": "object",
153
+ "properties": {
154
+ "disposition_complete": {},
155
+ "fresh_target_count": {},
156
+ "inactive_target_count": {},
157
+ "disqualifying_target_count": {},
158
+ "omitted_target_disposition_count": {},
159
+ "state_count": {}
160
+ },
161
+ "required": [
162
+ "disposition_complete",
163
+ "fresh_target_count",
164
+ "inactive_target_count",
165
+ "disqualifying_target_count",
166
+ "omitted_target_disposition_count"
167
+ ],
168
+ "not": {
169
+ "type": "object",
170
+ "properties": { "state_count": {} },
171
+ "required": ["state_count"]
172
+ }
173
+ }
174
+ ]
175
+ },
176
+ "tapeLedger": {
177
+ "allOf": [
178
+ { "$ref": "#/$defs/ledger" },
179
+ {
180
+ "type": "object",
181
+ "properties": {
182
+ "state_count": {},
183
+ "disposition_complete": {},
184
+ "fresh_target_count": {},
185
+ "inactive_target_count": {},
186
+ "disqualifying_target_count": {},
187
+ "omitted_target_disposition_count": {}
188
+ },
189
+ "required": ["state_count"],
190
+ "not": {
191
+ "type": "object",
192
+ "anyOf": [
193
+ {
194
+ "type": "object",
195
+ "properties": { "disposition_complete": {} },
196
+ "required": ["disposition_complete"]
197
+ },
198
+ {
199
+ "type": "object",
200
+ "properties": { "fresh_target_count": {} },
201
+ "required": ["fresh_target_count"]
202
+ },
203
+ {
204
+ "type": "object",
205
+ "properties": { "inactive_target_count": {} },
206
+ "required": ["inactive_target_count"]
207
+ },
208
+ {
209
+ "type": "object",
210
+ "properties": { "disqualifying_target_count": {} },
211
+ "required": ["disqualifying_target_count"]
212
+ },
213
+ {
214
+ "type": "object",
215
+ "properties": { "omitted_target_disposition_count": {} },
216
+ "required": ["omitted_target_disposition_count"]
217
+ }
218
+ ]
219
+ }
220
+ }
221
+ ]
222
+ },
223
+ "evidenceDescriptor": {
224
+ "type": "object",
225
+ "additionalProperties": false,
226
+ "required": ["kind", "file_name", "sha256", "bytes"],
227
+ "properties": {
228
+ "kind": {
229
+ "enum": [
230
+ "ledger",
231
+ "provider_inventory",
232
+ "selection",
233
+ "promotion_receipt",
234
+ "export_result"
235
+ ]
236
+ },
237
+ "file_name": {
238
+ "type": "string",
239
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$"
240
+ },
241
+ "sha256": { "$ref": "#/$defs/sha256" },
242
+ "bytes": { "$ref": "#/$defs/uint" }
243
+ }
244
+ },
245
+ "exportResultDescriptor": {
246
+ "type": "object",
247
+ "additionalProperties": false,
248
+ "required": [
249
+ "schema_id",
250
+ "file_name",
251
+ "sha256",
252
+ "bytes",
253
+ "result_sha256"
254
+ ],
255
+ "properties": {
256
+ "schema_id": {
257
+ "const": "https://schemas.usher.so/cex-canonical-orderbook-export-result/v2"
258
+ },
259
+ "file_name": {
260
+ "type": "string",
261
+ "pattern": "^[A-Za-z0-9][A-Za-z0-9._-]{0,254}$"
262
+ },
263
+ "sha256": { "$ref": "#/$defs/sha256" },
264
+ "bytes": { "$ref": "#/$defs/uint" },
265
+ "result_sha256": { "$ref": "#/$defs/sha256" }
266
+ }
267
+ },
268
+ "initializer": {
269
+ "type": "object",
270
+ "additionalProperties": false,
271
+ "required": [
272
+ "canonical_snapshot_id",
273
+ "source_time_ms",
274
+ "sequence",
275
+ "semantic_stream_position"
276
+ ],
277
+ "properties": {
278
+ "canonical_snapshot_id": { "$ref": "#/$defs/sha256" },
279
+ "source_time_ms": { "$ref": "#/$defs/uint" },
280
+ "sequence": { "type": "string", "pattern": "^[0-9]+$" },
281
+ "semantic_stream_position": { "const": 0 }
282
+ }
283
+ },
284
+ "clockOutcome": {
285
+ "oneOf": [
286
+ {
287
+ "type": "object",
288
+ "additionalProperties": false,
289
+ "required": [
290
+ "status",
291
+ "reason",
292
+ "partial_evidence",
293
+ "exporter_result"
294
+ ],
295
+ "properties": {
296
+ "status": { "const": "success" },
297
+ "reason": { "const": "required_clock_qualification_completed" },
298
+ "partial_evidence": {
299
+ "type": "array",
300
+ "items": { "$ref": "#/$defs/evidenceDescriptor" }
301
+ },
302
+ "exporter_result": { "type": "null" }
303
+ }
304
+ },
305
+ {
306
+ "type": "object",
307
+ "additionalProperties": false,
308
+ "required": [
309
+ "status",
310
+ "reason",
311
+ "partial_evidence",
312
+ "exporter_result"
313
+ ],
314
+ "properties": {
315
+ "status": { "const": "failure" },
316
+ "reason": {
317
+ "enum": [
318
+ "required_clock_input_invalid",
319
+ "required_clock_capability_unsupported",
320
+ "required_clock_credentials_missing",
321
+ "required_clock_acquisition_failed",
322
+ "required_clock_reconstruction_failed",
323
+ "required_clock_classification_failed",
324
+ "required_clock_evidence_incomplete",
325
+ "required_clock_internal_failure"
326
+ ]
327
+ },
328
+ "partial_evidence": {
329
+ "type": "array",
330
+ "items": { "$ref": "#/$defs/evidenceDescriptor" }
331
+ },
332
+ "exporter_result": { "type": "null" }
333
+ }
334
+ }
335
+ ]
336
+ },
337
+ "tapeOutcome": {
338
+ "oneOf": [
339
+ {
340
+ "type": "object",
341
+ "additionalProperties": false,
342
+ "required": [
343
+ "status",
344
+ "reason",
345
+ "partial_evidence",
346
+ "exporter_result"
347
+ ],
348
+ "properties": {
349
+ "status": { "const": "success" },
350
+ "reason": { "const": "source_tape_prepared" },
351
+ "partial_evidence": {
352
+ "type": "array",
353
+ "items": { "$ref": "#/$defs/evidenceDescriptor" }
354
+ },
355
+ "exporter_result": { "$ref": "#/$defs/exportResultDescriptor" }
356
+ }
357
+ },
358
+ {
359
+ "type": "object",
360
+ "additionalProperties": false,
361
+ "required": [
362
+ "status",
363
+ "reason",
364
+ "partial_evidence",
365
+ "exporter_result"
366
+ ],
367
+ "properties": {
368
+ "status": { "const": "failure" },
369
+ "reason": {
370
+ "enum": [
371
+ "source_tape_input_invalid",
372
+ "source_tape_capability_unsupported",
373
+ "source_tape_credentials_missing",
374
+ "source_tape_acquisition_failed",
375
+ "source_tape_reconstruction_failed",
376
+ "source_tape_inventory_incomplete",
377
+ "source_tape_archive_failed",
378
+ "source_tape_promotion_failed",
379
+ "source_tape_selection_failed",
380
+ "source_tape_export_failed",
381
+ "source_tape_internal_failure"
382
+ ]
383
+ },
384
+ "partial_evidence": {
385
+ "type": "array",
386
+ "items": { "$ref": "#/$defs/evidenceDescriptor" }
387
+ },
388
+ "exporter_result": { "type": "null" }
389
+ }
390
+ }
391
+ ]
392
+ }
393
+ }
394
+ }
@@ -1,4 +1,11 @@
1
+ import { type MarketDataSourceTapeDependencyConfiguration } from "./helpers/market-data-preparation/source-tape-dependencies";
2
+ import type { MarketDataSourceTapeDependencies } from "./helpers/market-data-preparation/source-tape-operation";
1
3
  export * from "./helpers/canonical-orderbook-export/exact-selection";
2
4
  export * from "./helpers/canonical-orderbook-export/exporter";
3
5
  export * from "./helpers/market-data-preparation/conformance-fixtures";
4
6
  export * from "./helpers/market-data-preparation/contracts";
7
+ export * from "./helpers/market-data-preparation/required-clock-qualification";
8
+ export * from "./helpers/market-data-preparation/source-tape-operation";
9
+ export * from "./helpers/market-data-source-forensics";
10
+ export type { MarketDataSourceTapeDependencyConfiguration };
11
+ export declare function createMarketDataSourceTapeDependencies(configuration: MarketDataSourceTapeDependencyConfiguration): MarketDataSourceTapeDependencies;