|
1 | | -/** |
2 | | - * Branded types for kernel identifiers. |
3 | | - * |
4 | | - * ## Trust model |
5 | | - * |
6 | | - * Branded types are validated at creation time via `insist*()` assertions and |
7 | | - * `makeGCAction()`. After construction, the type system carries the invariant |
8 | | - * — interior code trusts the brand without re-checking. |
9 | | - * |
10 | | - * - **External input** (JSON-RPC params, liveslots syscalls): validated at the |
11 | | - * boundary using superstruct definitions (`KRefStruct`, `EndpointIdStruct`, |
12 | | - * `EndpointMessageStruct`, etc.). |
13 | | - * - **Translator layer**: validates endpoint-space refs via `insistERef()` |
14 | | - * before translating to kernel-space. |
15 | | - * - **Persistence reads**: trusted. Data integrity is the responsibility of the |
16 | | - * persistence layer (`@metamask/kernel-store`); branded types are applied via |
17 | | - * `as` casts on read. See the kernel-store package README for details. |
18 | | - * - **Internal construction** (counters, template literals): uses `as` casts |
19 | | - * where the format is controlled by the constructor (e.g., `\`v\${id}\` as VatId`). |
20 | | - */ |
21 | | - |
22 | 1 | import type { |
23 | 2 | Baggage, |
24 | 3 | Message as SwingsetMessage, |
@@ -62,11 +41,30 @@ import type { |
62 | 41 | } from './remotes/types.ts'; |
63 | 42 | import { Fail } from './utils/assert.ts'; |
64 | 43 |
|
65 | | -// Branded string types intentionally use plain `string &` rather than template |
66 | | -// literal types (e.g. `v${number}`). The brands already prevent cross-type |
67 | | -// confusion, and the format is enforced at runtime by `insist*()` / `is*()` |
68 | | -// validators. Template literals would add friction to the `as` casts used for |
69 | | -// persistence reads and internal construction without meaningful extra safety. |
| 44 | +/** |
| 45 | + * # Branded types |
| 46 | + * |
| 47 | + * Branded types are validated at creation time via `insist*()` assertions and |
| 48 | + * `makeGCAction()`. After construction, the type system carries the invariant; |
| 49 | + * interior code trusts the brand without re-checking. |
| 50 | + * |
| 51 | + * - **External input** (JSON-RPC params, liveslots syscalls): validated at the |
| 52 | + * boundary using superstruct definitions (`KRefStruct`, `EndpointIdStruct`, |
| 53 | + * `EndpointMessageStruct`, etc.). |
| 54 | + * - **Translator layer**: validates endpoint-space refs via `insistERef()` |
| 55 | + * before translating to kernel-space. |
| 56 | + * - **Persistence reads**: trusted. Data integrity is the responsibility of the |
| 57 | + * persistence layer (`@metamask/kernel-store`); branded types are applied via |
| 58 | + * `as` casts on read. See `./store/README.md` for details. |
| 59 | + * - **Internal construction** (counters, template literals): uses `as` casts |
| 60 | + * where the format is controlled by the constructor (e.g., `"v1" as VatId`). |
| 61 | + * |
| 62 | + * Branded string types intentionally use plain `string &` rather than template |
| 63 | + * literal types (e.g. `v${number}`). The brands already prevent cross-type |
| 64 | + * confusion, and the format is enforced at runtime by `insist*()` / `is*()` |
| 65 | + * validators. Template literals would add friction to the `as` casts used for |
| 66 | + * persistence reads and internal construction without meaningful extra safety. |
| 67 | + */ |
70 | 68 |
|
71 | 69 | declare const VatIdBrand: unique symbol; |
72 | 70 | /** |
|
0 commit comments