@native-sdk/cli 0.8.4 → 0.9.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 (161) hide show
  1. package/build/app.zig +1178 -74
  2. package/build.zig +715 -17
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +10 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +435 -3
  7. package/packages/core/package-lock.json +11 -11
  8. package/packages/core/package.json +2 -2
  9. package/packages/core/scripts/compiler_typecheck.mjs +116 -15
  10. package/packages/core/scripts/gen_service_surface.mjs +268 -0
  11. package/packages/core/scripts/merge_static_archives.mjs +78 -0
  12. package/packages/core/scripts/npm_static_spike.mjs +64 -0
  13. package/packages/core/scripts/run_external_core_compiler.mjs +122 -6
  14. package/packages/core/scripts/run_external_service_compiler.mjs +280 -0
  15. package/packages/core/scripts/stage_external_core.mjs +9 -1
  16. package/packages/core/scripts/stage_external_services.mjs +172 -0
  17. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  18. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  19. package/packages/core/sdk/core.d.ts +224 -0
  20. package/packages/core/sdk/core.ts +694 -22
  21. package/packages/core/sdk/events.d.ts +89 -0
  22. package/packages/core/sdk/events.ts +128 -0
  23. package/packages/core/src/checker.ts +936 -15
  24. package/packages/core/src/cli.ts +156 -3
  25. package/packages/core/src/contract.ts +28 -5
  26. package/packages/core/src/devhost.ts +1876 -16
  27. package/packages/core/src/devhost_journal.mjs +183 -0
  28. package/packages/core/src/devhost_resolver.mjs +17 -1
  29. package/packages/core/src/devhost_service_worker.mjs +90 -0
  30. package/packages/core/src/diagnostics.ts +179 -22
  31. package/packages/core/src/frontend.ts +210 -34
  32. package/packages/core/src/infer.ts +24 -0
  33. package/packages/core/src/modules.ts +129 -80
  34. package/packages/core/src/service_contract.ts +597 -0
  35. package/packages/core/src/sqlite_cli.ts +93 -0
  36. package/packages/core/src/sqlite_codegen.ts +806 -0
  37. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  38. package/packages/core/src/typed_ast.ts +36 -8
  39. package/skill-data/automation/SKILL.md +1 -1
  40. package/skill-data/core/references/project-anatomy.md +1 -1
  41. package/skill-data/native-ui/SKILL.md +58 -5
  42. package/skill-data/ts-core/SKILL.md +123 -41
  43. package/skill-data/ts-services/SKILL.md +126 -0
  44. package/skill-data/ts-services/references/service-surface.md +604 -0
  45. package/skill-data/zig/SKILL.md +1 -1
  46. package/skills/native-sdk/SKILL.md +1 -1
  47. package/src/app_runner/no_migrations.zig +3 -0
  48. package/src/app_runner/no_services.zig +20 -0
  49. package/src/app_runner/root.zig +133 -4
  50. package/src/app_runner/ts_core_main.zig +254 -8
  51. package/src/app_runner/ts_core_mobile.zig +241 -0
  52. package/src/automation/protocol.zig +5 -1
  53. package/src/automation/snapshot.zig +31 -11
  54. package/src/embed/app_exports.zig +12 -1
  55. package/src/embed/c_api.zig +48 -2
  56. package/src/embed/conversions.zig +4 -5
  57. package/src/embed/host.zig +109 -1
  58. package/src/embed/root.zig +8 -0
  59. package/src/embed/tests.zig +241 -0
  60. package/src/embed/types.zig +51 -0
  61. package/src/embed/ui_host.zig +185 -5
  62. package/src/platform/android/NativeSdkActivity.java +131 -0
  63. package/src/platform/android/android_host.c +182 -1
  64. package/src/platform/android/native_sdk_app.h +17 -0
  65. package/src/platform/ios/native_sdk_app.h +17 -0
  66. package/src/platform/ios/uikit_host.m +115 -0
  67. package/src/platform/linux/cef_host.cpp +8 -2
  68. package/src/platform/linux/gtk_host.c +289 -22
  69. package/src/platform/linux/gtk_host.h +5 -1
  70. package/src/platform/linux/root.zig +109 -22
  71. package/src/platform/macos/appkit_host.h +24 -7
  72. package/src/platform/macos/appkit_host.m +686 -64
  73. package/src/platform/macos/cef_host.mm +400 -66
  74. package/src/platform/macos/root.zig +304 -47
  75. package/src/platform/null_platform.zig +435 -48
  76. package/src/platform/null_platform_tests.zig +113 -0
  77. package/src/platform/root.zig +19 -0
  78. package/src/platform/types.zig +281 -28
  79. package/src/platform/windows/root.zig +207 -27
  80. package/src/platform/windows/webview2_host.cpp +334 -51
  81. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  82. package/src/primitives/app_manifest/root.zig +4 -0
  83. package/src/primitives/app_manifest/tests.zig +3 -0
  84. package/src/primitives/app_manifest/types.zig +32 -0
  85. package/src/primitives/app_manifest/validation.zig +19 -1
  86. package/src/root.zig +53 -0
  87. package/src/runtime/api.zig +19 -0
  88. package/src/runtime/automation_commands.zig +35 -2
  89. package/src/runtime/automation_snapshot.zig +32 -20
  90. package/src/runtime/bridge_permission_tests.zig +58 -3
  91. package/src/runtime/bridge_responses.zig +4 -2
  92. package/src/runtime/builtin_bridge.zig +11 -1
  93. package/src/runtime/canvas_frame.zig +18 -11
  94. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  95. package/src/runtime/clock.zig +13 -1
  96. package/src/runtime/core.zig +145 -7
  97. package/src/runtime/credentials_store.zig +115 -0
  98. package/src/runtime/effects.zig +3701 -231
  99. package/src/runtime/effects_credentials_tests.zig +332 -0
  100. package/src/runtime/effects_file_tests.zig +587 -0
  101. package/src/runtime/effects_host_tests.zig +208 -1
  102. package/src/runtime/effects_notification_tests.zig +11 -0
  103. package/src/runtime/effects_relational_tests.zig +314 -0
  104. package/src/runtime/effects_store_tests.zig +211 -0
  105. package/src/runtime/file_access.zig +400 -0
  106. package/src/runtime/file_effect_crash_helper.zig +28 -0
  107. package/src/runtime/file_effect_crash_tests.zig +37 -0
  108. package/src/runtime/flow.zig +35 -10
  109. package/src/runtime/gpu_surface_events.zig +6 -1
  110. package/src/runtime/native_command_event_tests.zig +86 -2
  111. package/src/runtime/persist_store.zig +666 -0
  112. package/src/runtime/pty.zig +5 -2
  113. package/src/runtime/record_store.zig +788 -0
  114. package/src/runtime/relational_store.zig +854 -0
  115. package/src/runtime/root.zig +54 -0
  116. package/src/runtime/runtime_event_tests.zig +70 -0
  117. package/src/runtime/service_host.zig +711 -0
  118. package/src/runtime/service_pool.zig +1314 -0
  119. package/src/runtime/session_blobs.zig +4 -1
  120. package/src/runtime/session_journal.zig +158 -5
  121. package/src/runtime/session_record.zig +215 -0
  122. package/src/runtime/session_replay.zig +206 -11
  123. package/src/runtime/session_tests.zig +81 -0
  124. package/src/runtime/shell_layout.zig +1 -0
  125. package/src/runtime/shell_layout_tests.zig +120 -0
  126. package/src/runtime/sqlite_engine.zig +474 -0
  127. package/src/runtime/state.zig +16 -0
  128. package/src/runtime/system_services.zig +170 -38
  129. package/src/runtime/tests.zig +4 -0
  130. package/src/runtime/ts_core_host.zig +1067 -95
  131. package/src/runtime/ts_core_host_tests.zig +325 -11
  132. package/src/runtime/ts_ui_app.zig +953 -2
  133. package/src/runtime/ui_app.zig +434 -96
  134. package/src/runtime/ui_app_tests.zig +287 -11
  135. package/src/runtime/ui_app_window_tests.zig +61 -7
  136. package/src/runtime/validation.zig +42 -0
  137. package/src/runtime/view.zig +9 -0
  138. package/src/runtime/window_storage.zig +1 -0
  139. package/src/runtime/window_view_runtime.zig +2 -3
  140. package/src/runtime/window_views.zig +19 -0
  141. package/src/tooling/android.zig +21 -16
  142. package/src/tooling/db.zig +160 -0
  143. package/src/tooling/ios.zig +7 -1
  144. package/src/tooling/manifest.zig +214 -2
  145. package/src/tooling/package.zig +116 -0
  146. package/src/tooling/raw_manifest.zig +30 -0
  147. package/src/tooling/root.zig +1 -0
  148. package/src/tooling/templates.zig +189 -4
  149. package/src/tooling/ts_core.zig +366 -17
  150. package/src/tooling/verbs.zig +7 -0
  151. package/third_party/sqlite/README.md +13 -0
  152. package/third_party/sqlite/sqlite3.c +269649 -0
  153. package/third_party/sqlite/sqlite3.h +14349 -0
  154. package/tools/corewire/core_abi.zig +14 -2
  155. package/tools/corewire/emit.zig +98 -29
  156. package/tools/corewire/emit_facade.zig +442 -27
  157. package/tools/corewire/emit_profile.zig +6 -2
  158. package/tools/corewire/emit_service.zig +924 -0
  159. package/tools/corewire/main.zig +122 -0
  160. package/tools/corewire/service_contract.zig +250 -0
  161. package/tools/corewire/sidecar.zig +26 -15
