@native-sdk/cli 0.10.1 → 0.11.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 (555) hide show
  1. package/README.md +8 -6
  2. package/bin/native.js +2 -1
  3. package/build/app.zig +393 -97
  4. package/build/corewire.zig +53 -0
  5. package/build/test_shards.zig +49 -0
  6. package/build/ts_run.mjs +3 -3
  7. package/build.zig +2030 -83
  8. package/native-sdk.d.ts +5 -1
  9. package/package.json +20 -14
  10. package/packages/core/compile-surface/core.ts +164 -72
  11. package/packages/core/package-lock.json +75 -357
  12. package/packages/core/package.json +25 -4
  13. package/packages/core/scripts/compiler_command.mjs +17 -12
  14. package/packages/core/scripts/compiler_typecheck.mjs +1 -0
  15. package/packages/core/scripts/gen_declarations.mjs +3 -2
  16. package/packages/core/scripts/gen_service_surface.mjs +22 -10
  17. package/packages/core/scripts/install_scriptc.mjs +182 -0
  18. package/packages/core/scripts/invoke_scriptc.mjs +18 -0
  19. package/packages/core/scripts/merge_static_archives.mjs +6 -1
  20. package/packages/core/scripts/npm_static_spike.mjs +2 -2
  21. package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
  22. package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
  23. package/packages/core/scripts/run_library_compiler.mjs +51 -0
  24. package/packages/core/scripts/run_native_tests.mjs +22 -0
  25. package/packages/core/scripts/scriptc-toolchain.json +101 -0
  26. package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
  27. package/packages/core/scripts/stage_external_core.mjs +68 -1
  28. package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
  29. package/packages/core/sdk/bytes.d.ts +2 -0
  30. package/packages/core/sdk/bytes.ts +86 -0
  31. package/packages/core/sdk/core.d.ts +332 -5
  32. package/packages/core/sdk/core.ts +371 -85
  33. package/packages/core/sdk/events.d.ts +252 -0
  34. package/packages/core/sdk/events.ts +240 -2
  35. package/packages/core/sdk/internal/image_identity.d.ts +7 -0
  36. package/packages/core/sdk/internal/image_identity.ts +71 -0
  37. package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
  38. package/packages/core/sdk/internal/markdown_policy.ts +878 -0
  39. package/packages/core/sdk/text.d.ts +27 -0
  40. package/packages/core/sdk/text.ts +206 -15
  41. package/packages/core/sdk/theme.d.ts +251 -0
  42. package/packages/core/sdk/theme.ts +267 -0
  43. package/packages/core/src/authorization.ts +137 -0
  44. package/packages/core/src/automation_commands.ts +201 -0
  45. package/packages/core/src/automation_interactions.ts +92 -0
  46. package/packages/core/src/bridge_descriptors.ts +104 -0
  47. package/packages/core/src/builtin_coordination.ts +172 -0
  48. package/packages/core/src/canvas_frame_coordination.ts +81 -0
  49. package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
  50. package/packages/core/src/canvas_scene_observation.ts +145 -0
  51. package/packages/core/src/chart_content.ts +161 -0
  52. package/packages/core/src/chart_plans.ts +432 -0
  53. package/packages/core/src/checker.ts +186 -19
  54. package/packages/core/src/cli.ts +2 -11
  55. package/packages/core/src/code_content.ts +580 -0
  56. package/packages/core/src/command_coordination.ts +140 -0
  57. package/packages/core/src/component_composition.ts +94 -0
  58. package/packages/core/src/component_construction.ts +149 -0
  59. package/packages/core/src/context_menus.ts +76 -0
  60. package/packages/core/src/contract.ts +25 -7
  61. package/packages/core/src/control_appearance.ts +232 -0
  62. package/packages/core/src/control_commands.ts +115 -0
  63. package/packages/core/src/control_content.ts +105 -0
  64. package/packages/core/src/control_geometry.ts +107 -0
  65. package/packages/core/src/control_payloads.ts +119 -0
  66. package/packages/core/src/control_primitives.ts +134 -0
  67. package/packages/core/src/devhost.ts +82 -7
  68. package/packages/core/src/devhost_journal.mjs +30 -7
  69. package/packages/core/src/diagnostics.ts +7 -0
  70. package/packages/core/src/effect_plans.ts +71 -0
  71. package/packages/core/src/extent_program.ts +53 -0
  72. package/packages/core/src/flow_measurement.ts +121 -0
  73. package/packages/core/src/font_registry.ts +37 -0
  74. package/packages/core/src/frontend.ts +12 -10
  75. package/packages/core/src/glyph_atlas.ts +86 -0
  76. package/packages/core/src/gpu_packet_preparation.ts +130 -0
  77. package/packages/core/src/gpu_planning.ts +123 -0
  78. package/packages/core/src/gpu_presentation.ts +55 -0
  79. package/packages/core/src/host_flow.ts +89 -0
  80. package/packages/core/src/host_input_regions.ts +165 -0
  81. package/packages/core/src/image_registry.ts +66 -0
  82. package/packages/core/src/indicator_plans.ts +132 -0
  83. package/packages/core/src/infer.ts +150 -8
  84. package/packages/core/src/input_composition.ts +116 -0
  85. package/packages/core/src/intrinsic_measure.ts +100 -0
  86. package/packages/core/src/layout_coordination.ts +207 -0
  87. package/packages/core/src/leaf_plans.ts +134 -0
  88. package/packages/core/src/markup_canonical.ts +140 -0
  89. package/packages/core/src/markup_construction.ts +189 -0
  90. package/packages/core/src/markup_development.ts +160 -0
  91. package/packages/core/src/markup_display.ts +43 -0
  92. package/packages/core/src/markup_document.ts +226 -0
  93. package/packages/core/src/markup_elements.ts +225 -0
  94. package/packages/core/src/markup_expressions.ts +79 -0
  95. package/packages/core/src/markup_imports.ts +146 -0
  96. package/packages/core/src/markup_parser.ts +228 -0
  97. package/packages/core/src/markup_runtime.ts +93 -0
  98. package/packages/core/src/markup_scalars.ts +143 -0
  99. package/packages/core/src/markup_shapes.ts +243 -0
  100. package/packages/core/src/markup_specialized.ts +242 -0
  101. package/packages/core/src/markup_text.ts +86 -0
  102. package/packages/core/src/markup_values.ts +336 -0
  103. package/packages/core/src/measurement_coordination.ts +185 -0
  104. package/packages/core/src/modules.ts +1 -1
  105. package/packages/core/src/motion_sampling.ts +100 -0
  106. package/packages/core/src/paragraph_layout.ts +192 -0
  107. package/packages/core/src/portable_sources.json +98 -0
  108. package/packages/core/src/portable_sources.ts +17 -0
  109. package/packages/core/src/registered_font.ts +92 -0
  110. package/packages/core/src/render_animation_lifecycle.ts +128 -0
  111. package/packages/core/src/render_coordination.ts +170 -0
  112. package/packages/core/src/render_resources.ts +234 -0
  113. package/packages/core/src/runtime_policy.ts +3954 -0
  114. package/packages/core/src/scalar_text.ts +82 -0
  115. package/packages/core/src/scroll_mutation.ts +86 -0
  116. package/packages/core/src/scroll_tree.ts +86 -0
  117. package/packages/core/src/service_contract.ts +55 -3
  118. package/packages/core/src/session_codecs.ts +309 -0
  119. package/packages/core/src/shell_admission.ts +126 -0
  120. package/packages/core/src/shell_coordination.ts +93 -0
  121. package/packages/core/src/sqlite_cli.ts +14 -46
  122. package/packages/core/src/sqlite_codegen.ts +84 -0
  123. package/packages/core/src/staged_rebuild.ts +60 -0
  124. package/packages/core/src/status_validation.ts +232 -0
  125. package/packages/core/src/stream_policy.ts +63 -0
  126. package/packages/core/src/surface_recipes.ts +136 -0
  127. package/packages/core/src/system_admission.ts +60 -0
  128. package/packages/core/src/terminal_paint.ts +436 -0
  129. package/packages/core/src/text_document_width.ts +81 -0
  130. package/packages/core/src/text_measurement_cache.ts +69 -0
  131. package/packages/core/src/text_query_layout.ts +179 -0
  132. package/packages/core/src/text_run_layout.ts +410 -0
  133. package/packages/core/src/text_span_queries.ts +355 -0
  134. package/packages/core/src/typed_ast.ts +18 -1
  135. package/packages/core/src/types.ts +7 -5
  136. package/packages/core/src/vector_effects.ts +98 -0
  137. package/packages/core/src/vector_raster.ts +243 -0
  138. package/packages/core/src/view_bridge.ts +161 -0
  139. package/packages/core/src/view_check.ts +145 -0
  140. package/packages/core/src/view_components.ts +2415 -0
  141. package/packages/core/src/view_coordination.ts +198 -0
  142. package/packages/core/src/view_evaluator.ts +823 -0
  143. package/packages/core/src/view_frontend.ts +1102 -0
  144. package/packages/core/src/view_program.ts +221 -0
  145. package/packages/core/src/view_reload.ts +166 -0
  146. package/packages/core/src/view_reload_watch.ts +98 -0
  147. package/packages/core/src/view_sources.ts +34 -0
  148. package/packages/core/src/virtual_windows.ts +88 -0
  149. package/packages/core/src/web_panes.ts +67 -0
  150. package/packages/core/src/widget_audits.ts +202 -0
  151. package/packages/core/src/widget_changes.ts +258 -0
  152. package/packages/core/src/widget_continuity.ts +37 -0
  153. package/packages/core/src/widget_metrics.ts +139 -0
  154. package/packages/core/src/widget_motion.ts +171 -0
  155. package/packages/core/src/widget_paint.ts +272 -0
  156. package/packages/core/src/widget_paint_walk.ts +203 -0
  157. package/packages/core/src/widget_presentation.ts +141 -0
  158. package/packages/core/src/widget_reconcile.ts +63 -0
  159. package/packages/core/src/widget_retention.ts +62 -0
  160. package/packages/core/src/widget_routing.ts +262 -0
  161. package/packages/core/src/window_lifecycle.ts +92 -0
  162. package/packages/core/testing/index.ts +430 -0
  163. package/schemas/app.schema.json +13 -0
  164. package/skill-data/core/SKILL.md +2 -2
  165. package/skill-data/native-ui/SKILL.md +77 -18
  166. package/skill-data/ts-core/SKILL.md +117 -11
  167. package/skill-data/ts-services/SKILL.md +1 -1
  168. package/skill-data/ts-services/references/service-surface.md +288 -144
  169. package/src/app_runner/root.zig +39 -12
  170. package/src/app_runner/ts_compiled_view.zig +1702 -0
  171. package/src/app_runner/ts_core_main.zig +185 -14
  172. package/src/app_runner/ts_core_mobile.zig +25 -13
  173. package/src/automation/server.zig +57 -6
  174. package/src/automation/snapshot.zig +9 -637
  175. package/src/automation/snapshot_reference.zig +656 -0
  176. package/src/automation/snapshot_serialization.zig +566 -0
  177. package/src/embed/host.zig +2 -0
  178. package/src/embed/tests.zig +2 -0
  179. package/src/embed/ui_host.zig +2 -0
  180. package/src/platform/keyboard_input.zig +32 -0
  181. package/src/platform/linux/gtk_host.c +36 -24
  182. package/src/platform/linux/gtk_pixels.h +118 -0
  183. package/src/platform/linux/gtk_pixels_test.c +241 -0
  184. package/src/platform/linux/root.zig +4 -0
  185. package/src/platform/macos/appkit_host.h +7 -2
  186. package/src/platform/macos/appkit_host.m +219 -39
  187. package/src/platform/macos/cef_host.mm +15 -1
  188. package/src/platform/macos/global_shortcuts.zig +138 -0
  189. package/src/platform/macos/key_codes.zig +102 -0
  190. package/src/platform/macos/keyboard_input.zig +81 -0
  191. package/src/platform/macos/pointer_motion_test.m +96 -0
  192. package/src/platform/macos/root.zig +25 -3
  193. package/src/platform/macos/scroll_driver_test.m +105 -0
  194. package/src/platform/macos/spectrum_bins.h +34 -0
  195. package/src/platform/macos/spectrum_bins_test.c +56 -0
  196. package/src/platform/macos/text_keyboard_test.m +80 -0
  197. package/src/platform/macos/webview_inspection_test.m +106 -0
  198. package/src/platform/macos/widget_focus_test.m +66 -0
  199. package/src/platform/null_platform.zig +130 -2
  200. package/src/platform/null_platform_tests.zig +13 -0
  201. package/src/platform/root.zig +15 -0
  202. package/src/platform/types.zig +115 -0
  203. package/src/platform/windows/global_shortcuts.zig +157 -0
  204. package/src/platform/windows/key_codes.zig +63 -0
  205. package/src/platform/windows/keyboard_input.zig +136 -0
  206. package/src/platform/windows/root.zig +17 -0
  207. package/src/platform/windows/webview2_host.cpp +7 -2
  208. package/src/primitives/app_manifest/comptime_scene.zig +1 -1
  209. package/src/primitives/app_manifest/root.zig +2 -0
  210. package/src/primitives/app_manifest/tests.zig +4 -1
  211. package/src/primitives/app_manifest/validation.zig +2 -0
  212. package/src/primitives/canvas/a11y_audit.zig +3 -1
  213. package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
  214. package/src/primitives/canvas/chart_content_policy.zig +75 -0
  215. package/src/primitives/canvas/chart_plan_policy.zig +196 -0
  216. package/src/primitives/canvas/code_content_policy.zig +162 -0
  217. package/src/primitives/canvas/commands.zig +29 -1
  218. package/src/primitives/canvas/component_composition.zig +125 -0
  219. package/src/primitives/canvas/component_composition_policy.zig +44 -0
  220. package/src/primitives/canvas/component_construction_policy.zig +187 -0
  221. package/src/primitives/canvas/container_layout_policy.zig +87 -0
  222. package/src/primitives/canvas/control_appearance_policy.zig +142 -0
  223. package/src/primitives/canvas/control_command_policy.zig +75 -0
  224. package/src/primitives/canvas/control_content_policy.zig +90 -0
  225. package/src/primitives/canvas/control_geometry_policy.zig +165 -0
  226. package/src/primitives/canvas/control_payload_policy.zig +48 -0
  227. package/src/primitives/canvas/control_primitive_policy.zig +129 -0
  228. package/src/primitives/canvas/decision_reuse.zig +133 -0
  229. package/src/primitives/canvas/effect_plan_policy.zig +96 -0
  230. package/src/primitives/canvas/events.zig +1027 -1
  231. package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
  232. package/src/primitives/canvas/font_ttf.zig +27 -3
  233. package/src/primitives/canvas/fonts/Geist-Bold.ttf +0 -0
  234. package/src/primitives/canvas/fonts/Geist-Medium.ttf +0 -0
  235. package/src/primitives/canvas/fonts/OFL.txt +93 -0
  236. package/src/primitives/canvas/fonts/README.md +15 -0
  237. package/src/primitives/canvas/frame.zig +92 -23
  238. package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
  239. package/src/primitives/canvas/gpu.zig +10 -0
  240. package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
  241. package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
  242. package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
  243. package/src/primitives/canvas/grid_layout_policy.zig +51 -0
  244. package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
  245. package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
  246. package/src/primitives/canvas/intrinsic_measure_policy.zig +131 -0
  247. package/src/primitives/canvas/layout_audit.zig +5 -2
  248. package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
  249. package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
  250. package/src/primitives/canvas/markdown.zig +13 -3
  251. package/src/primitives/canvas/markdown_content_policy.zig +227 -0
  252. package/src/primitives/canvas/markdown_image_binding.zig +81 -0
  253. package/src/primitives/canvas/markdown_tests.zig +3 -3
  254. package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
  255. package/src/primitives/canvas/numeric_capabilities.zig +14 -0
  256. package/src/primitives/canvas/reference.zig +15 -11
  257. package/src/primitives/canvas/reference_tests.zig +58 -0
  258. package/src/primitives/canvas/registered_font_policy.zig +152 -0
  259. package/src/primitives/canvas/render.zig +48 -0
  260. package/src/primitives/canvas/render_cache_policy.zig +184 -0
  261. package/src/primitives/canvas/render_coordination_policy.zig +163 -0
  262. package/src/primitives/canvas/render_damage_policy.zig +160 -0
  263. package/src/primitives/canvas/render_effects.zig +14 -0
  264. package/src/primitives/canvas/render_generic_resources.zig +14 -0
  265. package/src/primitives/canvas/render_images.zig +14 -0
  266. package/src/primitives/canvas/render_layers.zig +14 -0
  267. package/src/primitives/canvas/render_override_policy.zig +119 -0
  268. package/src/primitives/canvas/render_paths.zig +14 -0
  269. package/src/primitives/canvas/render_plan_policy.zig +199 -0
  270. package/src/primitives/canvas/render_resource_policy.zig +476 -0
  271. package/src/primitives/canvas/root.zig +107 -4
  272. package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
  273. package/src/primitives/canvas/serialization.zig +8 -1
  274. package/src/primitives/canvas/surface_layout_policy.zig +36 -0
  275. package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
  276. package/src/primitives/canvas/terminal_grid.zig +10 -696
  277. package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
  278. package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
  279. package/src/primitives/canvas/text.zig +1 -0
  280. package/src/primitives/canvas/text_atlas.zig +113 -0
  281. package/src/primitives/canvas/text_cache_policy.zig +94 -0
  282. package/src/primitives/canvas/text_document_policy.zig +120 -0
  283. package/src/primitives/canvas/text_layout.zig +51 -2
  284. package/src/primitives/canvas/text_layout_cache.zig +29 -0
  285. package/src/primitives/canvas/text_layout_hash.zig +1 -0
  286. package/src/primitives/canvas/text_layout_types.zig +3 -0
  287. package/src/primitives/canvas/text_measure_cache.zig +46 -0
  288. package/src/primitives/canvas/text_measurement_policy.zig +124 -0
  289. package/src/primitives/canvas/text_metrics.zig +53 -37
  290. package/src/primitives/canvas/text_metrics_tests.zig +52 -7
  291. package/src/primitives/canvas/text_query_policy.zig +295 -0
  292. package/src/primitives/canvas/text_run_policy.zig +252 -0
  293. package/src/primitives/canvas/text_scalar_policy.zig +234 -0
  294. package/src/primitives/canvas/text_span_query_policy.zig +232 -0
  295. package/src/primitives/canvas/text_spans.zig +280 -8
  296. package/src/primitives/canvas/text_tests.zig +10 -0
  297. package/src/primitives/canvas/tokens.zig +47 -0
  298. package/src/primitives/canvas/ui.zig +251 -83
  299. package/src/primitives/canvas/ui_markup.zig +207 -46
  300. package/src/primitives/canvas/ui_markup_canonical.zig +237 -0
  301. package/src/primitives/canvas/ui_markup_compiled.zig +1724 -80
  302. package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
  303. package/src/primitives/canvas/ui_markup_compiled_values.zig +76 -0
  304. package/src/primitives/canvas/ui_markup_construction.zig +146 -0
  305. package/src/primitives/canvas/ui_markup_contract.zig +146 -14
  306. package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
  307. package/src/primitives/canvas/ui_markup_display.zig +82 -0
  308. package/src/primitives/canvas/ui_markup_document.zig +196 -0
  309. package/src/primitives/canvas/ui_markup_elements.zig +163 -0
  310. package/src/primitives/canvas/ui_markup_expr.zig +192 -2
  311. package/src/primitives/canvas/ui_markup_imports.zig +262 -0
  312. package/src/primitives/canvas/ui_markup_parser.zig +117 -0
  313. package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
  314. package/src/primitives/canvas/ui_markup_runtime.zig +76 -0
  315. package/src/primitives/canvas/ui_markup_scalars.zig +115 -0
  316. package/src/primitives/canvas/ui_markup_shapes.zig +224 -0
  317. package/src/primitives/canvas/ui_markup_specialized.zig +106 -0
  318. package/src/primitives/canvas/ui_markup_tests.zig +116 -0
  319. package/src/primitives/canvas/ui_markup_text.zig +128 -0
  320. package/src/primitives/canvas/ui_markup_values.zig +368 -0
  321. package/src/primitives/canvas/ui_markup_view.zig +3026 -57
  322. package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
  323. package/src/primitives/canvas/ui_schema.zig +13 -1
  324. package/src/primitives/canvas/ui_schema_tests.zig +11 -7
  325. package/src/primitives/canvas/ui_tests.zig +1 -0
  326. package/src/primitives/canvas/vector.zig +36 -2
  327. package/src/primitives/canvas/vector_effect_policy.zig +236 -0
  328. package/src/primitives/canvas/vector_raster_policy.zig +190 -0
  329. package/src/primitives/canvas/virtual_extent_policy.zig +350 -0
  330. package/src/primitives/canvas/virtual_extents.zig +113 -3
  331. package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
  332. package/src/primitives/canvas/widget_audit_policy.zig +293 -0
  333. package/src/primitives/canvas/widget_change_policy.zig +298 -0
  334. package/src/primitives/canvas/widget_invalidation.zig +113 -2
  335. package/src/primitives/canvas/widget_layout.zig +673 -128
  336. package/src/primitives/canvas/widget_layout_tests.zig +4 -0
  337. package/src/primitives/canvas/widget_metric_policy.zig +129 -0
  338. package/src/primitives/canvas/widget_metrics.zig +45 -6
  339. package/src/primitives/canvas/widget_paint_policy.zig +166 -0
  340. package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
  341. package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
  342. package/src/primitives/canvas/widget_render.zig +744 -74
  343. package/src/primitives/canvas/widget_render_controls.zig +1217 -133
  344. package/src/primitives/canvas/widget_render_scroll.zig +11 -3
  345. package/src/primitives/canvas/widget_render_style.zig +94 -0
  346. package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
  347. package/src/primitives/canvas/widget_routing.zig +75 -0
  348. package/src/primitives/canvas/widget_routing_policy.zig +135 -0
  349. package/src/primitives/canvas/widget_runtime.zig +21 -1
  350. package/src/primitives/canvas/widget_semantics.zig +25 -0
  351. package/src/primitives/canvas/widget_text_input.zig +86 -23
  352. package/src/primitives/canvas/widget_text_select.zig +1 -0
  353. package/src/primitives/canvas/widget_tree.zig +8 -1
  354. package/src/primitives/canvas/widgets.zig +42 -12
  355. package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
  356. package/src/root.zig +26 -0
  357. package/src/runtime/accessibility_policy.zig +122 -0
  358. package/src/runtime/api.zig +29 -0
  359. package/src/runtime/app_dispatch_policy.zig +68 -0
  360. package/src/runtime/authorization_policy.zig +150 -0
  361. package/src/runtime/automation_command_policy.zig +241 -0
  362. package/src/runtime/automation_interaction_policy.zig +107 -0
  363. package/src/runtime/automation_snapshot.zig +52 -22
  364. package/src/runtime/automation_snapshot_reference.zig +290 -0
  365. package/src/runtime/automation_widget_dispatch.zig +267 -355
  366. package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
  367. package/src/runtime/blob_policy.zig +58 -0
  368. package/src/runtime/blob_reference.zig +64 -0
  369. package/src/runtime/bridge_descriptor_policy.zig +206 -0
  370. package/src/runtime/bridge_payload.zig +2 -0
  371. package/src/runtime/builtin_bridge.zig +180 -44
  372. package/src/runtime/builtin_coordination_policy.zig +121 -0
  373. package/src/runtime/callback_policy_test_reference.zig +97 -0
  374. package/src/runtime/canvas_drag_policy.zig +94 -0
  375. package/src/runtime/canvas_fonts.zig +38 -10
  376. package/src/runtime/canvas_frame.zig +590 -134
  377. package/src/runtime/canvas_frame_helpers.zig +1 -0
  378. package/src/runtime/canvas_hover_policy.zig +131 -0
  379. package/src/runtime/canvas_images.zig +59 -30
  380. package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
  381. package/src/runtime/canvas_limits.zig +1 -1
  382. package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
  383. package/src/runtime/canvas_scene_observation_policy.zig +181 -0
  384. package/src/runtime/canvas_widget_context_menu.zig +183 -4
  385. package/src/runtime/canvas_widget_context_menu_test_cases.zig +1147 -0
  386. package/src/runtime/canvas_widget_context_menu_tests.zig +23 -1098
  387. package/src/runtime/canvas_widget_display.zig +110 -9
  388. package/src/runtime/canvas_widget_events.zig +718 -328
  389. package/src/runtime/canvas_widget_runtime.zig +720 -150
  390. package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
  391. package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
  392. package/src/runtime/canvas_widget_state.zig +93 -56
  393. package/src/runtime/channel_sources.zig +80 -0
  394. package/src/runtime/command_policy.zig +161 -0
  395. package/src/runtime/component_policy.zig +83 -0
  396. package/src/runtime/context_menu_policy.zig +112 -0
  397. package/src/runtime/core.zig +170 -6
  398. package/src/runtime/desktop_files.zig +189 -0
  399. package/src/runtime/effects.zig +638 -33
  400. package/src/runtime/effects_host_tests.zig +25 -0
  401. package/src/runtime/effects_tests.zig +28 -0
  402. package/src/runtime/file_policy_test_reference.zig +113 -0
  403. package/src/runtime/flow.zig +419 -341
  404. package/src/runtime/flow_reference.zig +1427 -0
  405. package/src/runtime/font_registry_policy.zig +72 -0
  406. package/src/runtime/frame_profile.zig +24 -33
  407. package/src/runtime/global_shortcuts.zig +75 -0
  408. package/src/runtime/gpu_surface_events.zig +97 -35
  409. package/src/runtime/host_event_pump.zig +303 -0
  410. package/src/runtime/host_event_pump_reference.zig +268 -0
  411. package/src/runtime/host_flow_policy.zig +155 -0
  412. package/src/runtime/host_input_regions_policy.zig +156 -0
  413. package/src/runtime/image_registry_policy.zig +94 -0
  414. package/src/runtime/input_composition_policy.zig +138 -0
  415. package/src/runtime/journal_policy.zig +66 -0
  416. package/src/runtime/journal_reference.zig +53 -0
  417. package/src/runtime/keyboard_input.zig +86 -0
  418. package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
  419. package/src/runtime/markup_development_policy.zig +91 -0
  420. package/src/runtime/media_surface.zig +40 -1
  421. package/src/runtime/motion_sampling_policy.zig +159 -0
  422. package/src/runtime/recording_policy.zig +42 -0
  423. package/src/runtime/render_animation_policy.zig +206 -0
  424. package/src/runtime/replay_policy.zig +66 -0
  425. package/src/runtime/replay_policy_reference.zig +326 -0
  426. package/src/runtime/replay_progress_policy.zig +64 -0
  427. package/src/runtime/replay_progress_reference.zig +34 -0
  428. package/src/runtime/request_policy_test_reference.zig +188 -0
  429. package/src/runtime/root.zig +16 -0
  430. package/src/runtime/scroll_mutation_policy.zig +130 -0
  431. package/src/runtime/scroll_mutation_runtime.zig +158 -0
  432. package/src/runtime/scroll_tree_policy.zig +99 -0
  433. package/src/runtime/session_blobs.zig +157 -58
  434. package/src/runtime/session_blobs_reference.zig +692 -0
  435. package/src/runtime/session_codec.zig +361 -0
  436. package/src/runtime/session_codec_reference.zig +1027 -0
  437. package/src/runtime/session_journal.zig +246 -983
  438. package/src/runtime/session_record.zig +231 -45
  439. package/src/runtime/session_replay.zig +157 -415
  440. package/src/runtime/session_tests.zig +552 -0
  441. package/src/runtime/shell_admission_policy.zig +225 -0
  442. package/src/runtime/shell_coordination_policy.zig +138 -0
  443. package/src/runtime/shell_layout.zig +126 -1
  444. package/src/runtime/snapshot_policy.zig +60 -0
  445. package/src/runtime/snapshot_reference.zig +64 -0
  446. package/src/runtime/staged_rebuild_policy.zig +83 -0
  447. package/src/runtime/state.zig +16 -0
  448. package/src/runtime/status_validation.zig +190 -0
  449. package/src/runtime/system_admission_policy.zig +140 -0
  450. package/src/runtime/system_services.zig +65 -36
  451. package/src/runtime/tests.zig +2 -0
  452. package/src/runtime/ts_canvas_hooks.zig +261 -0
  453. package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
  454. package/src/runtime/ts_canvas_icons.zig +234 -0
  455. package/src/runtime/ts_core_host.zig +2451 -411
  456. package/src/runtime/ts_core_host_tests.zig +1982 -0
  457. package/src/runtime/ts_test_host.zig +699 -0
  458. package/src/runtime/ts_ui_app.zig +1111 -45
  459. package/src/runtime/ui_app.zig +1381 -650
  460. package/src/runtime/ui_app_provenance.zig +147 -5
  461. package/src/runtime/ui_app_provenance_reference.zig +370 -0
  462. package/src/runtime/ui_app_tests.zig +667 -188
  463. package/src/runtime/ui_app_window_tests.zig +222 -0
  464. package/src/runtime/view.zig +25 -0
  465. package/src/runtime/view_canvas.zig +30 -6
  466. package/src/runtime/view_coordination_policy.zig +147 -0
  467. package/src/runtime/view_reload.zig +226 -0
  468. package/src/runtime/view_widget_control.zig +51 -14
  469. package/src/runtime/view_widget_scroll.zig +46 -26
  470. package/src/runtime/view_widget_text.zig +153 -68
  471. package/src/runtime/view_widget_tree.zig +503 -69
  472. package/src/runtime/virtual_window_policy.zig +128 -0
  473. package/src/runtime/web_pane_policy.zig +111 -0
  474. package/src/runtime/web_pane_test_cases.zig +204 -0
  475. package/src/runtime/webview_view_bridge_tests.zig +2 -0
  476. package/src/runtime/widget_continuity_policy.zig +73 -0
  477. package/src/runtime/widget_motion_policy.zig +238 -0
  478. package/src/runtime/widget_reconcile_policy.zig +81 -0
  479. package/src/runtime/widget_retention_policy.zig +75 -0
  480. package/src/runtime/window_command_bridge_tests.zig +63 -0
  481. package/src/runtime/window_lifecycle_policy.zig +127 -0
  482. package/src/runtime/window_storage.zig +74 -8
  483. package/src/runtime/window_view_runtime.zig +148 -33
  484. package/src/runtime/window_views.zig +179 -11
  485. package/src/security/root.zig +1 -0
  486. package/src/tooling/components/identity_tests.zig +62 -36
  487. package/src/tooling/components/stepper.native +24 -0
  488. package/src/tooling/components/stepper.zig +0 -19
  489. package/src/tooling/components/timeline-item.native +22 -0
  490. package/src/tooling/components/timeline.native +5 -3
  491. package/src/tooling/components/timeline_item.zig +0 -32
  492. package/src/tooling/eject_components.zig +76 -8
  493. package/src/tooling/ios.zig +66 -12
  494. package/src/tooling/manifest.zig +35 -0
  495. package/src/tooling/raw_manifest.zig +6 -0
  496. package/src/tooling/templates.zig +23 -3
  497. package/src/tooling/ts_core.zig +97 -4
  498. package/src/tooling/verbs.zig +87 -1
  499. package/tools/corewire/build_profile.mjs +54 -0
  500. package/tools/corewire/contract_intake.ts +303 -0
  501. package/tools/corewire/contract_intake.zig +82 -0
  502. package/tools/corewire/core.test.ts +188 -0
  503. package/tools/corewire/core_abi.zig +55 -0
  504. package/tools/corewire/core_cases.ts +233 -0
  505. package/tools/corewire/core_contract.ts +407 -0
  506. package/tools/corewire/core_emission.ts +136 -0
  507. package/tools/corewire/core_emission.zig +69 -0
  508. package/tools/corewire/core_goldens.json +3110 -0
  509. package/tools/corewire/core_policy.ts +14 -0
  510. package/tools/corewire/core_policy.zig +48 -0
  511. package/tools/corewire/core_projection.ts +361 -0
  512. package/tools/corewire/core_vocabulary.ts +6 -0
  513. package/tools/corewire/emit.zig +19 -1590
  514. package/tools/corewire/emit_facade.ts +714 -0
  515. package/tools/corewire/emit_facade.zig +10 -3752
  516. package/tools/corewire/emit_mirror.ts +300 -0
  517. package/tools/corewire/emit_profile.ts +50 -0
  518. package/tools/corewire/emit_service.ts +331 -0
  519. package/tools/corewire/emit_service.zig +23 -842
  520. package/tools/corewire/entry.test.ts +95 -0
  521. package/tools/corewire/entry_coordination.ts +127 -0
  522. package/tools/corewire/entry_coordination.zig +190 -0
  523. package/tools/corewire/facade_templates.ts +85 -0
  524. package/tools/corewire/filesystem.test.ts +166 -0
  525. package/tools/corewire/filesystem_coordination.ts +213 -0
  526. package/tools/corewire/filesystem_coordination.zig +245 -0
  527. package/tools/corewire/intake.test.ts +39 -0
  528. package/tools/corewire/intake_cases.ts +55 -0
  529. package/tools/corewire/intake_goldens.json +12237 -0
  530. package/tools/corewire/invocation.test.ts +28 -0
  531. package/tools/corewire/invocation.ts +175 -0
  532. package/tools/corewire/invocation.zig +136 -0
  533. package/tools/corewire/invocation_cases.ts +60 -0
  534. package/tools/corewire/invocation_fixture.ts +33 -0
  535. package/tools/corewire/invocation_goldens.json +1143 -0
  536. package/tools/corewire/invocation_tests.zig +111 -0
  537. package/tools/corewire/invocation_usage.ts +2 -0
  538. package/tools/corewire/lossless_projection.ts +96 -0
  539. package/tools/corewire/main.zig +7 -680
  540. package/tools/corewire/main_reference.zig +415 -0
  541. package/tools/corewire/mirror_templates.ts +59 -0
  542. package/tools/corewire/profile.test.ts +248 -0
  543. package/tools/corewire/profile.zig +56 -0
  544. package/tools/corewire/profile_emission.ts +204 -0
  545. package/tools/corewire/profile_library.json +29 -0
  546. package/tools/corewire/profile_tests.zig +136 -0
  547. package/tools/corewire/service.test.ts +75 -0
  548. package/tools/corewire/service_cases.ts +61 -0
  549. package/tools/corewire/service_contract.zig +40 -146
  550. package/tools/corewire/service_goldens.json +650 -0
  551. package/tools/corewire/service_projection.zig +52 -0
  552. package/tools/corewire/service_templates.ts +14 -0
  553. package/tools/corewire/shim_rt.zig +9 -0
  554. package/tools/corewire/sidecar.zig +269 -1438
  555. package/tools/corewire/emit_profile.zig +0 -521
