@native-sdk/cli 0.8.4 → 0.9.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.
Files changed (146) hide show
  1. package/build/app.zig +859 -62
  2. package/build.zig +543 -13
  3. package/build.zig.zon +1 -0
  4. package/native-sdk.d.ts +2 -0
  5. package/package.json +12 -11
  6. package/packages/core/compile-surface/core.ts +365 -2
  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/npm_static_spike.mjs +64 -0
  12. package/packages/core/scripts/run_external_core_compiler.mjs +77 -6
  13. package/packages/core/scripts/run_external_service_compiler.mjs +240 -0
  14. package/packages/core/scripts/stage_external_core.mjs +9 -1
  15. package/packages/core/scripts/stage_external_services.mjs +172 -0
  16. package/packages/core/scripts/surface_manifest_diff.mjs +253 -0
  17. package/packages/core/scripts/vendor_service_packages.mjs +189 -0
  18. package/packages/core/sdk/core.d.ts +149 -0
  19. package/packages/core/sdk/core.ts +529 -12
  20. package/packages/core/sdk/events.d.ts +36 -0
  21. package/packages/core/sdk/events.ts +57 -0
  22. package/packages/core/src/checker.ts +468 -15
  23. package/packages/core/src/cli.ts +143 -3
  24. package/packages/core/src/contract.ts +26 -5
  25. package/packages/core/src/devhost.ts +1847 -16
  26. package/packages/core/src/devhost_journal.mjs +181 -0
  27. package/packages/core/src/devhost_resolver.mjs +17 -1
  28. package/packages/core/src/devhost_service_worker.mjs +90 -0
  29. package/packages/core/src/diagnostics.ts +82 -16
  30. package/packages/core/src/frontend.ts +204 -34
  31. package/packages/core/src/modules.ts +129 -80
  32. package/packages/core/src/service_contract.ts +597 -0
  33. package/packages/core/src/sqlite_cli.ts +93 -0
  34. package/packages/core/src/sqlite_codegen.ts +806 -0
  35. package/packages/core/src/sqlite_runtime_policy.ts +364 -0
  36. package/packages/core/src/typed_ast.ts +36 -8
  37. package/skill-data/core/references/project-anatomy.md +1 -1
  38. package/skill-data/native-ui/SKILL.md +47 -0
  39. package/skill-data/ts-core/SKILL.md +80 -31
  40. package/skill-data/ts-services/SKILL.md +126 -0
  41. package/skill-data/ts-services/references/service-surface.md +603 -0
  42. package/skill-data/zig/SKILL.md +1 -1
  43. package/skills/native-sdk/SKILL.md +1 -1
  44. package/src/app_runner/no_migrations.zig +3 -0
  45. package/src/app_runner/no_services.zig +20 -0
  46. package/src/app_runner/root.zig +104 -4
  47. package/src/app_runner/ts_core_main.zig +249 -8
  48. package/src/automation/snapshot.zig +23 -5
  49. package/src/embed/app_exports.zig +11 -1
  50. package/src/embed/c_api.zig +48 -2
  51. package/src/embed/conversions.zig +4 -5
  52. package/src/embed/host.zig +109 -1
  53. package/src/embed/root.zig +7 -0
  54. package/src/embed/tests.zig +213 -0
  55. package/src/embed/types.zig +51 -0
  56. package/src/embed/ui_host.zig +119 -5
  57. package/src/platform/android/NativeSdkActivity.java +131 -0
  58. package/src/platform/android/android_host.c +182 -1
  59. package/src/platform/android/native_sdk_app.h +17 -0
  60. package/src/platform/ios/native_sdk_app.h +17 -0
  61. package/src/platform/ios/uikit_host.m +115 -0
  62. package/src/platform/linux/cef_host.cpp +1 -1
  63. package/src/platform/linux/gtk_host.c +89 -17
  64. package/src/platform/linux/gtk_host.h +3 -0
  65. package/src/platform/linux/root.zig +40 -18
  66. package/src/platform/macos/appkit_host.h +16 -3
  67. package/src/platform/macos/appkit_host.m +536 -36
  68. package/src/platform/macos/cef_host.mm +248 -36
  69. package/src/platform/macos/root.zig +244 -34
  70. package/src/platform/null_platform.zig +223 -19
  71. package/src/platform/null_platform_tests.zig +74 -0
  72. package/src/platform/root.zig +9 -0
  73. package/src/platform/types.zig +179 -15
  74. package/src/platform/windows/root.zig +187 -21
  75. package/src/platform/windows/webview2_host.cpp +293 -46
  76. package/src/primitives/app_manifest/comptime_scene.zig +2 -0
  77. package/src/primitives/app_manifest/root.zig +4 -0
  78. package/src/primitives/app_manifest/tests.zig +3 -0
  79. package/src/primitives/app_manifest/types.zig +32 -0
  80. package/src/primitives/app_manifest/validation.zig +19 -1
  81. package/src/root.zig +46 -0
  82. package/src/runtime/api.zig +11 -0
  83. package/src/runtime/automation_snapshot.zig +4 -0
  84. package/src/runtime/bridge_permission_tests.zig +23 -2
  85. package/src/runtime/bridge_responses.zig +3 -1
  86. package/src/runtime/canvas_frame.zig +18 -11
  87. package/src/runtime/canvas_frame_animation_tests.zig +4 -0
  88. package/src/runtime/clock.zig +13 -1
  89. package/src/runtime/core.zig +133 -1
  90. package/src/runtime/credentials_store.zig +115 -0
  91. package/src/runtime/effects.zig +2295 -113
  92. package/src/runtime/effects_credentials_tests.zig +332 -0
  93. package/src/runtime/effects_host_tests.zig +208 -1
  94. package/src/runtime/effects_relational_tests.zig +314 -0
  95. package/src/runtime/effects_store_tests.zig +211 -0
  96. package/src/runtime/flow.zig +14 -1
  97. package/src/runtime/gpu_surface_events.zig +6 -1
  98. package/src/runtime/native_command_event_tests.zig +42 -0
  99. package/src/runtime/persist_store.zig +666 -0
  100. package/src/runtime/record_store.zig +788 -0
  101. package/src/runtime/relational_store.zig +854 -0
  102. package/src/runtime/root.zig +49 -0
  103. package/src/runtime/runtime_event_tests.zig +70 -0
  104. package/src/runtime/service_host.zig +711 -0
  105. package/src/runtime/service_pool.zig +1314 -0
  106. package/src/runtime/session_blobs.zig +1 -1
  107. package/src/runtime/session_journal.zig +102 -0
  108. package/src/runtime/session_record.zig +177 -0
  109. package/src/runtime/session_replay.zig +109 -4
  110. package/src/runtime/shell_layout.zig +1 -0
  111. package/src/runtime/shell_layout_tests.zig +120 -0
  112. package/src/runtime/sqlite_engine.zig +474 -0
  113. package/src/runtime/state.zig +6 -0
  114. package/src/runtime/system_services.zig +49 -10
  115. package/src/runtime/tests.zig +4 -0
  116. package/src/runtime/ts_core_host.zig +788 -86
  117. package/src/runtime/ts_core_host_tests.zig +231 -11
  118. package/src/runtime/ts_ui_app.zig +499 -1
  119. package/src/runtime/ui_app.zig +142 -16
  120. package/src/runtime/ui_app_tests.zig +155 -5
  121. package/src/runtime/validation.zig +22 -0
  122. package/src/runtime/view.zig +9 -0
  123. package/src/runtime/window_storage.zig +1 -0
  124. package/src/runtime/window_view_runtime.zig +2 -3
  125. package/src/runtime/window_views.zig +19 -0
  126. package/src/tooling/android.zig +21 -16
  127. package/src/tooling/db.zig +160 -0
  128. package/src/tooling/ios.zig +7 -1
  129. package/src/tooling/manifest.zig +214 -2
  130. package/src/tooling/package.zig +116 -0
  131. package/src/tooling/raw_manifest.zig +30 -0
  132. package/src/tooling/root.zig +1 -0
  133. package/src/tooling/templates.zig +161 -4
  134. package/src/tooling/ts_core.zig +283 -17
  135. package/src/tooling/verbs.zig +7 -0
  136. package/third_party/sqlite/README.md +13 -0
  137. package/third_party/sqlite/sqlite3.c +269649 -0
  138. package/third_party/sqlite/sqlite3.h +14349 -0
  139. package/tools/corewire/core_abi.zig +14 -2
  140. package/tools/corewire/emit.zig +98 -29
  141. package/tools/corewire/emit_facade.zig +378 -23
  142. package/tools/corewire/emit_profile.zig +6 -2
  143. package/tools/corewire/emit_service.zig +924 -0
  144. package/tools/corewire/main.zig +122 -0
  145. package/tools/corewire/service_contract.zig +250 -0
  146. package/tools/corewire/sidecar.zig +26 -15
