@fleetless/contracts 13.0.1 → 13.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +31 -0
- package/artifacts/openapi.json +17 -17
- package/artifacts/routes.json +17 -25
- package/artifacts/schema/journal-deletion-manifest.schema.json +213 -3
- package/artifacts/schema/journal-manifest-batch.schema.json +142 -2
- package/artifacts/schema/journal-manifest-binding.schema.json +213 -3
- package/artifacts/schema/journal-manifest-row.schema.json +71 -1
- package/dist/assets.d.ts +1 -1
- package/dist/assets.js +1 -1
- package/dist/journal-manifests.d.ts +126 -0
- package/dist/journal-manifests.js +74 -1
- package/dist/rest.js +4 -4
- package/dist/routes.js +27 -30
- package/package.json +1 -1
|
@@ -572,7 +572,77 @@
|
|
|
572
572
|
"audit_id"
|
|
573
573
|
],
|
|
574
574
|
"additionalProperties": false
|
|
575
|
+
},
|
|
576
|
+
{
|
|
577
|
+
"type": "object",
|
|
578
|
+
"properties": {
|
|
579
|
+
"type": {
|
|
580
|
+
"type": "string",
|
|
581
|
+
"const": "retention_range"
|
|
582
|
+
},
|
|
583
|
+
"membership_kind": {
|
|
584
|
+
"type": "string",
|
|
585
|
+
"const": "affected"
|
|
586
|
+
},
|
|
587
|
+
"table": {
|
|
588
|
+
"type": "string",
|
|
589
|
+
"enum": [
|
|
590
|
+
"datapoint_series_samples",
|
|
591
|
+
"bridge_latency_buckets"
|
|
592
|
+
],
|
|
593
|
+
"description": "The table the range was deleted from."
|
|
594
|
+
},
|
|
595
|
+
"org_id": {
|
|
596
|
+
"type": "string",
|
|
597
|
+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
598
|
+
},
|
|
599
|
+
"robot_id": {
|
|
600
|
+
"type": "string",
|
|
601
|
+
"pattern": "^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$"
|
|
602
|
+
},
|
|
603
|
+
"series_id": {
|
|
604
|
+
"description": "The one datapoint series of the range; absent when the range covers every series of the robot. Never set for latency buckets.",
|
|
605
|
+
"type": "integer",
|
|
606
|
+
"minimum": 1,
|
|
607
|
+
"maximum": 9007199254740991
|
|
608
|
+
},
|
|
609
|
+
"from": {
|
|
610
|
+
"type": "string",
|
|
611
|
+
"format": "date-time",
|
|
612
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}(?:Z))$",
|
|
613
|
+
"description": "Inclusive lower bound of the deleted range (UTC, milliseconds)."
|
|
614
|
+
},
|
|
615
|
+
"cutoff": {
|
|
616
|
+
"type": "string",
|
|
617
|
+
"format": "date-time",
|
|
618
|
+
"pattern": "^(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))T(?:(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{3}(?:Z))$",
|
|
619
|
+
"description": "Exclusive upper bound of the deleted range (UTC, milliseconds). Replay deletes every row of the table inside [from, cutoff) for this robot and series and no row at or after the cutoff."
|
|
620
|
+
},
|
|
621
|
+
"row_count": {
|
|
622
|
+
"type": "integer",
|
|
623
|
+
"minimum": 1,
|
|
624
|
+
"maximum": 9007199254740991,
|
|
625
|
+
"description": "How many rows the range held when it was frozen."
|
|
626
|
+
},
|
|
627
|
+
"rows_digest": {
|
|
628
|
+
"type": "string",
|
|
629
|
+
"pattern": "^[0-9a-f]{64}$",
|
|
630
|
+
"description": "SHA-256 over the sorted row keys the range held when it was frozen (retention range digest v1); lets a backup of the range be checked against what was deleted."
|
|
631
|
+
}
|
|
632
|
+
},
|
|
633
|
+
"required": [
|
|
634
|
+
"type",
|
|
635
|
+
"membership_kind",
|
|
636
|
+
"table",
|
|
637
|
+
"org_id",
|
|
638
|
+
"robot_id",
|
|
639
|
+
"from",
|
|
640
|
+
"cutoff",
|
|
641
|
+
"row_count",
|
|
642
|
+
"rows_digest"
|
|
643
|
+
],
|
|
644
|
+
"additionalProperties": false
|
|
575
645
|
}
|
|
576
646
|
],
|
|
577
|
-
"description": "JSON Schema consumers must also check uuid_row generation equality
|
|
647
|
+
"description": "JSON Schema consumers must also check uuid_row generation equality, exact physical identity and that a retention range starts before it ends."
|
|
578
648
|
}
|
package/dist/assets.d.ts
CHANGED
|
@@ -390,7 +390,7 @@ export type AssetListResponse = z.infer<typeof assetListResponse>;
|
|
|
390
390
|
*
|
|
391
391
|
* A full store is never a dead end: the URDF upload is exempt from the gate,
|
|
392
392
|
* reconcile after every sync already frees what the new URDF stopped
|
|
393
|
-
* referencing, and this route is the third leg —
|
|
393
|
+
* referencing, and this route is the third leg — a developer can empty the
|
|
394
394
|
* store outright and let the next sync refill it. `deleted` and
|
|
395
395
|
* `bytes_freed` are what changed, not the store's state afterward — that is
|
|
396
396
|
* `0` by construction and not worth a field of its own.
|
package/dist/assets.js
CHANGED
|
@@ -527,7 +527,7 @@ export const assetListResponse = z.object({
|
|
|
527
527
|
*
|
|
528
528
|
* A full store is never a dead end: the URDF upload is exempt from the gate,
|
|
529
529
|
* reconcile after every sync already frees what the new URDF stopped
|
|
530
|
-
* referencing, and this route is the third leg —
|
|
530
|
+
* referencing, and this route is the third leg — a developer can empty the
|
|
531
531
|
* store outright and let the next sync refill it. `deleted` and
|
|
532
532
|
* `bytes_freed` are what changed, not the store's state afterward — that is
|
|
533
533
|
* `0` by construction and not worth a field of its own.
|
|
@@ -181,6 +181,20 @@ export declare const journalManifestRow: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
181
181
|
affected: "affected";
|
|
182
182
|
unaffected: "unaffected";
|
|
183
183
|
}>;
|
|
184
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
185
|
+
type: z.ZodLiteral<"retention_range">;
|
|
186
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
187
|
+
table: z.ZodEnum<{
|
|
188
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
189
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
190
|
+
}>;
|
|
191
|
+
org_id: z.ZodString;
|
|
192
|
+
robot_id: z.ZodString;
|
|
193
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
194
|
+
from: z.ZodISODateTime;
|
|
195
|
+
cutoff: z.ZodISODateTime;
|
|
196
|
+
row_count: z.ZodNumber;
|
|
197
|
+
rows_digest: z.ZodString;
|
|
184
198
|
}, z.core.$strict>]>;
|
|
185
199
|
export type JournalManifestRow = z.infer<typeof journalManifestRow>;
|
|
186
200
|
export declare const journalManifestEntry: z.ZodUnion<readonly [z.ZodObject<{
|
|
@@ -382,6 +396,20 @@ export declare const journalManifestBatch: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
382
396
|
affected: "affected";
|
|
383
397
|
unaffected: "unaffected";
|
|
384
398
|
}>;
|
|
399
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
400
|
+
type: z.ZodLiteral<"retention_range">;
|
|
401
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
402
|
+
table: z.ZodEnum<{
|
|
403
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
404
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
405
|
+
}>;
|
|
406
|
+
org_id: z.ZodString;
|
|
407
|
+
robot_id: z.ZodString;
|
|
408
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
409
|
+
from: z.ZodISODateTime;
|
|
410
|
+
cutoff: z.ZodISODateTime;
|
|
411
|
+
row_count: z.ZodNumber;
|
|
412
|
+
rows_digest: z.ZodString;
|
|
385
413
|
}, z.core.$strict>]>>;
|
|
386
414
|
}, z.core.$strict>, z.ZodObject<{
|
|
387
415
|
batch_id: z.ZodString;
|
|
@@ -544,6 +572,20 @@ export declare const journalManifestBatch: z.ZodUnion<readonly [z.ZodObject<{
|
|
|
544
572
|
affected: "affected";
|
|
545
573
|
unaffected: "unaffected";
|
|
546
574
|
}>;
|
|
575
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
576
|
+
type: z.ZodLiteral<"retention_range">;
|
|
577
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
578
|
+
table: z.ZodEnum<{
|
|
579
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
580
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
581
|
+
}>;
|
|
582
|
+
org_id: z.ZodString;
|
|
583
|
+
robot_id: z.ZodString;
|
|
584
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
585
|
+
from: z.ZodISODateTime;
|
|
586
|
+
cutoff: z.ZodISODateTime;
|
|
587
|
+
row_count: z.ZodNumber;
|
|
588
|
+
rows_digest: z.ZodString;
|
|
547
589
|
}, z.core.$strict>]>>;
|
|
548
590
|
}, z.core.$strict>]>;
|
|
549
591
|
export type JournalManifestBatch = z.infer<typeof journalManifestBatch>;
|
|
@@ -759,6 +801,20 @@ export declare const journalDeletionManifest: z.ZodObject<{
|
|
|
759
801
|
affected: "affected";
|
|
760
802
|
unaffected: "unaffected";
|
|
761
803
|
}>;
|
|
804
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
805
|
+
type: z.ZodLiteral<"retention_range">;
|
|
806
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
807
|
+
table: z.ZodEnum<{
|
|
808
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
809
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
810
|
+
}>;
|
|
811
|
+
org_id: z.ZodString;
|
|
812
|
+
robot_id: z.ZodString;
|
|
813
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
814
|
+
from: z.ZodISODateTime;
|
|
815
|
+
cutoff: z.ZodISODateTime;
|
|
816
|
+
row_count: z.ZodNumber;
|
|
817
|
+
rows_digest: z.ZodString;
|
|
762
818
|
}, z.core.$strict>]>>;
|
|
763
819
|
batches: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
764
820
|
batch_id: z.ZodString;
|
|
@@ -935,6 +991,20 @@ export declare const journalDeletionManifest: z.ZodObject<{
|
|
|
935
991
|
affected: "affected";
|
|
936
992
|
unaffected: "unaffected";
|
|
937
993
|
}>;
|
|
994
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
995
|
+
type: z.ZodLiteral<"retention_range">;
|
|
996
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
997
|
+
table: z.ZodEnum<{
|
|
998
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
999
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
1000
|
+
}>;
|
|
1001
|
+
org_id: z.ZodString;
|
|
1002
|
+
robot_id: z.ZodString;
|
|
1003
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
1004
|
+
from: z.ZodISODateTime;
|
|
1005
|
+
cutoff: z.ZodISODateTime;
|
|
1006
|
+
row_count: z.ZodNumber;
|
|
1007
|
+
rows_digest: z.ZodString;
|
|
938
1008
|
}, z.core.$strict>]>>;
|
|
939
1009
|
}, z.core.$strict>, z.ZodObject<{
|
|
940
1010
|
batch_id: z.ZodString;
|
|
@@ -1097,6 +1167,20 @@ export declare const journalDeletionManifest: z.ZodObject<{
|
|
|
1097
1167
|
affected: "affected";
|
|
1098
1168
|
unaffected: "unaffected";
|
|
1099
1169
|
}>;
|
|
1170
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1171
|
+
type: z.ZodLiteral<"retention_range">;
|
|
1172
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
1173
|
+
table: z.ZodEnum<{
|
|
1174
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
1175
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
1176
|
+
}>;
|
|
1177
|
+
org_id: z.ZodString;
|
|
1178
|
+
robot_id: z.ZodString;
|
|
1179
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
1180
|
+
from: z.ZodISODateTime;
|
|
1181
|
+
cutoff: z.ZodISODateTime;
|
|
1182
|
+
row_count: z.ZodNumber;
|
|
1183
|
+
rows_digest: z.ZodString;
|
|
1100
1184
|
}, z.core.$strict>]>>;
|
|
1101
1185
|
}, z.core.$strict>]>>;
|
|
1102
1186
|
}, z.core.$strict>;
|
|
@@ -1324,6 +1408,20 @@ export declare const journalManifestBinding: z.ZodObject<{
|
|
|
1324
1408
|
affected: "affected";
|
|
1325
1409
|
unaffected: "unaffected";
|
|
1326
1410
|
}>;
|
|
1411
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1412
|
+
type: z.ZodLiteral<"retention_range">;
|
|
1413
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
1414
|
+
table: z.ZodEnum<{
|
|
1415
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
1416
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
1417
|
+
}>;
|
|
1418
|
+
org_id: z.ZodString;
|
|
1419
|
+
robot_id: z.ZodString;
|
|
1420
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
1421
|
+
from: z.ZodISODateTime;
|
|
1422
|
+
cutoff: z.ZodISODateTime;
|
|
1423
|
+
row_count: z.ZodNumber;
|
|
1424
|
+
rows_digest: z.ZodString;
|
|
1327
1425
|
}, z.core.$strict>]>>;
|
|
1328
1426
|
batches: z.ZodArray<z.ZodUnion<readonly [z.ZodObject<{
|
|
1329
1427
|
batch_id: z.ZodString;
|
|
@@ -1500,6 +1598,20 @@ export declare const journalManifestBinding: z.ZodObject<{
|
|
|
1500
1598
|
affected: "affected";
|
|
1501
1599
|
unaffected: "unaffected";
|
|
1502
1600
|
}>;
|
|
1601
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1602
|
+
type: z.ZodLiteral<"retention_range">;
|
|
1603
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
1604
|
+
table: z.ZodEnum<{
|
|
1605
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
1606
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
1607
|
+
}>;
|
|
1608
|
+
org_id: z.ZodString;
|
|
1609
|
+
robot_id: z.ZodString;
|
|
1610
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
1611
|
+
from: z.ZodISODateTime;
|
|
1612
|
+
cutoff: z.ZodISODateTime;
|
|
1613
|
+
row_count: z.ZodNumber;
|
|
1614
|
+
rows_digest: z.ZodString;
|
|
1503
1615
|
}, z.core.$strict>]>>;
|
|
1504
1616
|
}, z.core.$strict>, z.ZodObject<{
|
|
1505
1617
|
batch_id: z.ZodString;
|
|
@@ -1662,6 +1774,20 @@ export declare const journalManifestBinding: z.ZodObject<{
|
|
|
1662
1774
|
affected: "affected";
|
|
1663
1775
|
unaffected: "unaffected";
|
|
1664
1776
|
}>;
|
|
1777
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
1778
|
+
type: z.ZodLiteral<"retention_range">;
|
|
1779
|
+
membership_kind: z.ZodLiteral<"affected">;
|
|
1780
|
+
table: z.ZodEnum<{
|
|
1781
|
+
datapoint_series_samples: "datapoint_series_samples";
|
|
1782
|
+
bridge_latency_buckets: "bridge_latency_buckets";
|
|
1783
|
+
}>;
|
|
1784
|
+
org_id: z.ZodString;
|
|
1785
|
+
robot_id: z.ZodString;
|
|
1786
|
+
series_id: z.ZodOptional<z.ZodNumber>;
|
|
1787
|
+
from: z.ZodISODateTime;
|
|
1788
|
+
cutoff: z.ZodISODateTime;
|
|
1789
|
+
row_count: z.ZodNumber;
|
|
1790
|
+
rows_digest: z.ZodString;
|
|
1665
1791
|
}, z.core.$strict>]>>;
|
|
1666
1792
|
}, z.core.$strict>]>>;
|
|
1667
1793
|
}, z.core.$strict>;
|
|
@@ -24,6 +24,8 @@ const uuidRowTable = z.enum([
|
|
|
24
24
|
'organization_exports', 'ops_notification_jobs', 'console_oauth_codes',
|
|
25
25
|
]);
|
|
26
26
|
const member = { membership_kind: membership };
|
|
27
|
+
// Retention sweeps name an expired time range instead of every deleted row.
|
|
28
|
+
const retentionRangeTable = z.enum(['datapoint_series_samples', 'bridge_latency_buckets']);
|
|
27
29
|
export const journalManifestRow = z.union([
|
|
28
30
|
z.strictObject({ ...member, type: z.literal('uuid_row'), table: uuidRowTable, id: uuid, row_generation: uuid }),
|
|
29
31
|
z.strictObject({ ...member, type: z.literal('basic_activity_observation'), org_id: uuid, audit_event_id: uuid }),
|
|
@@ -44,11 +46,30 @@ export const journalManifestRow = z.union([
|
|
|
44
46
|
z.strictObject({ ...member, type: z.literal('global_ops_event'), event_id: uuid }),
|
|
45
47
|
z.strictObject({ ...member, type: z.literal('org_operator_audit'), org_id: uuid, audit_id: uuid }),
|
|
46
48
|
z.strictObject({ ...member, type: z.literal('global_operator_audit'), audit_id: uuid }),
|
|
49
|
+
z.strictObject({
|
|
50
|
+
type: z.literal('retention_range'),
|
|
51
|
+
membership_kind: z.literal('affected'),
|
|
52
|
+
table: retentionRangeTable.meta({ description: 'The table the range was deleted from.' }),
|
|
53
|
+
org_id: uuid,
|
|
54
|
+
robot_id: uuid,
|
|
55
|
+
series_id: positive.optional().meta({ description: 'The one datapoint series of the range; absent when the range covers every series of the robot. Never set for latency buckets.' }),
|
|
56
|
+
from: utcMillis.meta({ description: 'Inclusive lower bound of the deleted range (UTC, milliseconds).' }),
|
|
57
|
+
cutoff: utcMillis.meta({ description: 'Exclusive upper bound of the deleted range (UTC, milliseconds). Replay deletes every row of the table inside [from, cutoff) for this robot and series and no row at or after the cutoff.' }),
|
|
58
|
+
row_count: positive.meta({ description: 'How many rows the range held when it was frozen.' }),
|
|
59
|
+
rows_digest: hash.meta({ description: 'SHA-256 over the sorted row keys the range held when it was frozen (retention range digest v1); lets a backup of the range be checked against what was deleted.' }),
|
|
60
|
+
}),
|
|
47
61
|
]).superRefine((row, ctx) => {
|
|
48
62
|
if (row.type === 'uuid_row' && row.row_generation !== row.id) {
|
|
49
63
|
ctx.addIssue({ code: 'custom', path: ['row_generation'], message: 'Immutable UUID row generation must equal its ID' });
|
|
50
64
|
}
|
|
51
|
-
|
|
65
|
+
if (row.type === 'retention_range') {
|
|
66
|
+
if (row.from >= row.cutoff)
|
|
67
|
+
ctx.addIssue({ code: 'custom', path: ['cutoff'], message: 'A retention range must end after it starts' });
|
|
68
|
+
if (row.table === 'bridge_latency_buckets' && row.series_id !== undefined) {
|
|
69
|
+
ctx.addIssue({ code: 'custom', path: ['series_id'], message: 'Latency buckets are not kept per series' });
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}).describe('JSON Schema consumers must also check uuid_row generation equality, exact physical identity and that a retention range starts before it ends.');
|
|
52
73
|
const entry = { mapping_id: uuid, source_project_id: opaqueId, source_bucket: opaqueId,
|
|
53
74
|
old_key: opaqueId, version_ids: z.array(opaqueId).min(1), membership_kind: membership };
|
|
54
75
|
export const journalManifestEntry = z.union([
|
|
@@ -92,6 +113,7 @@ function rowKey(row) {
|
|
|
92
113
|
case 'global_ops_event': return JSON.stringify(['ops_events', row.event_id]);
|
|
93
114
|
case 'org_operator_audit':
|
|
94
115
|
case 'global_operator_audit': return JSON.stringify(['operator_audit', row.audit_id]);
|
|
116
|
+
case 'retention_range': return JSON.stringify([row.table, 'range', row.robot_id, row.series_id ?? null, row.from]);
|
|
95
117
|
}
|
|
96
118
|
}
|
|
97
119
|
function entryKey(value) { return JSON.stringify([value.kind, value.mapping_id]); }
|
|
@@ -128,6 +150,53 @@ const nonOrganizationScope = {
|
|
|
128
150
|
'operator_audit.retention': 'operator_audit',
|
|
129
151
|
'auth_factor.remove': 'subject',
|
|
130
152
|
};
|
|
153
|
+
const rangeTableOfKind = {
|
|
154
|
+
'history.retention': 'datapoint_series_samples',
|
|
155
|
+
'history.slug_delete': 'datapoint_series_samples',
|
|
156
|
+
'latency.retention': 'bridge_latency_buckets',
|
|
157
|
+
};
|
|
158
|
+
/**
|
|
159
|
+
* A retention range belongs to exactly the history and latency retention
|
|
160
|
+
* kinds, stays inside the organization, robot, series and cutoff of its
|
|
161
|
+
* intent, and no two ranges of one robot overlap (a robot's ranges name a
|
|
162
|
+
* series all or none of them).
|
|
163
|
+
*/
|
|
164
|
+
function retentionRangeProblems(kind, ids, ranges) {
|
|
165
|
+
const problems = [];
|
|
166
|
+
const table = rangeTableOfKind[kind];
|
|
167
|
+
if (table === undefined)
|
|
168
|
+
return ['Retention ranges belong only to history and latency retention'];
|
|
169
|
+
for (const range of ranges) {
|
|
170
|
+
if (range.table !== table)
|
|
171
|
+
problems.push('Range table does not match the intent kind');
|
|
172
|
+
if (range.org_id !== ids.org_id)
|
|
173
|
+
problems.push('Range organization does not match the intent');
|
|
174
|
+
if (kind === 'history.slug_delete' && (range.robot_id !== ids.robot_id || range.series_id !== ids.series_id)) {
|
|
175
|
+
problems.push('Range robot or series does not match the intent');
|
|
176
|
+
}
|
|
177
|
+
if (kind !== 'history.slug_delete' && typeof ids.cutoff_at === 'string' && range.cutoff > ids.cutoff_at) {
|
|
178
|
+
problems.push('Range reaches past the sweep cutoff');
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
const byRobot = new Map();
|
|
182
|
+
for (const range of ranges)
|
|
183
|
+
byRobot.set(range.robot_id, [...(byRobot.get(range.robot_id) ?? []), range]);
|
|
184
|
+
for (const group of byRobot.values()) {
|
|
185
|
+
if (new Set(group.map((range) => range.series_id === undefined)).size > 1) {
|
|
186
|
+
problems.push('A robot\'s ranges must name a series all or none');
|
|
187
|
+
continue;
|
|
188
|
+
}
|
|
189
|
+
const bySeries = new Map();
|
|
190
|
+
for (const range of group)
|
|
191
|
+
bySeries.set(range.series_id, [...(bySeries.get(range.series_id) ?? []), range]);
|
|
192
|
+
for (const series of bySeries.values()) {
|
|
193
|
+
const ordered = [...series].sort((a, b) => (a.from < b.from ? -1 : a.from > b.from ? 1 : 0));
|
|
194
|
+
if (ordered.some((range, index) => index > 0 && range.from < ordered[index - 1].cutoff))
|
|
195
|
+
problems.push('Ranges of one robot overlap');
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
return problems;
|
|
199
|
+
}
|
|
131
200
|
/** A structural candidate; it is not a signed intent or protected readback. */
|
|
132
201
|
export const journalManifestBinding = z.strictObject({
|
|
133
202
|
intent: journalManifestIntentProjection, manifest: journalDeletionManifest,
|
|
@@ -159,6 +228,10 @@ export const journalManifestBinding = z.strictObject({
|
|
|
159
228
|
const allows = allowedRows[manifest.scope.kind];
|
|
160
229
|
if (allows && !manifest.rows.every(allows))
|
|
161
230
|
problem('Row outside closed source scope', ['manifest', 'rows']);
|
|
231
|
+
const ranges = manifest.rows.filter((row) => row.type === 'retention_range');
|
|
232
|
+
if (ranges.length > 0)
|
|
233
|
+
for (const message of new Set(retentionRangeProblems(intent.kind, ids, ranges)))
|
|
234
|
+
problem(message, ['manifest', 'rows']);
|
|
162
235
|
const isSweep = sweepKinds.some((kind) => kind === intent.kind);
|
|
163
236
|
const isExplicit = explicitKinds.some((kind) => kind === intent.kind);
|
|
164
237
|
if (isSweep || isExplicit) {
|
package/dist/rest.js
CHANGED
|
@@ -644,7 +644,7 @@ export const jobResponse = z.object({
|
|
|
644
644
|
* | `GET /api/robots/{id}/assets/{assetId}` | developer **or** end user | `assets`, end users only |
|
|
645
645
|
* | `GET /api/robots/{id}/assets/missing?name=` | developer **or** end user | `assets`, end users only |
|
|
646
646
|
* | `GET /api/robots/{id}/urdf` | developer **or** end user | `assets`, end users only |
|
|
647
|
-
* | `POST /api/robots/{id}/assets/sync` | developer
|
|
647
|
+
* | `POST /api/robots/{id}/assets/sync` | developer | — |
|
|
648
648
|
* | `GET /api/robots/{id}/assets/sync/{syncId}` | developer | — |
|
|
649
649
|
* | `POST /api/bridge/assets` | robot token, per sync | — |
|
|
650
650
|
*
|
|
@@ -670,9 +670,9 @@ export const jobResponse = z.object({
|
|
|
670
670
|
* belonging to that robot. One mechanism instead of two, and robot deletion is
|
|
671
671
|
* already a cascade.
|
|
672
672
|
*
|
|
673
|
-
* Reading is a role capability; **changing the store
|
|
674
|
-
* spends the org's asset quota and a
|
|
675
|
-
*
|
|
673
|
+
* Reading is a role capability; **changing the store takes a developer
|
|
674
|
+
* session, never an end user's** — a sync spends the org's asset quota and a
|
|
675
|
+
* deletion breaks every app rendering that robot.
|
|
676
676
|
*
|
|
677
677
|
* **`GET .../assets/missing` is the sole producer of `asset_missing`.** It
|
|
678
678
|
* never succeeds,
|
package/dist/routes.js
CHANGED
|
@@ -625,12 +625,11 @@ export const ROUTES = [
|
|
|
625
625
|
{
|
|
626
626
|
method: 'DELETE', path: '/api/apps/:id', section: 'apps',
|
|
627
627
|
summary: 'Deletes an app and everything it produced.',
|
|
628
|
-
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier:
|
|
628
|
+
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: false, status: 204,
|
|
629
629
|
params: [{ name: 'id', description: 'The app\'s uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`.' }],
|
|
630
630
|
query: null, request: null, response: null,
|
|
631
|
-
errors: [...DEVELOPER_GUARD, '
|
|
632
|
-
notes: '
|
|
633
|
-
'for an app outside their org, rather than a tier refusal that confirms the id exists. A full cascade — its users, roles, server keys, ' +
|
|
631
|
+
errors: [...DEVELOPER_GUARD, 'invalid_uuid', 'not_found'], transport: 'http',
|
|
632
|
+
notes: 'An app outside the caller\'s org answers `404`, as an unknown id does. A full cascade — its users, roles, server keys, ' +
|
|
634
633
|
'invitations, OIDC provider configuration and mail templates all go, recorded once as `app.deleted` carrying an `appDeletionSummary`. ' +
|
|
635
634
|
'Its robots are untouched: they belong to the org, not to the app. \n\n**No `force` parameter** — see ' +
|
|
636
635
|
'`GET /api/apps/:id/deletion-preview`.',
|
|
@@ -725,11 +724,11 @@ export const ROUTES = [
|
|
|
725
724
|
{
|
|
726
725
|
method: 'POST', path: '/api/apps/:id/server-keys', section: 'apps',
|
|
727
726
|
summary: 'Mints a server key for the app and returns the raw secret once.',
|
|
728
|
-
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier:
|
|
727
|
+
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: false, status: 201,
|
|
729
728
|
params: [{ name: 'id', description: 'The app\'s uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`.' }],
|
|
730
729
|
query: null, request: null, response: createServerKeyResponse,
|
|
731
|
-
errors: [...DEVELOPER_GUARD, '
|
|
732
|
-
notes: '
|
|
730
|
+
errors: [...DEVELOPER_GUARD, 'invalid_uuid', 'not_found', 'validation_error'], transport: 'http',
|
|
731
|
+
notes: 'A server key carries full app rights and outlives its creator\'s removal. The body is `{ "name": string }`, the same ' +
|
|
733
732
|
'trivial shape role creation takes. `key` is the only moment the raw secret exists outside the caller\'s hands — it is never in a ' +
|
|
734
733
|
'listing, never in an audit event, and cannot be read back.',
|
|
735
734
|
},
|
|
@@ -746,28 +745,28 @@ export const ROUTES = [
|
|
|
746
745
|
{
|
|
747
746
|
method: 'POST', path: '/api/apps/:id/server-keys/:keyId/rotate', section: 'apps',
|
|
748
747
|
summary: 'Replaces a server key\'s secret in place and returns the new one once.',
|
|
749
|
-
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier:
|
|
748
|
+
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: false, status: 200,
|
|
750
749
|
params: [
|
|
751
750
|
{ name: 'id', description: 'The app\'s uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`.' },
|
|
752
751
|
{ name: 'keyId', description: 'The server key\'s uuid, from `GET /api/apps/:id/server-keys`; a key of another app answers `404`.' },
|
|
753
752
|
],
|
|
754
753
|
query: null, request: null, response: createServerKeyResponse,
|
|
755
|
-
errors: [...DEVELOPER_GUARD, '
|
|
756
|
-
notes: '
|
|
754
|
+
errors: [...DEVELOPER_GUARD, 'invalid_uuid', 'not_found'], transport: 'http',
|
|
755
|
+
notes: 'The old secret is refused from this call on, and any `/realtime` socket that authenticated with ' +
|
|
757
756
|
'it is closed — rotation is what a developer reaches for when a key has leaked, and the holder of that socket is exactly who they are ' +
|
|
758
757
|
'rotating against.',
|
|
759
758
|
},
|
|
760
759
|
{
|
|
761
760
|
method: 'DELETE', path: '/api/apps/:id/server-keys/:keyId', section: 'apps',
|
|
762
761
|
summary: 'Revokes a server key and closes every socket holding it.',
|
|
763
|
-
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier:
|
|
762
|
+
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: false, status: 204,
|
|
764
763
|
params: [
|
|
765
764
|
{ name: 'id', description: 'The app\'s uuid, as returned by `POST /api/apps` or listed by `GET /api/apps`.' },
|
|
766
765
|
{ name: 'keyId', description: 'The server key\'s uuid, from `GET /api/apps/:id/server-keys`; a key of another app answers `404`.' },
|
|
767
766
|
],
|
|
768
767
|
query: null, request: null, response: null,
|
|
769
|
-
errors: [...DEVELOPER_GUARD, '
|
|
770
|
-
notes: '
|
|
768
|
+
errors: [...DEVELOPER_GUARD, 'invalid_uuid', 'not_found'], transport: 'http',
|
|
769
|
+
notes: 'The key stops working at once. Minting, rotating and revoking all decide who may speak for the whole app.',
|
|
771
770
|
},
|
|
772
771
|
/* -------------------------------------- the app's users and invitations */
|
|
773
772
|
{
|
|
@@ -1649,7 +1648,7 @@ export const ROUTES = [
|
|
|
1649
1648
|
'the refusal has to carry a `WWW-Authenticate` challenge that a guard shared with the REST surface does not send. `Origin` is checked ' +
|
|
1650
1649
|
'against the cloud\'s own, and a foreign one is the `403 forbidden` above. **Both catalogs, unconditionally**: every caller admitted ' +
|
|
1651
1650
|
'here is a Fleetless user, so the tool list has nothing left to vary with and the admin-ness check on `tools/call` is gone — a console ' +
|
|
1652
|
-
'tool that is still narrower than the catalog refuses for itself (`
|
|
1651
|
+
'tool that is still narrower than the catalog refuses for itself (`console_team_write.delete` refuses to remove an owner). ' +
|
|
1653
1652
|
'`403 forbidden` is also what an `mcp_session` token whose subject is an **app user** gets: this endpoint serves the team only, and such ' +
|
|
1654
1653
|
'a token belongs to its own app\'s endpoint. The code is `forbidden` rather than `mcp_disabled` because nothing is switched off — the ' +
|
|
1655
1654
|
'caller is at the wrong server — and per-app sign-in mints exactly such tokens, so the two states must not share a word. ' +
|
|
@@ -2264,13 +2263,12 @@ export const ROUTES = [
|
|
|
2264
2263
|
{
|
|
2265
2264
|
method: 'POST', path: '/api/robots/:id/token/rotate', section: 'robots',
|
|
2266
2265
|
summary: 'Mints a new bridge token for the robot and invalidates the old one.',
|
|
2267
|
-
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier:
|
|
2266
|
+
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: false, status: 201,
|
|
2268
2267
|
params: [{ name: 'id', description: 'The robot\'s uuid, as returned by `POST /api/robots` or listed by `GET /api/robots`.' }],
|
|
2269
2268
|
query: null, request: null, response: robotTokenRotateResponse,
|
|
2270
|
-
errors: [...DEVELOPER_GUARD, '
|
|
2271
|
-
notes: '
|
|
2272
|
-
'
|
|
2273
|
-
'stores a hash — so a caller who loses it rotates again. Audited as `robot.token_rotated`, with no `details`: the one interesting value ' +
|
|
2269
|
+
errors: [...DEVELOPER_GUARD, 'invalid_uuid', 'not_found'], transport: 'http',
|
|
2270
|
+
notes: 'A robot outside the caller\'s org answers `404`, as an unknown id does. `token` is the only moment the new secret exists outside the ' +
|
|
2271
|
+
'caller\'s hands — the cloud stores a hash — so a caller who loses it rotates again. Audited as `robot.token_rotated`, with no `details`: the one interesting value ' +
|
|
2274
2272
|
'here is the token. \n\n**It stops the bridge that is connected right now.** The old secret is gone the instant the hash is replaced, so ' +
|
|
2275
2273
|
'the cloud closes that socket with `CLOSE_TOKEN_ROTATED` rather than leaving a bridge speaking on a credential nothing would accept ' +
|
|
2276
2274
|
'again. A bridge that does not know the code reconnects and is refused at hello as `invalid_token`, which is the honest answer and ends ' +
|
|
@@ -2336,12 +2334,11 @@ export const ROUTES = [
|
|
|
2336
2334
|
{
|
|
2337
2335
|
method: 'DELETE', path: '/api/robots/:id', section: 'robots',
|
|
2338
2336
|
summary: 'Deletes a robot and everything it produced.',
|
|
2339
|
-
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier:
|
|
2337
|
+
audience: 'developer', auth: 'developer', rateLimited: false, ownerTier: false, status: 204,
|
|
2340
2338
|
params: [{ name: 'id', description: 'The robot\'s uuid, as returned by `POST /api/robots` or listed by `GET /api/robots`.' }],
|
|
2341
2339
|
query: robotDeleteQuery, request: null, response: null,
|
|
2342
|
-
errors: [...DEVELOPER_GUARD, '
|
|
2343
|
-
notes: '
|
|
2344
|
-
'for a robot outside their org, rather than a tier refusal that confirms the id exists. A full cascade — everything the robot produced ' +
|
|
2340
|
+
errors: [...DEVELOPER_GUARD, 'invalid_uuid', 'not_found', 'robot_in_use', 'robot_deletion_partial'], transport: 'http',
|
|
2341
|
+
notes: 'A robot outside the caller\'s org answers `404`, as an unknown id does. A full cascade — everything the robot produced ' +
|
|
2345
2342
|
'goes, except the audit trail, which is a record of what happened and must survive the thing it happened to. An open live session is ' +
|
|
2346
2343
|
'`409 robot_in_use` unless `?force=true` is passed, matched as the bare string so the caller has to actually say it. A cascade that ' +
|
|
2347
2344
|
'fails partway is `500 robot_deletion_partial` with the progress, never a bare `internal_error` that would read as "nothing happened".',
|
|
@@ -2867,11 +2864,11 @@ export const ROUTES = [
|
|
|
2867
2864
|
{
|
|
2868
2865
|
method: 'POST', path: '/api/robots/:id/assets/sync', section: 'assets',
|
|
2869
2866
|
summary: 'Asks the robot to upload its URDF and meshes, and returns the sync id.',
|
|
2870
|
-
audience: 'client', auth: 'developer_or_client', rateLimited: false, ownerTier:
|
|
2867
|
+
audience: 'client', auth: 'developer_or_client', rateLimited: false, ownerTier: false, status: 202,
|
|
2871
2868
|
params: [{ name: 'id', description: 'The robot\'s uuid, as returned by `POST /api/robots` or listed by `GET /api/robots`.' }],
|
|
2872
2869
|
query: null, request: assetSyncRequest, response: assetSyncResponse,
|
|
2873
|
-
errors: [...CLIENT_GUARD, '
|
|
2874
|
-
notes: '
|
|
2870
|
+
errors: [...CLIENT_GUARD, 'invalid_uuid', 'validation_error', 'not_found', 'robot_offline', 'busy'], transport: 'http',
|
|
2871
|
+
notes: 'Developer sessions only. The guard admits an end user or a server key, but only a developer session gets past the handler — and the ' +
|
|
2875
2872
|
'body is parsed **before** that `401`, because this route has always answered a malformed body first and the order has to survive. The ' +
|
|
2876
2873
|
'request is strict: a caller naming a source that does not exist learns so, instead of silently getting a bridge sync they did not ask ' +
|
|
2877
2874
|
'for. A robot that has reported nothing available to sync is `404`. A second sync is `409 busy` naming the `sync_id` that is actually ' +
|
|
@@ -2893,13 +2890,13 @@ export const ROUTES = [
|
|
|
2893
2890
|
{
|
|
2894
2891
|
method: 'DELETE', path: '/api/robots/:id/assets', section: 'assets',
|
|
2895
2892
|
summary: "Empties a robot's asset store: every URDF, mesh and texture, gone at once.",
|
|
2896
|
-
audience: 'client', auth: 'developer_or_client', rateLimited: false, ownerTier:
|
|
2893
|
+
audience: 'client', auth: 'developer_or_client', rateLimited: false, ownerTier: false, status: 200,
|
|
2897
2894
|
params: [{ name: 'id', description: 'The robot\'s uuid, as returned by `POST /api/robots` or listed by `GET /api/robots`.' }],
|
|
2898
2895
|
query: null, request: null, response: assetsClearResponse,
|
|
2899
|
-
errors: [...CLIENT_GUARD, '
|
|
2896
|
+
errors: [...CLIENT_GUARD, 'invalid_uuid', 'not_found', 'busy'], transport: 'http',
|
|
2900
2897
|
notes: 'The store\'s escape hatch: a full store is never a dead end, and this is the blunt third of the three answers to it — the URDF upload ' +
|
|
2901
|
-
'is exempt from the gate, reconcile after a sync already frees what the new URDF stopped referencing, and this route lets
|
|
2902
|
-
'the robot outright.
|
|
2898
|
+
'is exempt from the gate, reconcile after a sync already frees what the new URDF stopped referencing, and this route lets a developer clear ' +
|
|
2899
|
+
'the robot outright. Developer sessions only, like starting a sync. Removes every asset of the robot and resets its store to `0`; ' +
|
|
2903
2900
|
"the next sync fills it again. It does not touch the bridge's availability report — `urdf_available` still answers from the connected " +
|
|
2904
2901
|
'robot, unrelated to what this cloud happens to have stored. A clear while a sync is running is `409 busy` naming that sync\'s ' +
|
|
2905
2902
|
'details, the same refusal starting a second sync gets, because deleting under a running upload would leave the store counter wrong.',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fleetless/contracts",
|
|
3
|
-
"version": "13.0
|
|
3
|
+
"version": "13.2.0",
|
|
4
4
|
"description": "Fleetless wire contracts: the bridge-cloud protocol, the REST API schemas and the error codes, as zod schemas with generated JSON Schema and OpenAPI artifacts.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Dehne Robotik GmbH",
|