@@ -19,7 +19,7 @@ native check # subset-check core.ts + validate markup + app.json/app.zon
19
19
  native build # ReleaseFast binary; native test runs the app's tests
20
20
  ```
21
21
 
22
- The complete reference app in this idiom is `examples/soundboard-ts` in the SDK repo: the soundboard music library as three files and zero Zig — const catalog tables, REAL audio through the `Cmd.audioPlay` stream, scrub-to-seek on a markup slider, a motion-gated `Sub.timer` playback clock, the full text-edit engine on a search field, controlled scroll, registered cover assets, the width-adaptive grid through the frame channel, clipboard, and context menus, with an end-to-end suite driving the shipping markup.
22
+ The complete reference app in this idiom is `examples/soundboard` in the SDK repo: the soundboard music library as three files and zero Zig — const catalog tables, REAL audio through the `Cmd.audioPlay` stream, scrub-to-seek on a markup slider, a motion-gated `Sub.timer` playback clock, the full text-edit engine on a search field, controlled scroll, registered cover assets, the width-adaptive grid through the frame channel, clipboard, and context menus, with an end-to-end suite driving the shipping markup.
23
23
 
24
24
  ## The contract
25
25
 
@@ -46,6 +46,10 @@ export function update(model: Model, msg: Msg): Model {
46
46
  - Update-only state (fields, helpers, or Msg kinds nothing in markup binds or dispatches — host-fired timer arms, persistence bookkeeping) is declared once: `export const viewUnbound = ["nextId", "tick"] as const;`. It emits as the `view_unbound` opt-out `native check`'s unbound-state lint reads; a name outside the model surface is a taught NS1032. Entries are the TypeScript names exactly as declared (`"nextId"`) and Msg kinds as their `kind` tags — the same names markup binds, because there are no other names.
47
47
  - Names: your names are your names — fields, helpers, and locals emit into Zig with their TS spellings (`doneToday` stays `doneToday`), and markup binds them verbatim. String-literal unions emit as native enums.
48
48
 
49
+ ## Tests against the compiled app
50
+
51
+ Put Node test files directly in `tests/*.test.ts` and run `native test`. Import `NativeApp` and `findWidget` from `@native-sdk/core/testing` **only in tests**, never in `src/core.ts`. Each `NativeApp.start()` launches a separate headless native process with the real scriptc-compiled core and markup. Drive `click`/`action`/`menu`, assert returned model and accessibility snapshots, inspect and answer fake requests with `respond`, and fire declared timers with `fireTimer`. Supply explicit declared launch values with `NativeApp.start({ environment: [{ name: "APP_MODE", value: "manual" }] })`; they are journaled and replay does not read ambient environment. Framework app directories still use `appDataDirectory`. Always `close()` in `finally` or use `await using`. `verifyReplay()` verifies checkpoints and the final model in a fresh runtime; afterward only snapshot/close are allowed. Model bytes are JSON number arrays; native identities are decimal strings. The host uses a fixed clock and fake effects, without production persistence/services/app-data startup. See https://native-sdk.dev/docs/testing for the complete API and limits.
52
+
49
53
  ## The arena mental model
50
54
 
51
55
  Everything `update` builds lives in a per-dispatch bump arena that is freed wholesale after the returned model is committed, so spreads, `map`, and `filter` are cheap by construction. At commit, only nodes your update actually created are copied into the persistent model heap — everything you spread through unchanged is shared with the previous model for free.
@@ -98,7 +102,7 @@ Logic:
98
102
  - **Exceptions — `throw`/`try`/`catch`/`finally` as pure control flow.** Inside a core, exceptions are deterministic: `throw` carries a subset VALUE and unwinds to the nearest enclosing `catch` — across helper calls, out of array-method callbacks (a `throw` inside `.map`'s callback exits the whole loop, like JS), through nested `try`s, with `finally` running on every path (fall-through, `return`, `break`/`continue`, and throw alike). The discipline is two rules. First (NS1057): thrown values are kind-tagged subset shapes — throw kind-discriminated records (`throw { kind: "bad_digit", at: i } as ParseError`, where `ParseError` is an interface with a string-literal `kind` field or a `kind`-discriminated union; a single-shape core may also throw a number), and SEVERAL distinct shapes may throw: the checker collects every shape the core throws into its implicit thrown union. The catch binding IS that union — narrow it in place with kind tests, no `as` ceremony: `catch (e) { if (e.kind === "bad_digit") return -e.at; if (e.kind === "io") return e.code; return -1; }` (or `switch (e.kind)` — tsc cannot prove exhaustiveness over the implicit union, so give the switch a `default` or a trailing return). Bare rethrow (`throw e;`) re-raises the bound value — a narrowed arm included — and `catch { ... }` needs no binding; the single-`as` form (`const err = e as ParseError;`) stays legal in single-shape cores (and for a DECLARED union whose arms equal the thrown set — declare `type AppError = ... | ...` and `as AppError` works). What teaches: untagged values in a heterogeneous set, two shapes sharing one `kind` with different payloads, asserting one member shape of a multi-shape core, the binding escaping untyped into a call/store/return, and `throw new Error(...)` (engine error objects carry stack traces with no native layout). Second (NS1058): `finally` never redirects control flow — no `return`/`throw`/`break`-out inside it (JS's own no-unsafe-finally rule; loops fully inside the finally may break within themselves). An UNCAUGHT throw that reaches an exported function's boundary is a defined deterministic panic — exactly where node's process would crash. A throw mid-mutation of an owned array keeps the mutations applied so far, exactly like JS — the catch sees the array as node would.
99
103
  - **Local function values — const helpers hoist.** `const scale = (x: number): number => x * 3;` (arrow or `function` expression) hoists to an ordinary module-level fn when it is capture-free (module constants and other const helpers are fine to reference; enclosing locals/params are not — pass them as parameters), fully annotated (every parameter and the return type), and used only by direct calls (`scale(v)`, recursion included) or as an array-method callback (`xs.map(scale)`, comparators included). Everything else teaches NS1054: captures, missing annotations, `let` bindings, returning/storing the value, passing it to your own functions, calling through a record field. Capturing a locally-owned array also ENDS its ownership at the capture (a later mutation is the NS1051 teach) — the stored closure would retain the reference.
100
104
 
101
- Not yet in v1 — genuine roadmap deferrals, each stopping with a loud, tailored NS9001 naming the rewrite (never missing basic syntax; the banned-with-a-rule families live in "What the subset means" above). The rule-level deferrals carry `class: "deferred"` in the diagnostics catalogue — NS1011 (Map/Set), NS1019 (fixed arity), NS1040 (regexes), NS1042 (generators), NS1044 (BigInt/Symbol) — and their diagnostics say the capability is deliberately deferred, not impossible; the list below is the method-level remainder: `.toSorted()`/`.sort()` without a comparator (JS ToString ordering; pass `(a, b) => a - b`), `.reduce` without an initial value (a taught NS1007 — JS throws on an empty array) or with an index parameter (use a classic loop), `.indexOf`/`.includes` on record arrays (match a field with `.find`/`.findIndex`), `.join` on number arrays (elements are float-valued; join byte values instead), float values (`/`, `**`, `Math.round`, `Math.sqrt`, float `Math.floor`-family results) where an integer is required such as an index (a taught NS1016 — those values can be fractional or NaN), Math methods beyond the batch above, `Number` methods beyond the three classifiers, float-valued template holes (JS float-to-string fidelity is a runtime v2 surface), arrays of unions (`readonly View[]`) or arrays of byte-strings (`readonly Uint8Array[]`) as model fields (wrap the element in a single-field interface), a collect spawn's stderr tail (v1 delivers the exit code and stdout; stderr is not surfaced — put diagnostics on stdout or check the code), per-line truncation flags (a stdout or response line over its configured bound arrives cut, without a flag), and non-timer subscriptions (`Sub.timer` is the one subscription; one-shot needs are `Cmd.delay`, and process/fetch/audio streams are Cmd-initiated, not subscribed).
105
+ Not yet in v1 — genuine roadmap deferrals, each stopping with a loud, tailored NS9001 naming the rewrite (never missing basic syntax; the banned-with-a-rule families live in "What the subset means" above). The rule-level deferrals carry `class: "deferred"` in the diagnostics catalogue — NS1011 (Map/Set), NS1019 (fixed arity), NS1040 (regexes), NS1042 (generators), NS1044 (BigInt/Symbol) — and their diagnostics say the capability is deliberately deferred, not impossible; the list below is the method-level remainder: `.toSorted()`/`.sort()` without a comparator (JS ToString ordering; pass `(a, b) => a - b`), `.reduce` without an initial value (a taught NS1007 — JS throws on an empty array) or with an index parameter (use a classic loop), `.indexOf`/`.includes` on record arrays (match a field with `.find`/`.findIndex`), `.join` on number arrays (elements are float-valued; join byte values instead), float values (`/`, `**`, `Math.round`, `Math.sqrt`, float `Math.floor`-family results) where an integer is required such as an index (a taught NS1016 — those values can be fractional or NaN), Math methods beyond the batch above, `Number` methods beyond the three classifiers, float-valued template holes (JS float-to-string fidelity is a runtime v2 surface), arrays of unions (`readonly View[]`) or arrays of byte-strings (`readonly Uint8Array[]`) as model fields (wrap the element in a single-field interface), a collect spawn's stderr tail (v1 delivers the exit code and stdout; stderr is not surfaced — put diagnostics on stdout or check the code), per-line truncation flags (a stdout or response line over its configured bound arrives cut, without a flag), and subscriptions beyond `Sub.timer`, `Sub.globalShortcut`, and generated live queries (one-shot needs are `Cmd.delay`, and process/fetch/audio streams are Cmd-initiated, not subscribed).
102
106
 
103
107
  ## Effects are Cmd data
104
108
 
@@ -149,6 +153,7 @@ These map directly onto the host's effect engine — files, HTTP, the clipboard,
149
153
  - `Cmd.openExternalUrl(url)` — open an HTTP(S) URL in the system browser, fire-and-forget. `url` is bytes; the runtime validates it and enforces `security.navigation.external_links` before entering the platform service. Invalid, denied, or unavailable requests fail closed; fake execution and replay never open one.
150
154
  - `Cmd.revealPath(path)` — reveal a byte path in Finder, Files, or Explorer, fire-and-forget. Runtime path validation stays in force; invalid or unavailable requests fail closed, and fake execution/replay never reveal one.
151
155
  - `Cmd.credentials.set(key, secret, { key?, ok, err })` / `Cmd.credentials.get(key, route)` / `Cmd.credentials.delete(key, route)` — app-scoped Keychain on macOS/iOS, Secret Service/libsecret on Linux, Credential Manager on Windows, and AndroidKeyStore-wrapped authenticated ciphertext on Android. The authored credential key is a NUL-free string (UTF-8, ≤256 bytes); the manifest app id (≤128 bytes) supplies the service namespace, and secrets are `Uint8Array` values through 2,560 bytes (the cross-platform floor set by WinCred). Set/delete deliver empty bytes on `ok`; get delivers secret bytes; the closed err reasons are `miss`, `denied`, `locked`, `io_failed`, `over_bound`, and `rejected`. Declare BOTH `"credentials"` in `app.zon` capabilities and permissions; NS1071 warns when the capability is absent, NS1072 errors when permission is absent, and NS1073 reserves `core.credentials.*` for the typed factories. Never retain a returned secret in Model: consume its Msg immediately to construct the next effect. Recording stores only a successful get's length, per-session salt, and a placeholder digest independent of the secret (never the secret or a blob); replay delivers deterministic same-length placeholder bytes, and devhost keeps an in-memory map while printing only `<redacted, N bytes>`.
156
+ - `Cmd.keyboard.sendChord({ key, primary?, command?, control?, option?, shift? }, { key?, ok, err })` / `Cmd.keyboard.accessStatus({ prompt? }, route)` — send a key chord into whichever app has keyboard focus (other apps, through the OS; this is not in-app automation). The chord has the `Sub.globalShortcut` binding shape (`key` is `asciiBytes` from the shortcut key vocabulary) but needs no modifier. Both arms carry one `Uint8Array`: chord `ok` is empty, access `ok` is `granted`, `denied`, or `not_required`. Err reasons are `rejected` (missing `"keyboard_input"` permission — NS1075 catches it at check time, including raw `native-sdk.keyboard.*` requests), `unsupported` (Linux, mobile), `invalid_request`, `denied` (macOS Accessibility not granted; nothing posted), `blocked` (Windows refused the input), and `failed`. `ok` means posted, not delivered: Windows drops input to elevated windows without an error. Do not send a chord equal to one of the app's own global shortcuts. Replay, fake execution, and devhost never post input.
152
157
  - `Cmd.formatLocalTime(timestampMs, "date" | "time" | "datetime", { key?, ok, err })` — format epoch milliseconds (the same unit `Cmd.now` produces) through the host's current locale and local time zone; `ok` carries localized UTF-8 bytes. This is deliberately an effect rather than a pure helper: locale/timezone are ambient state, so the observed bytes journal and replay without consulting the replay machine. Err reasons are `invalid_request`, `unsupported`, and `failed`.
153
158
  - `Cmd.delay(key, ms, "fired")` — a keyed ONE-SHOT timer: dispatches the named arm once, `ms` from now, with the fire time (ms) as its single number payload (the same arm shape `Cmd.now` and `Sub.timer` target). Re-issuing a live delay key re-arms it from now — that is the debounce discipline (`Cmd.delay("autosave", 800, "save_now")` on every keystroke, one fire after the pause). `Cmd.cancel(key)` drops it silently. The interval is 1ms to one year; a literal outside that stops the build (NS1030).
154
159
 
@@ -167,16 +172,38 @@ Four effect families deliver MANY results from one command — a keyed stream th
167
172
  - `Cmd.audioPause(key)` / `Cmd.audioResume(key)` / `Cmd.audioStop(key)` / `Cmd.audioSeek(key, ms)` / `Cmd.audioSetVolume(key, volume)` — fire-and-forget control verbs: no result of their own; their consequences arrive on the event stream (`audioResume` on a dead player reports one `"failed"` event, never silence). A verb whose key names no open stream is a no-op. `audioStop` is the audio stream's close — no events for the key after it (`Cmd.cancel` does not apply to audio). Volume is clamped 0..1 and remembered across tracks; a literal outside 0..1 (or a negative seek literal) stops the build (NS1030).
168
173
  - `Cmd.channelOpen(key, { event })` — open an EXTERNAL-SOURCE channel under the app's numeric key: the host stages a long-lived, thread-safe posting seam its NATIVE side feeds — embedders and platform-services extensions post bytes from their own threads (sockets, watchers, workers), and each accepted post dispatches the `event` arm as one `"data"` event. Posting is deliberately not a TS verb — compiled cores are single-threaded, so the core opens, closes, and receives while the posting handle lives on the native side (`Effects.channelHandle(key)`). `key` may be any number expression, a positive integer below 2^53 (a certain-to-be-refused literal stops the build, NS1030). The `event` arm is a five-field record matched by NAME: `key` (the channel key echoed verbatim, so concurrent channels sharing one arm stay distinguishable; a key the wire cannot carry exactly echoes 0), `state` (the `ChannelState` union — import it from `@native-sdk/core` or declare an alias with exactly the three members `"data" | "closed" | "rejected"` in any order; checked BOTH directions, since a narrower union would silently drop states the host emits), `bytes` (`Uint8Array` — the post's payload on `"data"` events, empty otherwise), and `droppedPending`/`droppedTotal` (numbers — the honest back-pressure counters: posts the native handle refused since the previous delivered event, and over the channel's whole life; refused posts count, never silence). One channel per key at a time — a duplicate live key dispatches `"rejected"` — and the key shares the engine's effect-key space (a same-key fetch is blocked while the channel lives). No timer polling anywhere: the source wakes the loop itself. Channel events journal at the effect boundary, so recorded sessions replay the whole stream from the journal — the native posting side is never needed at replay (a native producer that consults `ChannelHandle.live()` before launching keeps replay fully offline; one that launches unconditionally is stopped at its first post, which answers `.closed`).
169
174
  - `Cmd.channelClose(key)` — close the open channel under the key, if any: staged posts flush, exactly one `"closed"` event (final drop totals aboard) dispatches the event arm, and the key frees. A key with no open channel no-ops.
175
+ - `Cmd.channelOpenSource(key, source, payload, { event, started })` opens a channel and starts an explicit native producer only for that newly accepted occupancy. The `started` arm has exactly `key: number`, `state: "started" | "skipped" | "failed"`, and `bytes: Uint8Array`; it runs in command order before the settled view. A refused open skips startup and still delivers the ordinary channel rejection. Startup failure carries the native error name; close that channel with `Cmd.channelClose`. Source names are 1–255 UTF-8 bytes and arguments at most 4096 bytes. The built-in `"native-sdk.process.samples"` source takes empty arguments and posts process readings every 500 ms. Native embedders can inject `Effects.channel_sources`; starters copy borrowed arguments before returning and must be quick and nonreentrant. Native recording journals startup results and replay never invokes the producer. The fake and virtual hosts report `UnsupportedChannelSource` unless a native test injects a starter; virtual-host recording of external producers requires the native runtime. See `examples/channel-monitor`.
170
176
  - `Cmd.audioCaptureStart(key, { source, sampleRate?, channels? }, { event })` — start a native `"microphone"` or `"system"` audio stream. The host converts into interleaved signed-16 little-endian PCM at 16/24/48 kHz and mono/stereo (default 48 kHz mono), in chunks no larger than 20 ms. The ten-field event arm is matched by NAME: `key`, `state` (exactly `"started" | "data" | "failed" | "stopped" | "rejected"`), `source` (exactly `"microphone" | "system"`), `sampleRate`, `channels`, `timestampMs`, `frames`, `pcm`, `droppedPending`, and `droppedTotal`. PCM is dispatch-lifetime bytes; the commit walker copies it when stored in the model. The bounded queue, wake behavior, drop accounting, journaling, and offline replay are the channel transport's. Microphone and system may run concurrently; a second start for one source replaces that source's prior key.
171
177
  - `Cmd.audioCaptureStop(key)` — synchronously quiesce native callbacks, flush already accepted chunks, deliver exactly one `"stopped"` terminal, and free the key. The key remains occupied until that terminal is delivered, so wait for `"stopped"` before reusing it; an earlier restart is rejected. A missing key no-ops. Declare `"microphone"` and/or `"system_audio"` in `app.zon` permissions so macOS dev executables and packaged apps carry the required usage descriptions.
172
178
  - `Cmd.imageLoad(id, { path?, url?, cachePath?, expectedBytes? }, { event })` — load an image at runtime under the model-owned NUMERIC ImageId your markup binds (`<image image="{cover}"/>`, `<avatar image="{avatar}"/>`); `id` may be any number expression (ids are model data), a positive integer below 2^53 (a certain-to-be-refused literal like 0 stops the build, NS1030). The source cascade is `audioPlay`'s exactly: local `path` first, a missing file falls through to `url` (fetched whole, installed at the cache path and integrity-gated by `expectedBytes`); at least one of `path`/`url` (NS1029), and prefer OMITTING `cachePath` — the wiring's caches directory (`TsUiApp`'s `image_cache_dir`) derives the content-addressed path from the URL. Exactly ONE `event` arm dispatches per load — a five-field record matched by NAME: `id` (the requested ImageId echoed verbatim, so concurrent loads sharing one arm stay distinguishable; an id the wire cannot carry exactly echoes 0), `state` (the `ImageState` union — exactly the fifteen members `"loaded" | "rejected" | "not_found" | "io_failed" | "connect_failed" | "tls_failed" | "protocol_failed" | "timed_out" | "http_status" | "cancelled" | "too_large" | "unsupported" | "decode_failed" | "registry_full" | "alloc_failed"`, any order; `"alloc_failed"` is resource exhaustion at registration — the host refused the memory, the bytes may be fine, retry when memory frees), `width`/`height` (the actual registered dimensions on `"loaded"`, 0 otherwise), and `status` (the HTTP status for url loads that performed an exchange; 0 when none occurred — local paths, cache hits — so a cached `"loaded"` is distinguishable from a network one). On `"loaded"` the pixels are already registered under the id — store the id in the model then (the store-on-success discipline keeps a fallback rendering until the load lands). One load per id at a time: a duplicate live id dispatches `"rejected"` (the spawn discipline — a load in flight is never replaced implicitly), and image loads are not the string-keyed `Cmd.cancel`'s to end — `Cmd.imageCancel(id)` is their cancel, LOUD like spawn's: the one terminal still arrives as the event arm's `"cancelled"`, and the id frees for a fresh load once it lands (an id with no live load no-ops; the same NS1030 literal gate as `imageLoad`). The default registry has 16 slots and a 1 MiB decoded-pixel target per slot: platform codecs downscale photo-size sources at decode time, preserving aspect, instead of rejecting them. Image-centric apps may declare `.images = .{ .max_image_pixel_bytes = 8388608 }` in app.zon (1–8 MiB accepted); allocation stays lazy per used slot, but filling 16 ceiling-sized slots is a declared 128 MiB high-water. Encoded sources have their own flat 8 MiB bound; only over-bound source bytes report `"too_large"` in normal operation, never a cut decode. `Cmd.imageUnregister(id)` releases a loaded image's registry slot — the gallery eviction move when the 17th distinct image would answer `"registry_full"`: views bound to the id fall back, and the slot accepts the next load. Unregister is synchronous registry surgery, NOT an effect — no result Msg, an unregistered id no-ops (the same NS1030 literal gate) — and it frees only the CURRENT registration: a load in flight under the id still registers at its terminal, so cancel the load first (`Cmd.imageCancel`) to keep the slot free.
173
179
 
180
+ ### Complete capability results and playback snapshots
181
+
182
+ `Cmd.spawnEvents(argv, { key?, stdin?, collect?, line?, exit })` routes every native subprocess field. Its line arm has `key: Uint8Array`, `line: Uint8Array`, `truncated: boolean`, and `droppedBefore: number`. Its exit arm has `key`, `code`, `reason` (`"exited" | "signaled" | "cancelled" | "rejected" | "spawn_failed"`), `droppedLines`, `output`, `outputTruncated`, `stderrTail`, and `stderrTruncated`. Bytes and booleans retain their ordinary types; counts and code are numbers. Duplicate pending keys reject without cancelling the original stream. Cancellation supplies the complete cancelled terminal.
183
+
184
+ `Cmd.spawnEventsExact(key, argv, { stdin?, collect?, line?, exit })` uses the same complete result arms with an exact native identity: `key` is canonical unsigned decimal ASCII bytes, from `"0"` through `"18446744073709551615"`. The native engine owns request copying, duplicate-key refusal, cancellation and terminal delivery; each refused request retains its own route while the original child continues. Empty argv, more than 16 arguments, over-bound argument bytes or stdin produce the ordinary rejected terminal. The command wire carries at most 255 argument entries. `Cmd.cancelExact(key)` cancels by that exact native identity and retains the ordinary terminal route. Malformed identities trap before an engine call.
185
+
186
+ `Cmd.clipboardWriteResult(bytes, { key?, result })` routes a complete arm with `key`, `operation` (`"read" | "write"`), `outcome` (`"ok" | "failed" | "rejected" | "cancelled"`), `text`, and `droppedBefore`. It preserves rejection and cancellation rather than dropping completion. `Cmd.clipboardWrite` remains the fire-and-forget form.
187
+
188
+ `Cmd.videoSnapshot({ snapshot })` captures current playback state when the command is issued and replies within the same dispatch, in command order like `Cmd.now`. Its arm carries `key: Uint8Array`, `active`, `surface`, `playing`, `buffering`, `completed`, `looping`, `muted`, `source` (`"local" | "stream"`), `positionMs`, `durationMs`, `width`, `height`, and `volume`. Flags are booleans and numeric mirrors are numbers. The key is empty when the playback belongs to another owner. `Cmd.videoRestart(key)` restarts completed playback and retains ownership for later keyed commands. See `examples/effects-probe` and `examples/video-player` for complete cores and views.
189
+
190
+ `Cmd.wallTime(msgKind)` supplies the journaled signed-i64 wall clock as canonical decimal bytes, preserving values outside the exact JavaScript-number range. Use a single-byte-payload arm.
191
+
192
+ `Cmd.readFileResult(path, { key?, result })` and `Cmd.writeFileResult(path, bytes, { key?, result })` supply the full file terminal: `key`, `operation`, `event`, `outcome`, `bytes`, `totalBytes`, `mtimeMs`, `exists`, and `droppedBefore`. Import `FileResultArm` for the complete shape. Totals and signed modification times are canonical decimal bytes. Named requests replace earlier requests and cancel silently; unrelated live capability owners and full tables return a complete `"rejected"` record. The virtual host returns explicit refusals because it performs no ambient filesystem IO.
193
+
194
+ `Cmd.host("native-sdk.debug.log", bytes)` writes up to 4096 raw bytes to native stderr for cadence diagnostics. The fake executor and replay suppress the send; it adds no effect journal record.
195
+
196
+ `Cmd.timerResult(key, afterMs, "one_shot" | "repeating", { result })` supplies `key: Uint8Array`, `timestampNs: Uint8Array`, and `outcome: "fired" | "rejected"`. `Cmd.timerResultExact` accepts canonical unsigned decimal ASCII bytes for the interval, through `18446744073709` ms (the native nanosecond conversion limit). Zero, malformed values, and larger intervals deliver the rejected terminal. Ordinary number timers retain their one-year bound. Repeating timers stay armed after a fire; rearming replaces the same key; cancellation is silent. Rejection includes the requested key. See `examples/notes` for persistence coalescing and relative-time refresh.
197
+
198
+ `commandMsg` may accept a `string` or `Uint8Array`; the checked contract selects the matching command ABI. Byte input preserves the command spelling without an ASCII conversion.
199
+
174
200
  ### The window verbs
175
201
 
176
202
  The menu-bar lifecycle verbs are fire-and-forget, with no result Msg (the window's own frame event carries visibility state):
177
203
 
178
204
  - `Cmd.showWindow(label)` — un-hide + activate the window with the declared label (a string literal — window labels are declarations, in `app.zon` or a `windows_fn` descriptor): the counterpart to a `close_policy = "hide"` close and the tray "Open" consequence; also restores a minimized window. An unknown label is a no-op.
179
205
  - `Cmd.hideWindow(label)` — order a live window out without closing it; native identity and views remain, and `showWindow` is the inverse.
206
+ - `Cmd.closeWindow(label)` / `Cmd.minimizeWindow(label)` — perform the native close or minimize action for an app-drawn window control. Close follows the window's ordinary policy, including normal shutdown when the last window closes. Unknown labels no-op; the fake executor retains complete request counters and copied labels. Model-declared secondary windows usually close by removing their descriptor.
180
207
  - `Cmd.setDockPresence(visible)` — on macOS, switch between a regular Dock/app-switcher app and accessory/headless behavior; unsupported hosts ignore it.
181
208
  - `Cmd.quitApp()` — the graceful terminate, and the tray "Quit" consequence: the host quits through the SAME shutdown path a last-window close takes, so the stop hook runs exactly once and a recording session seals its journal.
182
209
 
@@ -217,7 +244,7 @@ Commands are constructed inline in the return path and nowhere else (NS1017): ne
217
244
 
218
245
  Export `windows(model): readonly WindowDescriptor[]` to derive the secondary windows that should exist from committed model state. Import `WindowDescriptor` from `@native-sdk/core/events`, and construct entries with `windowDescriptor` from `@native-sdk/core` so omitted fields receive the canonical defaults. Presence is liveness: adding a descriptor creates the window, removing it closes the window and releases its retained view.
219
246
 
220
- Each possible label has a statically compiled Native markup view at `src/windows/<label>.native`; for example descriptor label `settings` uses `src/windows/settings.native`. Spell that identity directly inside the canonical constructor as `label: asciiBytes("settings")`: window labels are static declarations, and `native check`/every build reject a dynamic label or one whose root file is missing. Window roots may import shared components nested under `src/windows/` with the ordinary `<import>` syntax; the generated launcher embeds and hot-reloads the full import closure. The descriptor's `canvasLabel` must be unique across the whole app. Both the main view and every open window view rebuild from the same model after a Msg.
247
+ Each possible label has a statically compiled Native markup view at `src/windows/<label>.native`; for example descriptor label `settings` uses `src/windows/settings.native`. Spell that identity directly inside the canonical constructor as `label: asciiBytes("settings")`: window labels are static declarations, and `native check`/every build reject a dynamic label or one whose root file is missing. Window roots may import components nested under `src/windows/` with the ordinary `<import>` syntax. The main `src/app.native` view can import component files anywhere under `src/`; the generated launcher embeds both source sets and hot-reloads each imported closure. The descriptor's `canvasLabel` must be unique across the whole app. Both the main view and every open window view rebuild from the same model after a Msg.
221
248
 
222
249
  ```ts
223
250
  import { asciiBytes, windowDescriptor } from "@native-sdk/core";
@@ -245,6 +272,12 @@ export function windows(model: Model): readonly WindowDescriptor[] {
245
272
 
246
273
  `titlebar` accepts `"standard"`, `"hidden_inset"`, `"hidden_inset_tall"`, and `"chromeless"`. The last removes all OS chrome and is required when a transparent model-declared window targets Windows; provide working app-drawn close/minimize controls for that fully skinned shape.
247
274
 
275
+ ### Model-declared WebView panes
276
+
277
+ Export `webPanes(model: Model): readonly WebViewPane[]` from `core.ts`, importing `WebViewPane` from `@native-sdk/core/events`. Each descriptor supplies byte `label` and `url`, nullable byte `anchor`, numeric `x`, `y`, `width`, `height`, and `reloadToken`. The label names an existing manifest WebView parented to the canvas. An anchor names a canvas widget's semantics label and uses its measured bounds; `anchor: null` uses the explicit frame. A URL change navigates, and a token change reloads.
278
+
279
+ The adapter copies helper-result bytes into native-owned storage before OS reconciliation. It consumes the first four descriptors in declaration order. Labels are bounded to 64 bytes, anchors to 256 bytes, and URLs to the platform's URL budget. Geometry must fit finite f32 canvas points; dimensions are nonnegative. Reload tokens are nonnegative safe integers. Navigation still obeys manifest origin policy. Panes reconcile after rebuild and presentation; they do not create WebViews or bypass OS policy.
280
+
248
281
  ### The init command
249
282
 
250
283
  `initialModel` may return the same pair to run a boot effect once at install, before the first view build — loading a store is the canonical use:
@@ -278,6 +311,7 @@ export function subscriptions(model: Model): Sub<Msg> {
278
311
 
279
312
  - `Sub.none` — no subscriptions (everything paused).
280
313
  - `Sub.timer(key, everyMs, "tick")` — a repeating timer named by its string-literal key; each fire dispatches the named arm with the current time (ms) as its single number payload (the same arm shape `Cmd.now` targets). The interval may derive from the model.
314
+ - `Sub.globalShortcut("talk", { key: asciiBytes("space"), option: true }, "talk")` — a system-wide shortcut that fires while other apps have focus, registered while declared and re-registered when the binding changes. The arm is exactly `{ id: Uint8Array; state: GlobalShortcutState }` (import the state from `@native-sdk/core/events`); states are `registered`, `pressed`, `released`, `conflict`, `unsupported`, and `rejected`. Up to 16 per app with unique 1-64 byte ids, and every key except `f1`-`f12` needs a modifier other than Shift; a bad or duplicate id, a 17th shortcut, or a bad binding reports `rejected`, and a combination another shortcut owns reports `conflict`. macOS and Windows only; Linux reports `unsupported`.
281
315
  - `Sub.batch([...])` — several at once.
282
316
 
283
317
  Sub values follow the Cmd purity rule with their own home (NS1025): built inline in `subscriptions`' return path, never stored, never returned from anywhere else. Debounced re-arm falls out of reconciliation — change the key or interval and the timer re-arms; drop it from the set and it stops.
@@ -294,10 +328,33 @@ One caveat for node-side pokes: the build resolves the `@native-sdk/core*` speci
294
328
  - **`src/` is the boundary**: `../` escapes and absolute paths are taught (NS1034); bare npm specifiers are taught (NS1035 - vendor the code under `src/` or make the import `import type`). Only `@native-sdk/core` (the intrinsic Cmd/Sub/asciiBytes/utf8Bytes surface) and the SDK library modules below carry runtime meaning from outside.
295
329
  - **Everything module-level is importable**: interfaces, literal-union aliases, discriminated unions, module `const` numbers and tables, and helper functions all cross files (renamed imports and `import * as ns` namespace aliases both work — the alias is dot-syntax over the same flat namespace, never a value of its own). Export lists and value re-exports work too: `export { helper, doneCount as remaining }` binds names over existing declarations, and `export { parsePs } from "./parsers.ts"` forwards another module's export by name (a renamed binding emits as a flat-namespace alias). Type names and EXPORTED value names must be unique across the core's files (NS1038 - declare once, import where used; renamed exports claim their new names in the same namespace); colliding PRIVATE helpers are fine (the compile uniques them per module).
296
330
  - **No runtime import cycles** (NS1036). `import type` back-edges are legal and idiomatic: a helper module type-imports `Model` from `./core.ts` while `core.ts` runtime-imports the helpers - that is the expected shape, not a smell.
297
- - **The entry contract (NS1014)**: `update`, `initialModel`, `subscriptions`, the wiring channels (`commandMsg`/`keyMsg`/`frameMsg`/`pinchMsg`/`dropMsg`/`appearanceMsg`/`chromeMsg`/`envMsgs`), the model-derived launcher helpers (`themeState`/`themePack`/`statusItem`), and `viewUnbound` are DECLARED in `core.ts` and exported under their own names (`export` on the declaration or an un-renamed `export { update }` list entry — a rename or a re-export from an imported module cannot bind an entry point) - imports may FEED them, never replace them. The markup binding surface is also entry-only: an exported single-Model-parameter helper binds (`{doneCount}`) only when it is DECLARED in `core.ts` — export lists participate under their exported names (`export { taskTotal as taskCount }` binds `{taskCount}`), but a re-export of an imported helper does not bind (under node the app's module object is the entry's exports, so it would bind natively but not exist under node). Imported modules export cross-module API for update and the entry helpers to call.
331
+ - **The entry contract (NS1014)**: `update`, `initialModel`, `subscriptions`, the wiring channels (`commandMsg`/`keyMsg`/`frameMsg`/`pinchMsg`/`dropMsg`/`appearanceMsg`/`chromeMsg`/`envMsgs`), the model-derived launcher helpers (`themeState`/`themePack`/`statusItem`/`webPanes`), and `viewUnbound` are DECLARED in `core.ts` and exported under their own names (`export` on the declaration or an un-renamed `export { update }` list entry — a rename or a re-export from an imported module cannot bind an entry point) - imports may FEED them, never replace them. The markup binding surface is also entry-only: an exported single-Model-parameter helper binds (`{doneCount}`) only when it is DECLARED in `core.ts` — export lists participate under their exported names (`export { taskTotal as taskCount }` binds `{taskCount}`), but a re-export of an imported helper does not bind (under node the app's module object is the entry's exports, so it would bind natively but not exist under node). Imported modules export cross-module API for update and the entry helpers to call.
298
332
  - **SDK library modules**: `@native-sdk/core/text` ships the byte-splice text engine - `applyTextInputEvent(state, event, capacity)` / `clampedInsertEvent` over `TextEditState` (the full caret/word/selection/IME reducer for markup text controls), plus `containsIgnoreCase`, `orderIgnoreCase`, and `trimAsciiSpaces`. `@native-sdk/core/events` ships the canonical event record types (`TextInputEvent` re-exported, `ScrollState`, `FrameEvent`, `KeyEvent`, `PinchEvent`, `FileDropEvent`, `ColorScheme`/`AppearanceEvent`, `ChromeInsets`/`ChromeButtons`/`ChromeEvent`, `AudioState`/`AudioEvent`, `AudioCaptureState`/`AudioCaptureSource`/`AudioCaptureEvent`) so no core re-types the vocabulary. Unlike `@native-sdk/core` (intrinsic, never compiled into the core) these are ordinary subset TypeScript, compiled INTO your core when imported and absent when not. Under node they resolve like the core module itself. One namespace rule to know (NS1038): module-scope names are unique across the whole import graph, so a core that imports an SDK event type deletes its own in-file mirror of that name.
299
333
 
300
- The reference splits are `examples/soundboard-ts` (core.ts + library.ts + player.ts + the SDK text engine), `examples/system-monitor-ts` (core.ts + parsers.ts + table.ts + the SDK text engine), and `examples/chatbot` (core.ts + api.ts — the JSON-over-bytes wire-format reference: request encoding and a targeted parse walk that returns `null` on anything malformed) in the SDK repo.
334
+ The reference splits are `examples/soundboard` (core.ts + library.ts + player.ts + the SDK text engine), `examples/system-monitor` (core.ts + parsers.ts + table.ts + the SDK text engine), and `examples/chatbot` (core.ts + api.ts — the JSON-over-bytes wire-format reference: request encoding and a targeted parse walk that returns `null` on anything malformed) in the SDK repo.
335
+
336
+ ## Windowed lists
337
+
338
+ Use `VirtualListRange` from `@native-sdk/core/events` for a Model-first row query. Export `rows(model: Model, range: VirtualListRange): readonly Row[]`; return exactly the rows from `start_index` through the exclusive `end_index`. Every row needs one keyed root. The range also includes first/last visible indices, item extent/gap, scroll/layout offsets, total content extent, before/after extents, and anchor extent. Geometry remains fractional.
339
+
340
+ ```html
341
+ <virtual-window id="items" as="window" item-count="{count}"
342
+ item-extent="40" overscan="4" viewport-fallback="600">
343
+ <column>
344
+ <virtual-list window="window" each="rows" as="row" grow="1"
345
+ label="Items" on-reach-end="load_more">
346
+ <list-item key="{row.id}">{row.title}</list-item>
347
+ </virtual-list>
348
+ <status-bar>{window.first_visible_index}–{window.last_visible_index}</status-bar>
349
+ </column>
350
+ </virtual-window>
351
+ ```
352
+
353
+ For variable row heights, replace `item-extent` with `extent-estimate="estimate"`, where `estimate(model: Model, index: number): number` returns a nonnegative finite estimate. The native capability owns measurement, scrolling, retained corrections, and viewport resolution; compiled TypeScript owns row selection and markup composition. Estimates retain only a stable helper identity. They never hold a model pointer or result-arena memory. Supply cheap estimates without constructing rows.
354
+
355
+ Each window requires exactly one list, declarations cannot nest, and a view supports eight windows. A template may receive a complete window binding and forward it to another template. Counts and logical indices are nonnegative safe integers; extent values must fit finite f32 points. Return no rows for an empty range. See `examples/feed` for variable-height authoring and persistent row interaction state.
356
+
357
+ Exported Model-first helpers may take additional explicitly typed, fixed-arity parameters. Their complete parameter tuples cross the canonical helper ABI, including nested records, optionals, slices, integer obligations, and fractional fields. Ordinary `{helper}` bindings continue to use helpers with only the Model parameter; windowed row queries receive their range through `<virtual-list>`. Shell conventions such as `windows`, `statusItem`, and `webPanes` retain their documented single-Model signature.
301
358
 
302
359
  ## Text is bytes
303
360
 
@@ -396,10 +453,17 @@ export type Msg = /* ... */ | { readonly kind: "library_scrolled"; readonly scro
396
453
  The generated wiring detects each channel from an export (export exists → wired; a wrong shape is a taught NS1033). Event records are matched by field name, STRUCTURALLY: import them from `@native-sdk/core/events` (`FrameEvent`, `KeyEvent`, `PinchEvent`, `FileDropEvent`, `ColorScheme`, `ChromeInsets`/`ChromeButtons`) or declare the same shapes in your core — both emit as your module's types and match identically. The `appearanceMsg`/`chromeMsg` arms themselves stay inline union members (`kind` plus the event's fields — the subset has no intersection arms); the SDK's `AppearanceEvent`/`ChromeEvent` records are those arms' canonical payload shapes, importable for helper signatures.