@@ -12,7 +12,7 @@ Two rules resolve most failures:
12
12
  - Operations on the outside world take a `std.Io` first (or right after the receiver). Get one from `init.io` in `main(init: std.process.Init)`, from `std.testing.io` in tests, or from `std.Io.Threaded` in code with no `Init` to thread through.
13
13
  - Containers are unmanaged: initialize with `.empty` and pass the allocator to every mutating call.
14
14
 
15
- In a UiApp, `update` never sees an `Io` — persistence, subprocesses, HTTP, clocks, and timers go through the typed effects channel (`fx.readFile`, `fx.spawn`, `fx.fetch`, `fx.wallMs`, `fx.startTimer`; see `native skills get native-ui`). Raw `std.Io` belongs in `main`, tests, and standalone tools. And because Zig analyzes lazily, a 0.15-ism can hide in code only one build path references: run BOTH `zig build` and `zig build test` before calling a change done.
15
+ In a UiApp, `update` never sees an `Io` — persistence, record and relational storage, secure credentials, subprocesses, HTTP, clocks, and timers go through the typed effects channel (`fx.persist`, `fx.storeSet`/`storeGet`/`storeDelete`/`storeScan`/`storeSetMany`, `fx.dbQuery`/`dbExec`, `fx.credentialsSet`/`credentialsGet`/`credentialsDelete`, `fx.readFile`, `fx.spawn`, `fx.fetch`, `fx.wallMs`, `fx.startTimer`; see `native skills get native-ui`). Raw `std.Io` belongs in `main`, tests, and standalone tools. Record-store apps declare `"store"`; relational apps declare `"sqlite"`; credentials require both the `"credentials"` capability and permission. Credential Msg arms carry `EffectCredentialsResult`; consume successful get bytes immediately and never retain them in Model. The engine owns database paths and app-scoped credential namespaces, while every result still returns as a Msg and crosses the replay journal (credential bytes are redacted). Use `TestHarness().createWithRelationalStore` for a hermetic in-memory relational database and `TestHarness().createWithCredentials` for a hermetic in-memory credential store. And because Zig analyzes lazily, a 0.15-ism can hide in code only one build path references: run BOTH `zig build` and `zig build test` before calling a change done.
16
16
 
17
17
  ## error: struct 'heap' has no member named 'GeneralPurposeAllocator' — allocators come from `main(init: std.process.Init)`
18
18
 
@@ -20,7 +20,7 @@ native skills get native-ui
20
20
  native skills get ts-core