@@ -41,7 +41,7 @@ const std = @import("std");
41
41
  /// The C-ABI generation these bindings implement. The generator refuses
42
42
  /// a sidecar declaring any other value; the generated shim re-checks the
43
43
  /// object's own getter at boot (the out-of-graph pairing backstop).
44
- pub const abi_version: u32 = 1;
44
+ pub const abi_version: u32 = 2;
45
45
 
46
46
  /// The snapshot-encoding generation the shim's decoder implements.
47
47
  pub const snapshot_format: u32 = 1;
@@ -80,7 +80,7 @@ pub const PanicSinkFn = *const fn (
80
80
  // any kind. One bytes return keeps the one-return-slot rule intact: the
81
81
  // multi-value result needs no marshalling shape of its own.
82
82
 
83
- /// The full symbol set of ABI version 1, bound under `prefix`. The
83
+ /// The full symbol set of ABI version 2, bound under `prefix`. The
84
84
  /// conditional channel entries are declared unconditionally here —
85
85
  /// `@extern` binds lazily, so a symbol is required at link time only
86
86
  /// when the generated shim actually references it, which it does
@@ -145,6 +145,18 @@ pub fn Bindings(comptime prefix: []const u8) type {
145
145
  /// init, or collect (arena truth — the buffer does NOT survive a
146
146
  /// frame reset; re-read after resetting).
147
147
  pub const model_snapshot = Symbol(fn (snap: *[*]const u8, snap_len: *usize) callconv(.c) void, "model_snapshot");
148
+ /// Borrow the tagged, length-delimited persistence snapshot. This is
149
+ /// deliberately separate from `model_snapshot`, whose positional
150
+ /// encoding is the hot-path core/shim ABI.
151
+ pub const persist_snapshot = Symbol(fn (snap: *[*]const u8, snap_len: *usize) callconv(.c) void, "persist_snapshot");
152
+ /// Replace the committed model from its canonical snapshot bytes.
153
+ /// The empty bytes return follows the compiler profile's one-return
154
+ /// convention; callers ignore it and re-snapshot the restored root.
155
+ pub const restore_model = Symbol(fn (snapshot: [*]const u8, snapshot_len: usize, out: *[*]const u8, out_len: *usize) callconv(.c) void, "restore_model");
156
+ /// Run the app's pure migration hook. The returned bytes are a
157
+ /// status prefix (1 success, 0 failure) plus the canonical current
158
+ /// Model snapshot on success.
159
+ pub const migrate_model = Symbol(fn (snapshot: [*]const u8, snapshot_len: usize, from_version: f64, out: *[*]const u8, out_len: *usize) callconv(.c) void, "migrate_model");
148
160
  /// Call the exported helper at `helper` (index into the
149
161
  /// sidecar's model_helpers). An unknown index is a generator/
150
162
  /// sidecar skew and TRAPS through the panic sink — it is never a
@@ -235,10 +235,12 @@ const Emitter = struct {
235
235
  fn validateEmissionNames(self: *Emitter) Error!void {
236
236
  var reserved: std.ArrayListUnmanaged([]const u8) = .empty;
237
237
  try reserved.appendSlice(self.arena, &.{
238
- "std", "shim_rt", "core_abi", "abi",
239
- "rt", "msg_tags", "boot", "initialModel",
240
- "update", "commitModelRoot", "sidecar_build_id", "sidecar_abi_version",
241
- "deterministic", "async_free", "snapshotModel", "referenceAttestedExports",
238
+ "std", "shim_rt", "core_abi", "abi",
239
+ "rt", "msg_tags", "boot", "initialModel",
240
+ "update", "commitModelRoot", "sidecar_build_id", "sidecar_model_fingerprint",
241
+ "sidecar_abi_version", "sidecar_snapshot_format", "deterministic", "async_free",
242
+ "snapshotModel", "modelSnapshot", "persistenceSnapshot", "restoreModel",
243
+ "referenceAttestedExports",
242
244
  });
243
245
  // Parameter and local names the generated bodies bind: a
244
246
  // module-level type under any of them would be shadowed, which
@@ -536,7 +538,9 @@ const Emitter = struct {
536
538
  \\/// fence (the out-of-graph backstop: a cached or hand-copied core
537
539
  \\/// must never dispatch against another build's tag order).
538
540
  \\pub const sidecar_build_id: u64 = 0x{x:0>16};
541
+ \\pub const sidecar_model_fingerprint: u64 = 0x{x:0>16};
539
542
  \\pub const sidecar_abi_version: u32 = {d};
543
+ \\pub const sidecar_snapshot_format: u32 = {d};
540
544
  \\
541
545
  \\/// The compiler's module-graph attestations, restated so host
542
546
  \\/// policy can gate on them: record/replay arms only against a
@@ -554,12 +558,21 @@ const Emitter = struct {
554
558
  \\ pub const Sub = []const u8;
555
559
  \\ pub const cmd_none: Cmd = &.{{}};
556
560
  \\ pub const sub_none: Sub = &.{{}};
561
+ \\ pub fn frameAllocator() std.mem.Allocator {{
562
+ \\ return shim_rt.frameAllocator();
563
+ \\ }}
557
564
  \\ pub fn frameAlloc(comptime T: type, n: usize) []T {{
558
565
  \\ return shim_rt.frameAlloc(T, n);
559
566
  \\ }}
560
567
  \\ pub fn frameCreate(comptime T: type, value: T) *T {{
561
568
  \\ return shim_rt.frameCreate(T, value);
562
569
  \\ }}
570
+ \\ pub fn decodeExact(comptime T: type, bytes: []const u8) T {{
571
+ \\ return shim_rt.decodeExact(T, bytes, shim_rt.frameAllocator());
572
+ \\ }}
573
+ \\ pub fn copyServiceBytes(bytes: []const u8) []const u8 {{
574
+ \\ return shim_rt.frameAllocator().dupe(u8, bytes) catch @panic("service result allocation failed");
575
+ \\ }}
563
576
  \\ pub fn frameReset() void {{
564
577
  \\ shim_rt.frameReset();
565
578
  \\ abi.frame_reset();
@@ -568,14 +581,15 @@ const Emitter = struct {
568
581
  \\ shim_rt.resetAll();
569
582
  \\ }}
570
583
  \\}};
571
- \\
572
584
  , .{
573
585
  try commentText(self.arena, self.sidecar.entry),
574
586
  try commentText(self.arena, self.sidecar.compiler_version),
575
587
  self.sidecar.build_id,
576
588
  std.zig.fmtString(self.sidecar.abi.prefix),
577
589
  self.sidecar.build_id,
590
+ self.sidecar.model_fingerprint,
578
591
  self.sidecar.abi_version,
592
+ self.sidecar.abi.snapshot_format,
579
593
  self.sidecar.deterministic,
580
594
  self.sidecar.async_free,
581
595
  });
@@ -939,12 +953,16 @@ const Emitter = struct {
939
953
  \\
940
954
  \\pub const InitResult = struct {{ model: *const {s}, cmd: rt.Cmd }};
941
955
  \\
942
- \\pub fn initialModel() InitResult {{
943
- \\ boot();
956
+ \\pub fn bootCommand() rt.Cmd {{
944
957
  \\ var cmd_ptr: [*]const u8 = undefined;
945
958
  \\ var cmd_len: usize = 0;
946
959
  \\ abi.boot_cmd(&cmd_ptr, &cmd_len);
947
- \\ return .{{ .model = snapshotModel(), .cmd = cmd_ptr[0..cmd_len] }};
960
+ \\ return cmd_ptr[0..cmd_len];
961
+ \\}}
962
+ \\
963
+ \\pub fn initialModel() InitResult {{
964
+ \\ boot();
965
+ \\ return .{{ .model = snapshotModel(), .cmd = bootCommand() }};
948
966
  \\}}
949
967
  \\
950
968
  , .{model_name});
@@ -1304,19 +1322,58 @@ const Emitter = struct {
1304
1322
  fn snapshotPlumbing(self: *Emitter) Error!void {
1305
1323
  try self.print(
1306
1324
  \\
1307
- \\/// Decode the committed model from the core's snapshot buffer
1308
- \\/// (canonical value encoding of the root record, snapshot format
1309
- \\/// {d}). The decoded mirror lives in the shim's model arena until
1310
- \\/// the next snapshot — it must survive frame resets, exactly as the
1311
- \\/// transpiler lane's committed heap does.
1312
- \\fn snapshotModel() *const {f} {{
1325
+ \\/// Borrow the compiled core's positional model-mirror bytes.
1326
+ \\/// Valid until the next core ABI call.
1327
+ \\pub fn modelSnapshot() []const u8 {{
1313
1328
  \\ var snap_ptr: [*]const u8 = undefined;
1314
1329
  \\ var snap_len: usize = 0;
1315
1330
  \\ abi.model_snapshot(&snap_ptr, &snap_len);
1316
- \\ return shim_rt.decodeSnapshot({f}, snap_ptr[0..snap_len]);
1331
+ \\ return snap_ptr[0..snap_len];
1332
+ \\}}
1333
+ \\
1334
+ \\/// Borrow the tagged, length-delimited durable snapshot
1335
+ \\/// (persistence snapshot format {d}). Valid until the next core
1336
+ \\/// ABI call.
1337
+ \\pub fn persistenceSnapshot() []const u8 {{
1338
+ \\ var snap_ptr: [*]const u8 = undefined;
1339
+ \\ var snap_len: usize = 0;
1340
+ \\ abi.persist_snapshot(&snap_ptr, &snap_len);
1341
+ \\ return snap_ptr[0..snap_len];
1342
+ \\}}
1343
+ \\
1344
+ \\/// Decode the committed model into the shim read arena.
1345
+ \\fn snapshotModel() *const {f} {{
1346
+ \\ return shim_rt.decodeSnapshot({f}, modelSnapshot());
1347
+ \\}}
1348
+ \\
1349
+ \\/// Replace the compiled core's committed model, then refresh the
1350
+ \\/// read-arena mirror returned to the host.
1351
+ \\pub fn restoreModel(snapshot: []const u8) *const {f} {{
1352
+ \\ var out_ptr: [*]const u8 = undefined;
1353
+ \\ var out_len: usize = 0;
1354
+ \\ abi.restore_model(snapshot.ptr, snapshot.len, &out_ptr, &out_len);
1355
+ \\ if (out_len != 0) @panic("core_shim: restore_model returned bytes; ABI version 2 requires an empty result");
1356
+ \\ return snapshotModel();
1317
1357
  \\}}
1318
1358
  \\
1319
- , .{ self.sidecar.abi.snapshot_format, ident(self.sidecar.model), ident(self.sidecar.model) });
1359
+ \\
1360
+ \\/// Run the app's pure migration hook and copy the resulting
1361
+ \\/// current-format snapshot out of the core result arena. Null is
1362
+ \\/// the hook's closed failure result (including no hook).
1363
+ \\pub fn migrateModel(snapshot: []const u8, from_version: u64, allocator: std.mem.Allocator) ?[]u8 {{
1364
+ \\ var out_ptr: [*]const u8 = undefined;
1365
+ \\ var out_len: usize = 0;
1366
+ \\ abi.migrate_model(snapshot.ptr, snapshot.len, @floatFromInt(from_version), &out_ptr, &out_len);
1367
+ \\ if (out_len < 1 or out_ptr[0] != 1) return null;
1368
+ \\ return allocator.dupe(u8, out_ptr[1..out_len]) catch null;
1369
+ \\}}
1370
+ \\
1371
+ , .{
1372
+ self.sidecar.abi.snapshot_format,
1373
+ ident(self.sidecar.model),
1374
+ ident(self.sidecar.model),
1375
+ ident(self.sidecar.model),
1376
+ });
1320
1377
  }
1321
1378
  };
1322
1379
 
@@ -1548,6 +1605,17 @@ test "emission is deterministic and carries the mirror surface" {
1548
1605
  // A bare-model init emits the pointer-returning shape.
1549
1606
  try testing.expect(std.mem.indexOf(u8, first, "pub fn initialModel() *const Model {") != null);
1550
1607
  try testing.expect(std.mem.indexOf(u8, first, "pub const UpdateResult = struct { model: *const Model, cmd: rt.Cmd };") != null);
1608
+
1609
+ const command_init_source = try std.mem.replaceOwned(
1610
+ u8,
1611
+ arena,
1612
+ sidecar_mod.minimal_valid_json,
1613
+ "\"init_returns_cmd\": false",
1614
+ "\"init_returns_cmd\": true",
1615
+ );
1616
+ const command_init = try emitFromJson(arena, command_init_source);
1617
+ try testing.expect(std.mem.indexOf(u8, command_init, "pub fn bootCommand() rt.Cmd {") != null);
1618
+ try testing.expect(std.mem.indexOf(u8, command_init, ".cmd = bootCommand()") != null);
1551
1619
  }
1552
1620
 
1553
1621
  test "u64-attested slots generate the unsigned twin; i64 and f64 slots are untouched" {
@@ -1696,9 +1764,9 @@ test "a u64 attestation on chrome geometry refuses at check time" {
1696
1764
  // class cannot carry.
1697
1765
  const source =
1698
1766
  \\{
1699
- \\ "format": 1, "wire_version": 3, "abi_version": 1,
1767
+ \\ "format": 1, "wire_version": 7, "abi_version": 2,
1700
1768
  \\ "compiler_version": "0.0.1", "entry": "src/core.ts",
1701
- \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface",
1769
+ \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface", "model_fingerprint": "00000000a11ce001",
1702
1770
  \\ "types": {
1703
1771
  \\ "structs": [
1704
1772
  \\ {"name": "Model", "fields": [{"name": "chromeTop", "type": {"kind": "f64"}}]},
@@ -1722,14 +1790,14 @@ test "a u64 attestation on chrome geometry refuses at check time" {
1722
1790
  \\ "msg": {"name": "Msg", "arms": [
1723
1791
  \\ {"name": "chrome_changed", "payload": {"kind": "record", "name": "Msg_chrome_changed"}}
1724
1792
  \\ ], "unbound": []},
1725
- \\ "init_returns_cmd": false, "update_returns_cmd": true, "has_subscriptions": false,
1793
+ \\ "init_returns_cmd": false, "update_returns_cmd": true, "has_subscriptions": false, "has_migrate": false,
1726
1794
  \\ "channels": {"command_msg": false, "frame_msg": false, "key_msg": false, "pinch_msg": false, "drop_msg": false,
1727
1795
  \\ "appearance_msg": null, "chrome_msg": "chrome_changed", "env_msgs": []},
1728
1796
  \\ "abi": {"prefix": "nsc_core_", "exports": ["abi_version", "build_id", "set_panic_sink", "init",
1729
1797
  \\ "collect", "frame_reset", "boot_cmd", "dispatch_void", "dispatch_bytes", "dispatch_number",
1730
1798
  \\ "dispatch_number_bytes", "dispatch_bool", "dispatch_enum", "dispatch_record",
1731
1799
  \\ "dispatch_text_input", "dispatch_scroll_state", "subscriptions", "model_snapshot",
1732
- \\ "helper_call"], "snapshot_format": 1},
1800
+ \\ "persist_snapshot", "restore_model", "migrate_model", "helper_call"], "snapshot_format": 1},
1733
1801
  \\ "integer_slots": [{"slot": "Buttons.x", "class": "u64"}],
1734
1802
  \\ "deterministic": true, "async_free": true
1735
1803
  \\}
@@ -1836,7 +1904,8 @@ test "the empty integer_slots list decodes nothing differently" {
1836
1904
  // (the identity constants' own u64 plumbing is not a mirror slot).
1837
1905
  try testing.expect(std.mem.indexOf(u8, generated, "exactF64") == null);
1838
1906
  try testing.expect(std.mem.indexOf(u8, generated, ": i64,") == null);
1839
- try testing.expect(std.mem.indexOf(u8, generated, ": u64,") == null);
1907
+ try testing.expect(std.mem.indexOf(u8, generated, "count: u64,") == null);
1908
+ try testing.expect(std.mem.indexOf(u8, generated, "picked: u64,") == null);
1840
1909
  }
1841
1910
 
1842
1911
  test "the emitted shim parses as Zig" {
@@ -1876,9 +1945,9 @@ test "a shared authored type spelling like a synthesized name stays a top-level
1876
1945
  // first site would leave the second dangling.
1877
1946
  const source =
1878
1947
  \\{
1879
- \\ "format": 1, "wire_version": 3, "abi_version": 1,
1948
+ \\ "format": 1, "wire_version": 7, "abi_version": 2,
1880
1949
  \\ "compiler_version": "0.0.1", "entry": "src/core.ts",
1881
- \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface",
1950
+ \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface", "model_fingerprint": "00000000a11ce001",
1882
1951
  \\ "types": {
1883
1952
  \\ "structs": [
1884
1953
  \\ {"name": "Model_user", "fields": [{"name": "id", "type": {"kind": "f64"}}]},
@@ -1891,14 +1960,14 @@ test "a shared authored type spelling like a synthesized name stays a top-level
1891
1960
  \\ },
1892
1961
  \\ "model": "Model", "model_helpers": [], "model_unbound": [],
1893
1962
  \\ "msg": {"name": "Msg", "arms": [{"name": "bump", "payload": {"kind": "void"}}], "unbound": []},
1894
- \\ "init_returns_cmd": false, "update_returns_cmd": true, "has_subscriptions": false,
1963
+ \\ "init_returns_cmd": false, "update_returns_cmd": true, "has_subscriptions": false, "has_migrate": false,
1895
1964
  \\ "channels": {"command_msg": false, "frame_msg": false, "key_msg": false, "pinch_msg": false, "drop_msg": false,
1896
1965
  \\ "appearance_msg": null, "chrome_msg": null, "env_msgs": []},
1897
1966
  \\ "abi": {"prefix": "nsc_core_", "exports": ["abi_version", "build_id", "set_panic_sink", "init",
1898
1967
  \\ "collect", "frame_reset", "boot_cmd", "dispatch_void", "dispatch_bytes", "dispatch_number",
1899
1968
  \\ "dispatch_number_bytes", "dispatch_bool", "dispatch_enum", "dispatch_record",
1900
1969
  \\ "dispatch_text_input", "dispatch_scroll_state", "subscriptions", "model_snapshot",
1901
- \\ "helper_call"], "snapshot_format": 1},
1970
+ \\ "persist_snapshot", "restore_model", "migrate_model", "helper_call"], "snapshot_format": 1},
1902
1971
  \\ "integer_slots": [], "deterministic": true, "async_free": true
1903
1972
  \\}
1904
1973
  ;
@@ -2312,9 +2381,9 @@ test "a chrome arm holding its insets by reference refuses" {
2312
2381
  // node (by-reference) insets record cannot take that construction.
2313
2382
  const source =
2314
2383
  \\{
2315
- \\ "format": 1, "wire_version": 3, "abi_version": 1,
2384
+ \\ "format": 1, "wire_version": 7, "abi_version": 2,
2316
2385
  \\ "compiler_version": "0.0.1", "entry": "src/core.ts",
2317
- \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface",
2386
+ \\ "source_hash": "00000000c0ffee00", "build_id": "00000000b01dface", "model_fingerprint": "00000000a11ce001",
2318
2387
  \\ "types": {
2319
2388
  \\ "structs": [
2320
2389
  \\ {"name": "Model", "fields": [{"name": "chromeTop", "type": {"kind": "f64"}}]},
@@ -2338,14 +2407,14 @@ test "a chrome arm holding its insets by reference refuses" {
2338
2407
  \\ "msg": {"name": "Msg", "arms": [
2339
2408
  \\ {"name": "chrome_changed", "payload": {"kind": "record", "name": "Msg_chrome_changed"}}
2340
2409
  \\ ], "unbound": []},
2341
- \\ "init_returns_cmd": false, "update_returns_cmd": true, "has_subscriptions": false,
2410
+ \\ "init_returns_cmd": false, "update_returns_cmd": true, "has_subscriptions": false, "has_migrate": false,
2342
2411
  \\ "channels": {"command_msg": false, "frame_msg": false, "key_msg": false, "pinch_msg": false, "drop_msg": false,
2343
2412
  \\ "appearance_msg": null, "chrome_msg": "chrome_changed", "env_msgs": []},
2344
2413
  \\ "abi": {"prefix": "nsc_core_", "exports": ["abi_version", "build_id", "set_panic_sink", "init",
2345
2414
  \\ "collect", "frame_reset", "boot_cmd", "dispatch_void", "dispatch_bytes", "dispatch_number",
2346
2415
  \\ "dispatch_number_bytes", "dispatch_bool", "dispatch_enum", "dispatch_record",
2347
2416
  \\ "dispatch_text_input", "dispatch_scroll_state", "subscriptions", "model_snapshot",
2348
- \\ "helper_call"], "snapshot_format": 1},
2417
+ \\ "persist_snapshot", "restore_model", "migrate_model", "helper_call"], "snapshot_format": 1},
2349
2418
  \\ "integer_slots": [], "deterministic": true, "async_free": true
2350
2419
  \\}
2351
2420
  ;