397
454
 
398
455
  - **`commandMsg(name: string): Msg | null`** — menus, shortcuts, and chrome tabs, by command id (string equality works on `string` values).
456
+ - **`windowContext(model: Model, label: Uint8Array): WindowContextMsg | null`** — source-window identity before a window's input or command message. The label is the exact live window label; GPU frames do not change input ownership. Return a dedicated kind-discriminated subset of `Msg` with matching payloads, or null when the owner already matches. Handle this context message without effects so the corresponding input owns one command batch.
399
457
  - **`statusItem(model: Model): StatusItemState` / `statusItems(model: Model): readonly StatusItemDescriptor[]`** — one complete menu-bar item, or a stable-id collection. Presentation includes generic title typography. Dropdown rows include a typed `metric` block, typed segmented options, and bounded chart data; never encode these as text conventions. The generated launcher reconciles after committed updates.
400
- - **`themeState(model: Model): ThemeState`** — the stock theme's model-owned pack, color scheme, and accent. Import `ThemeState` from `@native-sdk/core/events`; each field is optional (`pack`, `colorScheme`, `accent`). Omit a field to inherit app.zon, use `colorScheme: "system"` (or omit it) to follow the OS, and spell accents exactly `#rrggbb`. High contrast/reduced motion remain system-owned and high contrast suppresses accents. `themePack(model)` remains the pack-only compatibility helper; export one or the other, never both. Complete `tokens_fn`/`tokens` wiring takes precedence. Forced scheme applies to canvas tokens in v1; native chrome and WebViews remain OS-themed.
458
+ - **`tokenOverrides(model: Model): ThemeDesignTokenOverrides`** — model-derived colors, typography, spacing, geometry, controls, and motion over the selected stock theme. Import the complete optional record from `@native-sdk/core/theme`; omitted members inherit the resolved stock register. Colors use normalized RGBA. Numbers cross the helper ABI as f64; native registration validates font ids and ranges and explicitly converts GPU values to f32. The runtime stamps device scale and installs its layout policies after applying the overrides. Full native `tokens`/`tokens_fn` configurations retain precedence.
459
+ - **`assets.fonts` in the manifest** — declare bundled TrueType faces as `{ "id": 64, "path": "assets/mono.ttf" }`. Ids start at 64 and remain permanent; at most eight faces register before the first layout. Reference their ids through `tokenOverrides` typography. Missing, oversized, or invalid files fail startup. The same asset tree is included in packaging.
460
+ - **`themeState(model: Model): ThemeState`** — the stock theme's model-owned pack, color scheme, and accent. Import `ThemeState` from `@native-sdk/core/events`; each field is optional (`pack`, `colorScheme`, `accent`, `highContrast`, `reduceMotion`). Omit a field to inherit app.zon, use `colorScheme: "system"` (or omit it) to follow the OS, and spell accents exactly `#rrggbb`. Omitted `highContrast`/`reduceMotion` follow the OS; explicit values retain model-owned appearance during replay. Effective high contrast suppresses accents. `themePack(model)` remains the pack-only compatibility helper; export one or the other, never both. Complete `tokens_fn`/`tokens` wiring takes precedence. On macOS, the requested scheme also applies to native window chrome and child controls, including secondary windows. `system` clears the window override and resumes OS appearance. WebView content remains responsible for its own styling.
461
+ - **`webPanes(model: Model): readonly WebViewPane[]`** — model-declared geometry, URL, and reload state for existing scene WebViews; see Model-declared WebView panes.
401
462
  - **`windows(model: Model): readonly WindowDescriptor[]`** — the model-declared secondary-window set. The launcher compiles `src/windows/<label>.native`, reconciles descriptor presence after committed updates, projects `closePolicy`, and routes a `.quit` `onCloseCommand` through `commandMsg`.