21
21
  ```
22
22
 
23
- Use `native skills get core` for initial orientation. For the default app-authoring path, load **both** `native-ui` (views, bindings, the app loop) and `ts-core` (the TypeScript subset, effects, subscriptions, and modules) before implementing. Use `native skills get core --full` when work reaches lower-level runtime wiring, WebViews, bridge/security, native capabilities, packaging, or debugging. Use `native skills get automation` when testing a running app, taking snapshots, requesting reloads, or using the built-in automation server. Use `native skills get zig` only for an existing Zig core, a toolkit extension, SDK implementation work, or a Zig 0.16 compile error.
23
+ Use `native skills get core` for initial orientation. For the default app-authoring path, load **both** `native-ui` (views, bindings, the app loop) and `ts-core` (the TypeScript subset, effects, subscriptions, and modules) before implementing. Load `ts-services` too when the tree has `src/services/` or ordinary TypeScript needs filesystem/process/JSON/regex/Map/Date/class work behind `Cmd.request`. Use `native skills get core --full` when work reaches lower-level runtime wiring, WebViews, bridge/security, native capabilities, packaging, or debugging. Use `native skills get automation` when testing a running app, taking snapshots, requesting reloads, or using the built-in automation server. Use `native skills get zig` only for an existing Zig core, a toolkit extension, SDK implementation work, or a Zig 0.16 compile error.
24
24
 
25
25
  ## Quick orientation
26
26
 
@@ -0,0 +1,3 @@
1
+ const relational = @import("native_sdk").relational_store;
2
+
3
+ pub const migrations = [_]relational.Migration{};
@@ -0,0 +1,20 @@
1
+ //! Generated-runner stub for apps without src/services/.
2
+ pub const enabled = false;
3
+ pub const protocol_version: u8 = 3;
4
+ pub const compiler_version = "";
5
+ pub const inproc_symbol_prefix = "nsc_svc_";
6
+ pub const contract_fingerprint = [_]u8{0} ** 32;
7
+ pub const Operation = struct { name: []const u8, index: u16, deadline_ms: ?u32, cancellable: bool, streaming: bool, in_flight: u8 };
8
+ pub const operations = [_]Operation{};
9
+ pub fn indexOf(name: []const u8) ?u16 {
10
+ _ = name;
11
+ return null;
12
+ }
13
+ pub fn operationAt(index: u16) ?Operation {
14
+ _ = index;
15
+ return null;
16
+ }
17
+ pub fn isStreaming(index: u16) bool {
18
+ _ = index;
19
+ return false;
20
+ }
@@ -2,6 +2,7 @@ const std = @import("std");
2
2
  const build_options = @import("build_options");
3
3
  const native_sdk = @import("native_sdk");
4
4
  const app_manifest = @import("app_manifest_zon");
5
+ const built_relational_migrations = @import("relational_migrations");
5
6
  const manifest_shortcuts = if (@hasField(@TypeOf(app_manifest), "shortcuts")) app_manifest.shortcuts else .{};
6
7
  const manifest_windows = if (@hasField(@TypeOf(app_manifest), "windows")) app_manifest.windows else .{};
7
8
 
@@ -54,6 +55,13 @@ pub const RunOptions = struct {
54
55
  security: native_sdk.SecurityPolicy = .{},
55
56
  menus: []const native_sdk.Menu = &.{},
56
57
  shortcuts: ?[]const native_sdk.Shortcut = null,
58
+ /// Filled by `runWithOptions` from the manifest capability. App entry
59
+ /// points do not set this themselves; the field only carries the owned
60
+ /// binding uniformly into each platform's runtime options.
61
+ record_store: ?native_sdk.RecordStoreBinding = null,
62
+ relational_store: ?native_sdk.RelationalStoreBinding = null,
63
+ credentials_enabled: bool = false,
64
+ relational_migrations: []const native_sdk.relational_store.Migration = &built_relational_migrations.migrations,
57
65
 
58
66
  fn appInfo(self: RunOptions, buffers: *StateBuffers) native_sdk.AppInfo {
59
67
  var info: native_sdk.AppInfo = .{
@@ -98,6 +106,7 @@ pub const RunOptions = struct {
98
106
  info.main_window.always_on_top = manifestShellStartupBool("always_on_top", false);
99
107
  info.main_window.click_through = manifestShellStartupBool("click_through", false);
100
108
  info.main_window.activate_on_show = manifestShellStartupBool("activate_on_show", true);
109
+ info.main_window.allows_fullscreen = manifestShellStartupBool("allows_fullscreen", true);
101
110
  // Min-size floors ride the create call like the titlebar:
102
111
  // the scene re-applies size/title later, but the window's
103
112
  // enforced floor is host state from the first frame on.
@@ -164,10 +173,12 @@ fn manifestWindow(comptime window: anytype, comptime index: usize) native_sdk.Wi
164
173
  .restore_state = windowBool(window, "restore_state", true),
165
174
  .restore_policy = windowRestorePolicy(window),
166
175
  .titlebar = windowTitlebarStyle(window),
176
+ .show = if (windowBool(window, "initially_hidden", false)) .hidden else .immediate,
167
177
  .transparent = windowBool(window, "transparent", false),
168
178
  .always_on_top = windowBool(window, "always_on_top", false),
169
179
  .click_through = windowBool(window, "click_through", false),
170
180
  .activate_on_show = windowBool(window, "activate_on_show", true),
181
+ .allows_fullscreen = windowBool(window, "allows_fullscreen", true),
171
182
  .min_width = windowMinSize(window, "min_width"),
172
183
  .min_height = windowMinSize(window, "min_height"),
173
184
  .close_policy = windowClosePolicy(window),
@@ -259,6 +270,7 @@ fn manifestShellStartupShowMode() native_sdk.WindowShowMode {
259
270
  if (comptime !@hasField(@TypeOf(shell), "windows")) return .immediate;
260
271
  if (comptime shell.windows.len == 0) return .immediate;
261
272
  const window = shell.windows[0];
273
+ if (comptime windowBool(window, "initially_hidden", false)) return .hidden;
262
274
  if (comptime !@hasField(@TypeOf(window), "views")) return .immediate;
263
275
  inline for (window.views) |view| {
264
276
  if (comptime @hasField(@TypeOf(view), "kind")) {
@@ -431,6 +443,35 @@ fn manifestDeclaresTrayCapability() bool {
431
443
  return false;
432
444
  }
433
445
 
446
+ /// Whether app.zon declares the Tier-2 record store. This is comptime so
447
+ /// apps without the capability never analyze the SQLite open/deinit path.
448
+ fn manifestDeclaresStore() bool {
449
+ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
450
+ inline for (app_manifest.capabilities) |capability| {
451
+ const name: []const u8 = capability;
452
+ if (comptime std.mem.eql(u8, name, "store")) return true;
453
+ }
454
+ return false;
455
+ }
456
+
457
+ fn manifestDeclaresSqlite() bool {
458
+ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
459
+ inline for (app_manifest.capabilities) |capability| {
460
+ const name: []const u8 = capability;
461
+ if (comptime std.mem.eql(u8, name, "sqlite")) return true;
462
+ }
463
+ return false;
464
+ }
465
+
466
+ fn manifestDeclaresCredentials() bool {
467
+ if (comptime !@hasField(@TypeOf(app_manifest), "capabilities")) return false;
468
+ inline for (app_manifest.capabilities) |capability| {
469
+ const name: []const u8 = capability;
470
+ if (comptime std.mem.eql(u8, name, "credentials")) return true;
471
+ }
472
+ return false;
473
+ }
474
+
434
475
  fn shortcutModifiers(comptime shortcut: anytype) native_sdk.ShortcutModifiers {
435
476
  const values = if (@hasField(@TypeOf(shortcut), "modifiers")) shortcut.modifiers else .{};
436
477
  var modifiers: native_sdk.ShortcutModifiers = .{};
@@ -462,14 +503,61 @@ pub fn runWithOptions(app: native_sdk.App, options: RunOptions, init: std.proces
462
503
  if (init.environ_map.get("NATIVE_SDK_SESSION_REPLAY")) |journal_path| {
463
504
  return runSessionReplay(app, options, init, journal_path);
464
505
  }
506
+ const RecordStoreType = if (comptime manifestDeclaresStore()) native_sdk.RecordStore else void;
507
+ var record_store_value: RecordStoreType = undefined;
508
+ var record_store_open = false;
509
+ var resolved_options = options;
510
+ resolved_options.credentials_enabled = manifestDeclaresCredentials();
511
+ if (comptime manifestDeclaresStore()) {
512
+ var data_dir_buffer: [512]u8 = undefined;
513
+ const app_data_dir = native_sdk.app_dirs.resolveOne(
514
+ .{ .name = options.bundle_id },
515
+ native_sdk.app_dirs.currentPlatform(),
516
+ native_sdk.debug.envFromMap(init.environ_map),
517
+ .data,
518
+ &data_dir_buffer,
519
+ ) catch return error.StoreDataDirUnavailable;
520
+ try std.Io.Dir.cwd().createDirPath(init.io, app_data_dir);
521
+ record_store_value = try native_sdk.RecordStore.open(std.heap.page_allocator, app_data_dir);
522
+ record_store_open = true;
523
+ resolved_options.record_store = record_store_value.binding();
524
+ }
525
+ defer if (comptime manifestDeclaresStore()) {
526
+ if (record_store_open) record_store_value.deinit();
527
+ };
528
+ const RelationalStoreType = if (comptime manifestDeclaresSqlite()) native_sdk.RelationalStore else void;
529
+ var relational_store_value: RelationalStoreType = undefined;
530
+ var relational_store_open = false;
531
+ if (comptime manifestDeclaresSqlite()) {
532
+ var data_dir_buffer: [512]u8 = undefined;
533
+ const app_data_dir = native_sdk.app_dirs.resolveOne(
534
+ .{ .name = options.bundle_id },
535
+ native_sdk.app_dirs.currentPlatform(),
536
+ native_sdk.debug.envFromMap(init.environ_map),
537
+ .data,
538
+ &data_dir_buffer,
539
+ ) catch return error.SqliteDataDirUnavailable;
540
+ try std.Io.Dir.cwd().createDirPath(init.io, app_data_dir);
541
+ const open_result = try native_sdk.RelationalStore.openMigrated(std.heap.page_allocator, app_data_dir, options.relational_migrations);
542
+ switch (open_result.outcome) {
543
+ .ok => relational_store_value = open_result.database.?,
544
+ .migrate_failed => return error.SqliteMigrationFailed,
545
+ .version_unknown => return error.SqliteVersionUnknown,
546
+ }
547
+ relational_store_open = true;
548
+ resolved_options.relational_store = relational_store_value.binding();
549
+ }
550
+ defer if (comptime manifestDeclaresSqlite()) {
551
+ if (relational_store_open) relational_store_value.deinit();
552
+ };
465
553
  if (comptime std.mem.eql(u8, build_options.platform, "macos")) {
466
- try runMacos(app, options, init);
554
+ try runMacos(app, resolved_options, init);
467
555
  } else if (comptime std.mem.eql(u8, build_options.platform, "linux")) {
468
- try runLinux(app, options, init);
556
+ try runLinux(app, resolved_options, init);
469
557
  } else if (comptime std.mem.eql(u8, build_options.platform, "windows")) {
470
- try runWindows(app, options, init);
558
+ try runWindows(app, resolved_options, init);
471
559
  } else {
472
- try runNull(app, options, init);
560
+ try runNull(app, resolved_options, init);
473
561
  }
474
562
  }
475
563
 
@@ -525,6 +613,9 @@ fn runNull(app: native_sdk.App, options: RunOptions, init: std.process.Init) !vo
525
613
  .shortcuts = shortcuts,
526
614
  .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
527
615
  .window_state_store = store,
616
+ .record_store = options.record_store,
617
+ .relational_store = options.relational_store,
618
+ .credentials_enabled = options.credentials_enabled,
528
619
  .environ = init.minimal.environ,
529
620
  .session_recorder = session_recorder,
530
621
  });
@@ -589,6 +680,9 @@ fn runMacos(app: native_sdk.App, options: RunOptions, init: std.process.Init) !v
589
680
  .shortcuts = shortcuts,
590
681
  .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
591
682
  .window_state_store = store,
683
+ .record_store = options.record_store,
684
+ .relational_store = options.relational_store,
685
+ .credentials_enabled = options.credentials_enabled,
592
686
  .environ = init.minimal.environ,
593
687
  .session_recorder = session_recorder,
594
688
  });
@@ -650,6 +744,9 @@ fn runLinux(app: native_sdk.App, options: RunOptions, init: std.process.Init) !v
650
744
  .shortcuts = shortcuts,
651
745
  .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
652
746
  .window_state_store = store,
747
+ .record_store = options.record_store,
748
+ .relational_store = options.relational_store,
749
+ .credentials_enabled = options.credentials_enabled,
653
750
  .environ = init.minimal.environ,
654
751
  .session_recorder = session_recorder,
655
752
  });
@@ -710,6 +807,9 @@ fn runWindows(app: native_sdk.App, options: RunOptions, init: std.process.Init)
710
807
  .shortcuts = shortcuts,
711
808
  .automation = if (build_options.automation) native_sdk.automation.Server.init(init.io, ".zig-cache/native-sdk-automation", app_info.resolvedWindowTitle()) else null,
712
809
  .window_state_store = store,
810
+ .record_store = options.record_store,
811
+ .relational_store = options.relational_store,
812
+ .credentials_enabled = options.credentials_enabled,
713
813
  .environ = init.minimal.environ,
714
814
  .session_recorder = session_recorder,
715
815
  });
@@ -25,8 +25,12 @@
25
25
  //! from src/app.native in Debug.
26
26
  //! menus/shortcuts a core exporting `commandMsg(name): Msg | null`
27
27
  //! receives command events (menus, shortcuts, chrome
28
- //! tabs) as ordinary Msgs; without the export command
29
- //! events stay host-handled only.
28
+ //! tabs, status-item rows) as ordinary Msgs; without
29
+ //! the export command events stay host-handled only.
30
+ //! status item a core exporting `statusItem(model)` supplies the
31
+ //! install-time icon/click hooks and live menu-bar
32
+ //! presentation + rows; the adapter patches the two
33
+ //! live parts independently after committed updates.
30
34
  //! host events the adapter wires the core's opt-in channels from
31
35
  //! its exports (export exists -> wired): `frameMsg`
32
36
  //! (presented frames), `keyMsg` (the app-level key
@@ -58,6 +62,9 @@ const runner = @import("runner");
58
62
  const native_sdk = @import("native_sdk");
59
63
  const manifest = @import("app_manifest_zon");
60
64
  pub const core = @import("core.zig");
65
+ const services = @import("services.zig");
66
+ const service_carrier = @import("service_carrier.zig");
67
+ const relational_migrations = @import("migrations.zig");
61
68
 
62
69
  pub const panic = std.debug.FullPanic(native_sdk.debug.capturePanic);
63
70
 
@@ -111,19 +118,68 @@ pub fn main(init: std.process.Init) !void {
111
118
  .cache,
112
119
  &cache_dir_buffer,
113
120
  ) catch "";
114
- // The durable per-app data directory, resolved by the same platform
115
- // convention as Zig-core apps. TS cores request it through the
116
- // ordinary journaled envMsgs boundary under `app_data_dir_env`; it
117
- // is framework-provided rather than trusted from the ambient
118
- // environment, so package launch cwd and env differences disappear.
121
+ // The durable per-app data directory, resolved by the platform app-data
122
+ // convention and keyed by the manifest's stable bundle identity. TS cores
123
+ // request it through the ordinary journaled envMsgs boundary under
124
+ // `app_data_dir_env`; it is framework-provided rather than trusted from
125
+ // the ambient environment, so package launch cwd and env differences
126
+ // disappear.
119
127
  var data_dir_buffer: [512]u8 = undefined;
120
128
  const app_data_dir = native_sdk.app_dirs.resolveOne(
121
- .{ .name = manifest.name },
129
+ // Durable state follows the reverse-DNS bundle identity, not the
130
+ // mutable short machine name. Two installed apps may share a name;
131
+ // their manifest ids are the stable isolation boundary.
132
+ .{ .name = manifest.id },
122
133
  native_sdk.app_dirs.currentPlatform(),
123
134
  native_sdk.debug.envFromMap(init.environ_map),
124
135
  .data,
125
136
  &data_dir_buffer,
126
137
  ) catch "";
138
+ if (app_data_dir.len > 0) std.Io.Dir.cwd().createDirPath(init.io, app_data_dir) catch {};
139
+
140
+ // TypeScript services, on the build-selected carrier (service_carrier.zig).
141
+ // In-process (explicit opt-in): the service archive is linked into this
142
+ // binary and ServicePool runs one instance per worker thread. Child (the
143
+ // auto/default carrier): a lazily-spawned sibling executable with an
144
+ // explicit environment allowlist and the app data directory as its cwd.
145
+ // Either way, replay never calls the binding, so nothing starts under replay.
146
+ const use_pool = comptime (services.enabled and service_carrier.kind == .in_process);
147
+ const use_child = comptime (services.enabled and !use_pool);
148
+ var service_env = std.process.Environ.Map.init(std.heap.page_allocator);
149
+ defer service_env.deinit();
150
+ var service_path_buffer: [std.Io.Dir.max_path_bytes]u8 = undefined;
151
+ const ChildTransport = native_sdk.ServiceHost(services);
152
+ const PoolTransport = native_sdk.ServicePool(services);
153
+ var child_transport: if (use_child) ChildTransport else void = undefined;
154
+ var pool_transport: if (use_pool) PoolTransport else void = undefined;
155
+ if (comptime use_child) {
156
+ const env_keys = init.environ_map.keys();
157
+ const env_values = init.environ_map.values();
158
+ for (env_keys, env_values) |key, value| {
159
+ if (native_sdk.serviceEnvironmentVariableAllowed(key)) service_env.put(key, value) catch {};
160
+ }
161
+ const service_path = siblingServiceHostPath(init.io, &service_path_buffer);
162
+ child_transport = ChildTransport.init(
163
+ std.heap.page_allocator,
164
+ init.io,
165
+ service_path,
166
+ app_data_dir,
167
+ &service_env,
168
+ );
169
+ }
170
+ if (comptime use_pool) {
171
+ // The pool's cwd holds the cooperative-cancellation markers and
172
+ // stream-relay files; the service operations themselves run with the
173
+ // app process's own working directory.
174
+ pool_transport = PoolTransport.init(
175
+ std.heap.page_allocator,
176
+ init.io,
177
+ app_data_dir,
178
+ .{ .max_workers = service_carrier.pool_workers },
179
+ );
180
+ }
181
+ defer if (comptime use_child) child_transport.deinit();
182
+ defer if (comptime use_pool) pool_transport.deinit();
127
183
  // app.zon-declared images, read once at launch (bounded; a missing or
128
184
  // over-bound file skips its entry and the views keep their fallback)
129
185
  // and registered by the adapter on the installing frame.
@@ -157,6 +213,65 @@ pub fn main(init: std.process.Init) !void {
157
213
  }
158
214
  }
159
215
 
216
+ // Model persistence is a build-time capability: without `"persist"`
217
+ // this branch (store, paths, binding) is not analyzed into the app. A
218
+ // replay launch never reads the live snapshot; its journal feeds the
219
+ // recorded restore result before the installing app-start event.
220
+ var persist_store_value: native_sdk.PersistStore = undefined;
221
+ var persist_coordinator_value: native_sdk.persist_store.Coordinator = undefined;
222
+ var persist_coordinator_started = false;
223
+ var persist_host_value: PersistHost = .{};
224
+ var persist_outcome_handle: native_sdk.ChannelHandle = .{};
225
+ var persist_restore_value: native_sdk.persist_store.RestoreResult = .{ .outcome = .none };
226
+ var persist_options: ?Adapter.PersistOptions = null;
227
+ if (comptime manifestDeclaresPersist()) {
228
+ const config = comptime manifestPersistConfig();
229
+ comptime Adapter.validatePersistRoutes(.{
230
+ .ok = config.restore.ok,
231
+ .none = config.restore.none,
232
+ .err = config.restore.err,
233
+ });
234
+ const replay = init.environ_map.get("NATIVE_SDK_SESSION_REPLAY") != null;
235
+ persist_store_value = native_sdk.PersistStore.init(init.io, std.heap.page_allocator, app_data_dir, .{
236
+ .schema_version = config.version,
237
+ .model_fingerprint = core.sidecar_model_fingerprint,
238
+ .snapshot_format = core.sidecar_snapshot_format,
239
+ });
240
+ persist_host_value.outcome_handle = &persist_outcome_handle;
241
+ if (!replay) {
242
+ persist_restore_value = persist_store_value.restore();
243
+ if (persist_restore_value.used_backup) {
244
+ std.log.warn("model persistence: primary snapshot unavailable or corrupt; restored snapshot.nsd.bak", .{});
245
+ }
246
+ try persist_coordinator_value.startWithOutcomeHandler(
247
+ persist_store_value,
248
+ manifestPersistDebounce(config),
249
+ .{ .context = &persist_host_value, .report_fn = PersistHost.reportOutcome },
250
+ );
251
+ persist_coordinator_started = true;
252
+ persist_host_value.coordinator = &persist_coordinator_value;
253
+ }
254
+ persist_options = .{
255
+ // Replay binds the same named service to a no-op host. The
256
+ // command remains on the wire for fingerprint parity but can
257
+ // never mutate the live snapshot.
258
+ .binding = persist_host_value.binding(),
259
+ .routes = .{
260
+ .ok = config.restore.ok,
261
+ .none = config.restore.none,
262
+ .err = config.restore.err,
263
+ },
264
+ .restore = .{
265
+ .outcome = persist_restore_value.outcome,
266
+ .bytes = persist_restore_value.bytes,
267
+ .migration_from_version = persist_restore_value.migration_from_version,
268
+ },
269
+ .outcome_handle = &persist_outcome_handle,
270
+ };
271
+ }
272
+ defer if (comptime manifestDeclaresPersist()) persist_restore_value.deinit(std.heap.page_allocator);
273
+ defer if (persist_coordinator_started) persist_coordinator_value.deinit();
274
+
160
275
  // The app struct (and any real model) is multi-MB: `create`
161
276
  // heap-allocates and constructs in place, so neither rides the stack.
162
277
  const app_state = try Adapter.create(std.heap.page_allocator, .{
@@ -167,6 +282,18 @@ pub fn main(init: std.process.Init) !void {
167
282
  .image_cache_dir = audio_cache_dir,
168
283
  .boot_images = boot_images_buffer[0..boot_image_count],
169
284
  .env_values = env_values_buffer[0..env_value_count],
285
+ .host_calls = if (comptime use_pool)
286
+ pool_transport.binding()
287
+ else if (comptime use_child)
288
+ child_transport.binding()
289
+ else
290
+ null,
291
+ .service_results = if (comptime services.enabled) .{
292
+ .index_fn = services.indexOf,
293
+ .streaming_fn = services.isStreaming,
294
+ .decode_fn = services.resultDecoder(core),
295
+ } else null,
296
+ .persist = persist_options,
170
297
  }, options);
171
298
  defer app_state.destroy();
172
299
 
@@ -182,9 +309,61 @@ pub fn main(init: std.process.Init) !void {
182
309
  .permissions = app_permissions,
183
310
  .navigation = .{ .allowed_origins = allowed_origins },
184
311
  },
312
+ .relational_migrations = &relational_migrations.migrations,
185
313
  }, init);
186
314
  }
187
315
 
316
+ fn siblingServiceHostPath(io: std.Io, buffer: []u8) []const u8 {
317
+ var executable_buffer: [std.Io.Dir.max_path_bytes]u8 = undefined;
318
+ const len = std.process.executablePath(io, &executable_buffer) catch return "";
319
+ const dir = std.fs.path.dirname(executable_buffer[0..len]) orelse return "";
320
+ const suffix = if (@import("builtin").os.tag == .windows) ".exe" else "";
321
+ return std.fmt.bufPrint(buffer, "{s}/{s}_services{s}", .{ dir, manifest.name, suffix }) catch "";
322
+ }
323
+
324
+ const PersistHost = struct {
325
+ coordinator: ?*native_sdk.persist_store.Coordinator = null,
326
+ outcome_handle: ?*native_sdk.ChannelHandle = null,
327
+
328
+ fn binding(self: *PersistHost) native_sdk.HostCallBinding {
329
+ return .{ .context = self, .send_fn = send, .request_fn = request };
330
+ }
331
+
332
+ fn send(context: *anyopaque, name: []const u8, snapshot: []const u8) void {
333
+ const self: *PersistHost = @ptrCast(@alignCast(context));
334
+ const coordinator = self.coordinator orelse return;
335
+ if (std.mem.eql(u8, name, "core.persist.flush")) {
336
+ coordinator.flush();
337
+ return;
338
+ }
339
+ if (!std.mem.eql(u8, name, "core.persist")) return;
340
+ const outcome = coordinator.enqueue(snapshot);
341
+ if (outcome != .ok) reportOutcome(context, outcome);
342
+ }
343
+
344
+ fn reportOutcome(context: *anyopaque, outcome: native_sdk.persist_store.Outcome) void {
345
+ if (outcome == .ok) return;
346
+ const self: *PersistHost = @ptrCast(@alignCast(context));
347
+ const handle = self.outcome_handle orelse {
348
+ std.log.err("model persistence write failed before its result channel installed: {s}", .{@tagName(outcome)});
349
+ return;
350
+ };
351
+ switch (handle.post(@tagName(outcome))) {
352
+ .accepted => {},
353
+ .dropped_full, .dropped_oversized, .closed => {
354
+ std.log.err("model persistence write failed after its result channel closed: {s}", .{@tagName(outcome)});
355
+ },
356
+ }
357
+ }
358
+
359
+ fn request(context: *anyopaque, name: []const u8, key: u64, payload: []const u8) void {
360
+ _ = context;
361
+ _ = name;
362
+ _ = key;
363
+ _ = payload;
364
+ }
365
+ };
366
+
188
367
  /// The startup window title: the scene's first window title, else the
189
368
  /// manifest display name, else the app name.
190
369
  fn windowTitle() []const u8 {
@@ -251,6 +430,68 @@ fn manifestStringList(comptime m: anytype, comptime field: []const u8) []const [
251
430
  }
252
431
  }
253
432
 
433
+ fn manifestDeclaresPersist() bool {
434
+ comptime {
435
+ for (manifestStringList(manifest, "capabilities")) |capability| {
436
+ if (std.mem.eql(u8, capability, "persist")) {
437
+ if (!@hasField(@TypeOf(manifest), "persist")) {
438
+ @compileError("app.zon declares the persist capability but has no .persist = .{ .version, .restore = .{ .ok, .none, .err } } configuration");
439
+ }
440
+ return true;
441
+ }
442
+ }
443
+ if (@hasField(@TypeOf(manifest), "persist")) {
444
+ @compileError("app.zon configures .persist but does not declare \"persist\" in .capabilities");
445
+ }
446
+ return false;
447
+ }
448
+ }
449
+
450
+ fn ManifestPersistType() type {
451
+ if (@hasField(@TypeOf(manifest), "persist")) return @TypeOf(manifest.persist);
452
+ return void;
453
+ }
454
+
455
+ fn manifestPersistConfig() ManifestPersistType() {
456
+ comptime {
457
+ if (!manifestDeclaresPersist()) unreachable;
458
+ if (manifest.persist.version == 0 or manifest.persist.version > 9_007_199_254_740_991) {
459
+ @compileError("app.zon .persist.version must be a positive exact integer and monotonically increased for every Model shape change");
460
+ }
461
+ if (@hasField(@TypeOf(manifest.persist), "debounce_ms") and manifest.persist.debounce_ms > 60_000) {
462
+ @compileError("app.zon .persist.debounce_ms must be at most 60000");
463
+ }
464
+ validatePersistRoutes(manifest.persist.restore);
465
+ return manifest.persist;
466
+ }
467
+ }
468
+
469
+ fn manifestPersistDebounce(comptime config: anytype) u32 {
470
+ if (@hasField(@TypeOf(config), "debounce_ms")) return config.debounce_ms;
471
+ return 500;
472
+ }
473
+
474
+ fn validatePersistRoutes(comptime routes: anytype) void {
475
+ if (!persistRouteMatches(routes.ok, void)) {
476
+ @compileError("app.zon .persist.restore.ok must name a void Msg arm in src/core.ts");
477
+ }
478
+ if (!persistRouteMatches(routes.none, void)) {
479
+ @compileError("app.zon .persist.restore.none must name a void Msg arm in src/core.ts");
480
+ }
481
+ if (!persistRouteMatches(routes.err, []const u8)) {
482
+ @compileError("app.zon .persist.restore.err must name a one-Uint8Array-field Msg arm in src/core.ts");
483
+ }
484
+ }
485
+
486
+ fn persistRouteMatches(comptime name: []const u8, comptime Payload: type) bool {
487
+ const info = @typeInfo(core.Msg);
488
+ if (info != .@"union") return false;
489
+ inline for (info.@"union".fields) |field| {
490
+ if (std.mem.eql(u8, field.name, name)) return field.type == Payload;
491
+ }
492
+ return false;
493
+ }
494
+
254
495
  fn manifestAllowedOrigins() []const []const u8 {
255
496
  comptime {
256
497
  if (!@hasField(@TypeOf(manifest), "security")) return &.{};
@@ -223,6 +223,10 @@ pub const TrayItem = struct {
223
223
  command: []const u8 = "",
224
224
  separator: bool = false,
225
225
  enabled: bool = true,
226
+ detail: []const u8 = "",
227
+ role: platform.TrayItemRole = .command,
228
+ key: []const u8 = "",
229
+ modifiers: platform.ShortcutModifiers = .{},
226
230
  };
227
231
 
228
232
  /// The live status item (tray): current button title + dropdown items.
@@ -382,7 +386,7 @@ pub fn writeText(input: Input, writer: anytype) !void {
382
386
  },
383
387
  );
384
388
  if (view.kind == .gpu_surface) {
385
- try writer.print(" gpu_size={d}x{d} gpu_scale={d} gpu_backend={s} gpu_pixel_format={s} gpu_present_mode={s} gpu_alpha_mode={s} gpu_color_space={s} gpu_vsync={any} gpu_status={s} gpu_present_path={s} gpu_frame={d} gpu_timestamp_ns={d} gpu_frame_interval_ns={d} gpu_input_timestamp_ns={d} gpu_input_latency_ns={d} gpu_input_latency_budget_ns={d} gpu_input_latency_budget_exceeded={d} gpu_input_latency_budget_ok={any} gpu_first_frame_latency_ns={d} gpu_first_frame_latency_budget_ns={d} gpu_first_frame_latency_budget_exceeded={d} gpu_first_frame_latency_budget_ok={any} gpu_nonblank={any} gpu_sample=0x{x:0>8}", .{
389
+ try writer.print(" gpu_size={d}x{d} gpu_scale={d} gpu_backend={s} gpu_pixel_format={s} gpu_present_mode={s} gpu_alpha_mode={s} gpu_color_space={s} gpu_vsync={any} gpu_status={s} gpu_present_path={s} gpu_frame={d} gpu_timestamp_ns={d} gpu_frame_interval_ns={d} gpu_input_count={d} gpu_input_timestamp_ns={d} gpu_input_latency_ns={d} gpu_input_latency_budget_ns={d} gpu_input_latency_budget_exceeded={d} gpu_input_latency_budget_ok={any} gpu_first_frame_latency_ns={d} gpu_first_frame_latency_budget_ns={d} gpu_first_frame_latency_budget_exceeded={d} gpu_first_frame_latency_budget_ok={any} gpu_nonblank={any} gpu_occluded={any} gpu_sample=0x{x:0>8}", .{
386
390
  view.gpu_size.width,
387
391
  view.gpu_size.height,
388
392
  view.gpu_scale_factor,
@@ -397,6 +401,7 @@ pub fn writeText(input: Input, writer: anytype) !void {
397
401
  view.gpu_frame_index,
398
402
  view.gpu_timestamp_ns,
399
403
  view.gpu_frame_interval_ns,
404
+ view.gpu_input_event_count,
400
405
  view.gpu_input_timestamp_ns,
401
406
  view.gpu_input_latency_ns,
402
407
  view.gpu_input_latency_budget_ns,
@@ -407,6 +412,7 @@ pub fn writeText(input: Input, writer: anytype) !void {
407
412
  view.gpu_first_frame_latency_budget_exceeded_count,
408
413
  view.gpu_first_frame_latency_budget_ok,
409
414
  view.gpu_frame_nonblank,
415
+ view.gpu_occluded,
410
416
  view.gpu_sample_color,
411
417
  });
412
418
  // Packet-fallback telemetry: WHY the last packet attempt
@@ -594,11 +600,19 @@ pub fn writeText(input: Input, writer: anytype) !void {
594
600
  try writer.writeAll(" tray-item separator\n");
595
601
  continue;
596
602
  }
597
- try writer.print(" tray-item #{d} label=\"{s}\" command=\"{s}\" enabled={any}\n", .{
603
+ try writer.print(" tray-item #{d} label=\"{s}\" command=\"{s}\" enabled={any} detail=\"{s}\" role={s} key=\"{s}\" modifiers=(primary={any},command={any},control={any},option={any},shift={any})\n", .{
598
604
  item.id,
599
605
  item.label,
600
606
  item.command,
601
607
  item.enabled,
608
+ item.detail,
609
+ @tagName(item.role),
610
+ item.key,
611
+ item.modifiers.primary,
612
+ item.modifiers.command,
613
+ item.modifiers.control,
614
+ item.modifiers.option,
615
+ item.modifiers.shift,
602
616
  });
603
617
  }
604
618
  }
@@ -907,7 +921,7 @@ test "snapshot emits tray title and dropdown items" {
907
921
  const items = [_]TrayItem{
908
922
  .{ .id = 1, .label = "Refresh", .command = "app.refresh" },
909
923
  .{ .separator = true },
910
- .{ .id = 10, .label = "Fix crash on resize", .command = "issue.select.0", .enabled = false },
924
+ .{ .id = 10, .label = "Fix crash on resize", .command = "issue.select.0", .enabled = false, .detail = "warning ⚠", .role = .agent, .key = "q", .modifiers = .{ .command = true } },
911
925
  };
912
926
  try writeText(.{
913
927
  .windows = &windows,
@@ -915,9 +929,9 @@ test "snapshot emits tray title and dropdown items" {
915
929
  }, &writer);
916
930
  const text = writer.buffered();
917
931
  try std.testing.expect(std.mem.indexOf(u8, text, "\ntray title=\"ZN 3\" items=3\n") != null);
918
- try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #1 label=\"Refresh\" command=\"app.refresh\" enabled=true\n") != null);
932
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #1 label=\"Refresh\" command=\"app.refresh\" enabled=true detail=\"\" role=command key=\"\" modifiers=(primary=false,command=false,control=false,option=false,shift=false)\n") != null);
919
933
  try std.testing.expect(std.mem.indexOf(u8, text, " tray-item separator\n") != null);
920
- try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=false\n") != null);
934
+ try std.testing.expect(std.mem.indexOf(u8, text, " tray-item #10 label=\"Fix crash on resize\" command=\"issue.select.0\" enabled=false detail=\"warning ⚠\" role=agent key=\"q\" modifiers=(primary=false,command=true,control=false,option=false,shift=false)\n") != null);
921
935
 
922
936
  // No tray -> no tray lines.
923
937
  var empty_buffer: [512]u8 = undefined;
@@ -981,6 +995,7 @@ test "snapshot emits GPU surface frame proof" {
981
995
  .gpu_frame_index = 4,
982
996
  .gpu_timestamp_ns = 99,
983
997
  .gpu_frame_interval_ns = 8,
998
+ .gpu_input_event_count = 7,
984
999
  .gpu_input_timestamp_ns = 80,
985
1000
  .gpu_input_latency_ns = 19,
986
1001
  .gpu_input_latency_budget_ns = 16,
@@ -991,6 +1006,7 @@ test "snapshot emits GPU surface frame proof" {
991
1006
  .gpu_first_frame_latency_budget_exceeded_count = 0,
992
1007
  .gpu_first_frame_latency_budget_ok = true,
993
1008
  .gpu_frame_nonblank = true,
1009
+ .gpu_occluded = true,
994
1010
  .gpu_sample_color = 0xff336699,
995
1011
  .canvas_revision = 2,
996
1012
  .canvas_command_count = 5,
@@ -1088,6 +1104,7 @@ test "snapshot emits GPU surface frame proof" {
1088
1104
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_frame=4") != null);
1089
1105
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_timestamp_ns=99") != null);
1090
1106
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_frame_interval_ns=8") != null);
1107
+ try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_input_count=7") != null);
1091
1108
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_input_timestamp_ns=80") != null);
1092
1109
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_input_latency_ns=19") != null);
1093
1110
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_input_latency_budget_ns=16") != null);
@@ -1098,6 +1115,7 @@ test "snapshot emits GPU surface frame proof" {
1098
1115
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_first_frame_latency_budget_exceeded=0") != null);
1099
1116
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_first_frame_latency_budget_ok=true") != null);
1100
1117
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_nonblank=true") != null);
1118
+ try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_occluded=true") != null);
1101
1119
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "gpu_sample=0xff336699") != null);
1102
1120
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "canvas_revision=2") != null);
1103
1121
  try std.testing.expect(std.mem.indexOf(u8, writer.buffered(), "canvas_commands=5") != null);