402
- - **`frameMsg(model: Model, frame: FrameEvent): Msg | null`** — presented frames. `FrameEvent` is exactly `{ width, height, timestampMs, intervalMs }` numbers (canvas points; fractional milliseconds). Return null for frames that change nothing — the idle law holds exactly when an idle app dispatches nothing (a frame arm that always returns a Msg would spin the loop at full frame rate). The installing frame is excluded; the first PRESENTED frame corrects any seeded value.
463
+ - **`frameMsg(model: Model, frame: FrameEvent): Msg | null`** — presented frames. `FrameEvent` carries `{ width, height, timestampMs, intervalMs }` numbers (canvas points; fractional milliseconds) plus `timestampNs` and `intervalNs` as exact decimal ASCII bytes. Use the byte clocks for nanosecond-sensitive animation; converting the fractional-millisecond number back loses large-u64 precision. Existing structural four-number events remain supported. Return null for frames that change nothing — the idle law holds exactly when an idle app dispatches nothing. The installing frame is excluded.
464
+
465
+ For native audio identity parity, return `Cmd.audioPlayExact(key, source, { event: "audio_event" })` from `update`. The key is canonical unsigned decimal bytes through max-u64. Its event arm has exactly `key`, `state`, `positionMs`, `durationMs`, `playing`, `buffering`, and `bands`; the key and both counters are bytes, the flags are booleans, and `state` uses all six `AudioState` members. Import `ExactAudioEvent` from `@native-sdk/core/events` for helper signatures. Native copies every report into the dispatch arena, and committed model storage owns retained data. Deferred rejections/failures retain their original route and key across replacement; source rejection preserves the prior player. Existing native event admission bounds apply. `cacheDir` derives a content-addressed URL cache path when `cachePath` is empty; omitting both disables caching. `Cmd.audioTransport` controls the single player with `pause`, `play` (resume), `stop`, `seek` (decimal-byte `positionMs`), or `volume` (numeric `value`); volume is remembered even while idle. Commands remain inline in `update`'s return.
466
+ - **`layoutTweens(model: Model): readonly LayoutTween[]`** — runtime-driven split animation targets. Import `LayoutTween` from `@native-sdk/core/events`; provide nullable byte `label`, zero-based split occurrence `index`, target fraction `to`, integer `durationMs`, and `easing` (`linear`, `standard`, `emphasized`, `spring`). `label: null` selects among all splits; otherwise `index` selects among exact matching labels in tree order. Native resolves widget identities and retains animation storage; the core derives targets. Invalid descriptors are ignored, the first declaration for an id wins, and output respects the runtime tween budget. Reduced motion snaps through the existing runtime primitive.
403
467
  - **`keyMsg(key: KeyEvent): Msg | null`** — the app-level key FALLBACK (a focused widget's own keys and editable text always win first). `KeyEvent` is exactly `{ key: string; shift: boolean; control: boolean; alt: boolean; super: boolean }`; the key NAME arrives lowercased (`key.key === "space"`).
404
468
  - **`pinchMsg(pinch: PinchEvent): Msg | null`** — the view-global trackpad pinch channel. `PinchEvent` carries `windowId`, `label`, begin/change/end `phase`, multiplicative `scale` delta, and the view-local `x`/`y` anchor.
405
469
  - **`dropMsg(drop: FileDropEvent): Msg | null`** — native file drops after widget routing. `FileDropEvent` is exactly `{ windowId; viewLabel; point; paths }`: `point` is `{ x; y } | null`, and `paths` is `readonly Uint8Array[]` so arbitrary UTF-8 filesystem names remain byte text. Return null to ignore the drop or map it to any ordinary Msg.
@@ -408,6 +472,39 @@ The generated wiring detects each channel from an export (export exists → wire
408
472
  - **`export const envMsgs = [{ env: "NAME", msg: "<arm>" }] as const`** — each named environment variable present at launch dispatches its value through the arm (exactly one `Uint8Array` field, `BytesKind` — annotate with `readonly EnvMsg<Msg>[]` from the SDK for tsc checking) as one journaled Msg right after the boot command. The generated runner also synthesizes the reserved `NATIVE_SDK_APP_DATA_DIR` value from `native_sdk.app_dirs` when requested here; use it as the root for durable `Cmd.writeFile`/`Cmd.readFile` paths instead of relying on the package's process working directory. The core never reads the environment (NS1005), and neither does replay: the deliveries are journaled at record time and fed back from the journal, so a recording replays byte-identically even when ambient variables are unset or changed at replay launch.
409
473
  - **`app.zon .assets.images`** — `.assets = .{ .images = .{ .{ .id = 1, .path = "assets/art/cover.jpg" }, ... } }`: each file is read once at launch and registered on the installing frame; the `id` is the `ImageId` markup avatar bindings reference (`<avatar image="{coverId}">`), and a missing file or failed decode keeps the initials fallback.
410
474
 
475
+ ## Synchronous boot image results
476
+
477
+ Declare encoded images in the manifest's image assets. Native code decodes and
478
+ registers them on the installing frame. Export
479
+ `bootImageMsg(model: Model, result: BootImageResult): ImageMsg | null` to choose
480
+ which successful registrations enter the model and which failures keep a
481
+ fallback. Import `BootImageResult` from `@native-sdk/core/events`; it contains
482
+ exact decimal `id` bytes, `registered`, `width`, `height`, and complete native
483
+ `errorName` bytes. Failure has zero dimensions; success has an empty error.
484
+
485
+ `ImageMsg` is a dedicated subset union of `Msg`, with identical payload fields.
486
+ Returning `null` ignores the report without undoing registration. Results arrive
487
+ in asset declaration order before the initial command and first view. Images
488
+ retain native registry and pixel ownership; registration follows the existing
489
+ synchronous native boot convention and does not add an effect journal record.
490
+ A replay installs the same declared assets through the same codec capability.
491
+ Cores without this hook retain automatic registration without result delivery.
492
+
493
+ Like other transient value records, keep the callback record out of the retained
494
+ model tree: copy its fields into an interface-backed model record. Carry its
495
+ byte fields inline in message arms so the complete dispatch ABI stays explicit.
496
+
497
+ ## Canvas declarations
498
+
499
+ Import the canonical records from `@native-sdk/core/events` and declare these helpers in `core.ts`:
500
+
501
+ - `canvasIcons(model): readonly CanvasIconDefinition[]` declares the app's vector glyphs, installed once before boot images, commands and the first view. Each record carries its raw name bytes, view box, complete path elements and shape ranges with fill/stroke paints, stroke width, cap and join. Paints are `none`, `current_color`, or an explicit RGBA `color`. Native copies all data into stable drawing storage; another helper call cannot change the registered glyphs. There may be 64 icons with names of 1–128 bytes, 48 shapes and 512 path elements per icon. Names must be unique, view-box dimensions positive, ranges within the element array, geometry finite, stroke widths nonnegative and RGBA channels within 0–1. A refused batch leaves the previous registry intact and fails installation. Use `app:<name>` in markup. Glyph definitions are pure data and replay reinstalls the same definitions without file IO.
502
+ - `canvasChrome(model, context: CanvasChromeContext): readonly CanvasChromeCommand[]` derives up to 256 commands before the widget display list. `canvasChromeSuffix` has the same signature and derives an independent layer after widgets; either layer may be empty or omitted. Native supplies viewport dimensions and resolved background/surface/border colors. The compiled core owns the split, and native preserves both actual layer lengths during widget-only regeneration. Commands support filled rectangles, uniform rounded rectangles, stroked rectangles with four corner radii, lines, filled paths, and stroked paths with butt/round caps. IDs are canonical unsigned decimal bytes through max-u64; nonzero IDs must be unique across both layers, while zero is anonymous. Each gradient has at most 16 stops and each path at most 64 elements. Import `CanvasPathElement` and carry its verb plus all three point slots explicitly, including unused points, to keep declarations lossless. Native copies gradients and paths into disjoint layer storage before another helper call, then into the retained display list. Geometry and all path points must be finite, dimensions/radii/stroke widths nonnegative, and RGBA channels within 0–1. The native view's aggregate command, path, and gradient capacities still apply. Invalid or over-capacity declarations fail the whole install.
503
+ - `canvasAnimations(model): readonly CanvasAnimation[]` targets an exact accessibility label and zero-based occurrence, with `part: "fill" | "text"`. Native resolves retained command IDs and stamps the presentation clock. Indices and durations are u32-range integers; transforms are finite and opacity stays within 0–1. An invalid, duplicate, or oversized batch clears declarations.
504
+ - `canvasFrameMsg(model, frame: CanvasFrameEvent)` receives copied renderer facts with exact decimal-byte clocks/counters, risk, packet representability and dirty ratio. Return a dedicated subset union of `Msg` or `null`; share the exact payload types with `Msg`. Export this helper instead of `frameMsg`.
505
+
506
+ GPU Dashboard demonstrates these hooks together with model-owned appearance, token overrides, retained controls, and replay. Native retains rendering, submission and resource lifetime.
507
+
411
508
  ## The rules the checker enforces
412
509
 
413
510
  Every diagnostic carries one of these IDs plus the fix and the why, and every rule carries a class: `guarantee` rules protect a core invariant (determinism and replay, fixed shapes, immutability of shared data, the one text representation) and are permanent; `deferred` rules (NS1011, NS1019, NS1040, NS1042, NS1044) wait on a deliberate easing decision and say so in their output. Write to them up front:
@@ -444,10 +541,10 @@ Every diagnostic carries one of these IDs plus the fix and the why, and every ru
444
541
  - **NS1070 relational SQLite and capability disagree (warning).** Raw `Cmd.db.*`, generated `Cmd.q<Name>`, and generated `Sub.q<Name>` require `"sqlite"`; declaring the capability without using any of them produces the inverse warning.
445
542
  - **NS14xx SQL diagnostics come from the real schema.** Fix the migration or named statement at the reported `.sql` line. Migration versions are append-only and contiguous; ordinary generated-query tables are `STRICT`; raw query literals receive the non-fatal NS1420 escape-hatch nudge; identifier-like INTEGER fields receive NS1422's exact-number warning.
446
543
  - **NS1029 effect op arguments have a fixed shape.** Paths/URLs/bodies are bytes, `Cmd.fetch`'s spec is an inline object with a closed verb literal, a number-literal timeout, and an inline flat record of headers whose NAMES are compile-time ASCII and whose VALUES are string literals or runtime bytes (`Uint8Array`). The record's shape encodes at build time; a runtime header value rides its length-prefixed wire field at dispatch time exactly like `url`/`body` — but a smuggled string (a ternary of literals, a template) has no encoding: make it bytes.
447
- - **NS1031 exported model helpers join the model's binding surface.** An exported single-Model-parameter helper becomes a Model declaration markup binds (`doneCount` → `{doneCount}`); two members with one binding name would be ambiguous — rename one.
544
+ - **NS1031 exported model helpers join the model's binding surface.** An exported Model-first helper becomes a Model declaration; only a single-Model-parameter helper is a scalar markup binding (`doneCount` → `{doneCount}`); two members with one binding name would be ambiguous — rename one.
448
545
  - **NS1032 viewUnbound names update-only model state.** `export const viewUnbound = [...] as const` entries must be string literals naming Model fields, exported model helpers, or Msg kinds — by their TypeScript spellings (`"nextId"`); anything else would silence nothing and hide a typo.
449
546
  - **NS1030 effect arguments respect the engine's limits.** A compile-time-knowable value outside an engine bound (a path literal over 1024 bytes, a URL literal over 2 KiB, more than 8 headers, a header block over 1 KiB, a delay literal outside 1ms..one year) stops the build instead of shipping a guaranteed runtime rejection. Dynamic values stay the engine's to validate — they surface through the `err` arm.
450
- - **NS1033 wiring channel exports match their host event shapes.** `frameMsg`/`keyMsg`/`pinchMsg`/`dropMsg` take their exact event records and return `Msg | null`; `appearanceMsg`/`chromeMsg` are string literals naming arms with those channels' record shapes; `envMsgs` entries carry `env` and a one-`Uint8Array`-field `msg` arm; `themeState`, `themePack`, `statusItem`, `statusItems`, and `windows` return their exact model-derived shell shapes. The generated wiring builds these host values structurally from your declarations, so a wrong shape is taught here instead of surfacing as a Zig error inside generated code.
547
+ - **NS1033 wiring channel exports match their host event shapes.** `frameMsg`/`keyMsg`/`pinchMsg`/`dropMsg` take their exact event records and return `Msg | null`; `appearanceMsg`/`chromeMsg` are string literals naming arms with those channels' record shapes; `envMsgs` entries carry `env` and a one-`Uint8Array`-field `msg` arm; `themeState`, `themePack`, `statusItem`, `statusItems`, `windows`, and `webPanes` return their exact model-derived shell shapes. The generated wiring builds these host values structurally from your declarations, so a wrong shape is taught here instead of surfacing as a Zig error inside generated code.
451
548
  - **NS1034 core imports stay inside src/.** `../` escapes and absolute paths are rejected: the entry module's directory is the core's whole world - the build ships exactly that tree.
452
549
  - **NS1035 npm packages do not run inside a core.** No JS engine ships in the binary; vendor the logic under `src/` or make the import type-only.
453
550
  - **NS1036 core modules do not import in a cycle.** Runtime cycles only work through JS live-binding indirection; hoist shared declarations, or make the back-edge `import type` (which is exempt and idiomatic).
@@ -575,7 +672,7 @@ var app = Adapter.init(allocator, .{ .audio_cache_dir = resolved_cache_dir }, .{
575
672
 
576
673
  - `update`/`update_fx`/`init_fx` belong to the adapter (it runs your `initialModel`, `update`, and `subscriptions` through the effect bridge), and the adapter wires `on_command`/`on_key`/`on_pinch`/`on_drop`/`on_appearance`/`on_chrome`/`on_frame` from the core's channel exports automatically. It likewise wires `theme_state_fn` from `themeState(model)` or `theme_fn` from legacy `themePack(model)`, and the singular `status_item_fn` or collection `status_items_fn` from the matching helper. A wiring that also sets one of those seams is a teaching panic. Everything else is ordinary wiring: `tokens_fn`/`windows_fn` derive from `*const core.Model`, and `CoreOptions` carries the adapter-owned knobs (`audio_cache_dir`, `boot_images`, `env_values`).
577
674
  - Markup binds your model's field names EXACTLY as you wrote them: `nextId` binds as `{nextId}` (the core's model keeps the TS spellings). Record arrays iterate with `<for each="tasks" as="t" key="id">` and items bind their fields (`{t.title}`); optional scalars gate with `<if test="{selected}">` (null is falsy); string-literal unions bind as their member name (`{filter}` renders `all` — compare against a quoted literal, `selected="{sortKey == 'cpu'}"`); exported single-model helpers bind as derived values (`{doneCount}`) and slice-returning ones drive `for each`. Markup `<chart>` series bind number arrays too — `<series kind="bar" values="{cpuSpark}" />` over a field or helper returning `readonly number[]` (f64, narrowed per sample into the chart pipeline); pad a filling window's leading gap with `NaN` samples, which draw nothing.
578
- - `Options.sync` does not exist for TS apps (a committed model cannot be mutated in place): keep continuous controls model-driven — bind the widget's value and echo `on-change`/`on-scroll` Msgs back into the model.
675
+ - Keep continuous controls model-driven: bind the widget's value and echo `on-change`/`on-scroll` messages back into the model. For passive sampling of retained main-canvas sliders, export `sliderStateMsg(model: Model, sliders: readonly SliderState[]): SliderMsg | null` with `SliderState` from `@native-sdk/core/events`. The adapter supplies each slider's exact decimal `id`, byte `label`, and applied native f32 `value` before updates, effect drains, and rebuilds. Return a dedicated Msg subset union with identical payloads, or null; its update must return `Cmd.none` (commands fail the sync boundary). The ordinary commit walker retains the complete result before scratch reset. Sampling emits no extra journal event and follows the same retained state during replay. Custom `Options.sync` remains unsupported because it mutates a committed graph in place.
579
676
  - One live app per core module per process: two apps over the SAME core would share one committed root — and a process carries ONE compiled core (the archive owns a fixed-prefix C ABI symbol set).
580
677
  - Record/replay, the automation verbs, and screenshot fingerprints work unchanged — the adapter rides the standard UiApp dispatch path.
581
678
 
@@ -587,7 +684,7 @@ Builds compile the whole app — the core archive, service executables or in-pro
587
684
 
588
685
  Scaffolded apps carry an editor surface (`package.json`, `tsconfig.json`, and a CLI-managed `node_modules/@native-sdk/core` copy, npm-managed after the package is published): it exists so stock tsc/editors resolve `@native-sdk/core`, it is NEVER build truth (every `native` verb works with node_modules deleted; check/dev/build re-materialize it), and it is not a language marker — tree detection still keys on `src/core.ts` alone. Do not hand-edit or vendor files under `node_modules/`.
589
686
 
590
- **Refresh the model contract after shape changes.** `native check`'s typed markup pass reads `zig-out/model-contract.zon`, an artifact of the LAST build/test — after changing Model fields or Msg kinds, run `native test` (or `zig build model-contract` in an app that owns its build.zig) before trusting `native check`. A stale contract reports phantom hard errors (`unknown message tag`, `binding does not name a model field`) that name your NEW state — the state is fine; the artifact is old. And never delete `src/app.native` in response to a note about nothing embedding it: on the TypeScript track the generated wiring embeds the view from outside the app tree, so that file is always wired.
687
+ **`native check` types your markup against the current core.** It compiles `src/app.native` and `src/windows/*.native` against the contract it just derived from `src/core.ts`, with the same view compiler the build uses — there is no artifact to refresh after changing Model fields or Msg kinds. A binding error reads `src/app.native:L:C: error: compiled TypeScript view: …`; unused Model fields, helpers and Msg kinds are warnings (opt out with `export const viewUnbound`; `--strict` fails on them). Never delete `src/app.native` in response to a note about nothing embedding it: on the TypeScript track the generated wiring embeds the view from outside the app tree, so that file is always wired.
591
688
 
592
689
  The frontend is the checker: run it after every meaningful edit and read the diagnostics — they always name the rule, the idiomatic rewrite, and the reason. Inside an app, `native check` runs it for you (plus markup and app.zon validation); in a core-only workspace, invoke it directly:
593
690
 
@@ -597,3 +694,12 @@ node <sdk-repo>/packages/core/src/cli.ts src/core.ts
597
694
  ```
598
695
 
599
696
  Exit 0 means the module typechecked (real tsc semantics) and passed every subset rule — the exact pass every build runs before the external core compiler takes the graph. Because the subset is erasable TypeScript, `node` can import your core directly for quick behavioral checks (`node --input-type=module -e "..."` or a small `node --test` file) — the native build has the same semantics. If the core imports `@native-sdk/core` (for `Cmd`, `asciiBytes`, or `utf8Bytes`), map that one specifier for node first: copy the SDK module file next to the core and rewrite the import, or run through a loader that resolves it.
697
+
698
+ For a migration that already stores files under the app's short name, `envMsgs` may request `NATIVE_SDK_APP_LEGACY_DATA_DIR`. The launcher resolves that name and explicitly grants its data directory as an additional file root. The ordinary `NATIVE_SDK_APP_DATA_DIR` remains the bundle-ID directory; raw ambient path overrides are never used for either capability.
699
+
700
+ `envMsgs` may also request `NATIVE_SDK_APP_CACHE_DIR`. On desktop it supplies
701
+ the OS-resolved cache root under the app's short name, matching the launcher’s
702
+ URL media cache. Resolution failure supplies empty bytes, which disables
703
+ caching. The mobile launcher supplies empty bytes until a cache-root capability
704
+ is available. An ambient variable cannot override either result. Deliveries use
705
+ the same journaled launch channel and replay ownership as other `envMsgs`.
@@ -79,7 +79,7 @@ native vendor . escape-string-regexp@5.0.0
79
79
 
80
80
  The command installs with lifecycle scripts disabled in a temporary directory, copies the flattened package graph into `src/services/vendor/`, retains package/license files, computes canonical tree hashes, and rewrites app.zon's `service_packages` with exact names, `X.Y.Z` versions, and hashes. Check those bytes and manifest facts into source control.
81
81
 
82
- Builds never run npm or use the network. They verify package identity and every vendored byte, stage only declared packages, and invoke scriptc with `--npm-static <explicit-list>`. `auto`, dynamic-island fallback, and `--dynamic` are refused. Anything below 100% static coverage fails: `native check` preserves the coverage note verbatim and names the three options—choose another exact package, port/vendor a suitable implementation, or wait for compiler support. The checked-in package spike (`tests/ts-services/npm-static-spike.json`) passed three of five deliberately small candidates and refused `nanoid` and `micromark`; npm support is selective.
82
+ Builds never run npm or use the network. They verify package identity and every vendored byte, stage only declared packages, and invoke scriptc with `--npm-static <explicit-list>`. `auto`, dynamic-island fallback, and `--dynamic` are refused. Anything below 100% static coverage fails: `native check` preserves the coverage note verbatim and names the three options—choose another exact package, port/vendor a suitable implementation, or wait for compiler support. The checked-in package spike (`tests/ts-services/npm-static-spike.json`) passed four of five deliberately small candidates and refused `micromark`; npm support is selective.
83
83
 
84
84
  ## Streaming, cancellation, and deadlines
85
85