@native-sdk/cli 0.10.1 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -6
- package/bin/native.js +2 -1
- package/build/app.zig +320 -60
- package/build/corewire.zig +53 -0
- package/build/test_shards.zig +49 -0
- package/build/ts_run.mjs +3 -3
- package/build.zig +1796 -83
- package/package.json +19 -14
- package/packages/core/compile-surface/core.ts +134 -72
- package/packages/core/package-lock.json +75 -357
- package/packages/core/package.json +25 -4
- package/packages/core/scripts/compiler_command.mjs +17 -12
- package/packages/core/scripts/compiler_typecheck.mjs +1 -0
- package/packages/core/scripts/gen_declarations.mjs +3 -2
- package/packages/core/scripts/gen_service_surface.mjs +22 -10
- package/packages/core/scripts/install_scriptc.mjs +182 -0
- package/packages/core/scripts/invoke_scriptc.mjs +18 -0
- package/packages/core/scripts/merge_static_archives.mjs +6 -1
- package/packages/core/scripts/npm_static_spike.mjs +2 -2
- package/packages/core/scripts/run_external_core_compiler.mjs +22 -10
- package/packages/core/scripts/run_external_service_compiler.mjs +15 -15
- package/packages/core/scripts/run_library_compiler.mjs +51 -0
- package/packages/core/scripts/run_native_tests.mjs +22 -0
- package/packages/core/scripts/scriptc-toolchain.json +101 -0
- package/packages/core/scripts/scriptc_toolchain.mjs +121 -0
- package/packages/core/scripts/stage_external_core.mjs +57 -1
- package/packages/core/scripts/surface_manifest_diff.mjs +19 -12
- package/packages/core/sdk/bytes.d.ts +2 -0
- package/packages/core/sdk/bytes.ts +86 -0
- package/packages/core/sdk/core.d.ts +308 -4
- package/packages/core/sdk/core.ts +320 -84
- package/packages/core/sdk/events.d.ts +247 -0
- package/packages/core/sdk/events.ts +230 -2
- package/packages/core/sdk/internal/image_identity.d.ts +7 -0
- package/packages/core/sdk/internal/image_identity.ts +71 -0
- package/packages/core/sdk/internal/markdown_policy.d.ts +5 -0
- package/packages/core/sdk/internal/markdown_policy.ts +878 -0
- package/packages/core/sdk/text.d.ts +27 -0
- package/packages/core/sdk/text.ts +206 -15
- package/packages/core/sdk/theme.d.ts +251 -0
- package/packages/core/sdk/theme.ts +267 -0
- package/packages/core/src/authorization.ts +137 -0
- package/packages/core/src/automation_commands.ts +201 -0
- package/packages/core/src/automation_interactions.ts +92 -0
- package/packages/core/src/bridge_descriptors.ts +104 -0
- package/packages/core/src/builtin_coordination.ts +172 -0
- package/packages/core/src/canvas_frame_coordination.ts +81 -0
- package/packages/core/src/canvas_presentation_lifecycle.ts +84 -0
- package/packages/core/src/canvas_scene_observation.ts +145 -0
- package/packages/core/src/chart_content.ts +161 -0
- package/packages/core/src/chart_plans.ts +432 -0
- package/packages/core/src/checker.ts +166 -19
- package/packages/core/src/code_content.ts +580 -0
- package/packages/core/src/command_coordination.ts +140 -0
- package/packages/core/src/component_composition.ts +94 -0
- package/packages/core/src/component_construction.ts +149 -0
- package/packages/core/src/contract.ts +25 -7
- package/packages/core/src/control_appearance.ts +232 -0
- package/packages/core/src/control_commands.ts +115 -0
- package/packages/core/src/control_content.ts +105 -0
- package/packages/core/src/control_geometry.ts +107 -0
- package/packages/core/src/control_payloads.ts +119 -0
- package/packages/core/src/control_primitives.ts +134 -0
- package/packages/core/src/devhost.ts +82 -7
- package/packages/core/src/devhost_journal.mjs +30 -7
- package/packages/core/src/effect_plans.ts +71 -0
- package/packages/core/src/flow_measurement.ts +121 -0
- package/packages/core/src/font_registry.ts +37 -0
- package/packages/core/src/glyph_atlas.ts +86 -0
- package/packages/core/src/gpu_packet_preparation.ts +130 -0
- package/packages/core/src/gpu_planning.ts +123 -0
- package/packages/core/src/gpu_presentation.ts +55 -0
- package/packages/core/src/host_flow.ts +89 -0
- package/packages/core/src/host_input_regions.ts +165 -0
- package/packages/core/src/image_registry.ts +66 -0
- package/packages/core/src/indicator_plans.ts +132 -0
- package/packages/core/src/infer.ts +150 -8
- package/packages/core/src/input_composition.ts +116 -0
- package/packages/core/src/intrinsic_measure.ts +100 -0
- package/packages/core/src/layout_coordination.ts +207 -0
- package/packages/core/src/leaf_plans.ts +134 -0
- package/packages/core/src/markup_development.ts +160 -0
- package/packages/core/src/measurement_coordination.ts +185 -0
- package/packages/core/src/modules.ts +1 -1
- package/packages/core/src/motion_sampling.ts +100 -0
- package/packages/core/src/paragraph_layout.ts +192 -0
- package/packages/core/src/portable_sources.json +74 -0
- package/packages/core/src/portable_sources.ts +17 -0
- package/packages/core/src/registered_font.ts +93 -0
- package/packages/core/src/render_animation_lifecycle.ts +128 -0
- package/packages/core/src/render_coordination.ts +170 -0
- package/packages/core/src/render_resources.ts +234 -0
- package/packages/core/src/runtime_policy.ts +3930 -0
- package/packages/core/src/scalar_text.ts +84 -0
- package/packages/core/src/service_contract.ts +2 -1
- package/packages/core/src/session_codecs.ts +309 -0
- package/packages/core/src/shell_admission.ts +126 -0
- package/packages/core/src/shell_coordination.ts +93 -0
- package/packages/core/src/sqlite_cli.ts +11 -0
- package/packages/core/src/status_validation.ts +232 -0
- package/packages/core/src/stream_policy.ts +63 -0
- package/packages/core/src/surface_recipes.ts +136 -0
- package/packages/core/src/system_admission.ts +60 -0
- package/packages/core/src/terminal_paint.ts +436 -0
- package/packages/core/src/text_document_width.ts +81 -0
- package/packages/core/src/text_measurement_cache.ts +69 -0
- package/packages/core/src/text_query_layout.ts +179 -0
- package/packages/core/src/text_run_layout.ts +410 -0
- package/packages/core/src/text_span_queries.ts +355 -0
- package/packages/core/src/typed_ast.ts +18 -1
- package/packages/core/src/types.ts +7 -5
- package/packages/core/src/vector_effects.ts +98 -0
- package/packages/core/src/vector_raster.ts +243 -0
- package/packages/core/src/view_components.ts +2415 -0
- package/packages/core/src/view_coordination.ts +198 -0
- package/packages/core/src/view_frontend.ts +980 -0
- package/packages/core/src/widget_audits.ts +202 -0
- package/packages/core/src/widget_changes.ts +258 -0
- package/packages/core/src/widget_metrics.ts +139 -0
- package/packages/core/src/widget_motion.ts +171 -0
- package/packages/core/src/widget_paint.ts +272 -0
- package/packages/core/src/widget_paint_walk.ts +203 -0
- package/packages/core/src/widget_presentation.ts +141 -0
- package/packages/core/src/widget_routing.ts +262 -0
- package/packages/core/src/window_lifecycle.ts +92 -0
- package/packages/core/testing/index.ts +430 -0
- package/schemas/app.schema.json +13 -0
- package/skill-data/core/SKILL.md +2 -2
- package/skill-data/native-ui/SKILL.md +76 -17
- package/skill-data/ts-core/SKILL.md +113 -9
- package/skill-data/ts-services/SKILL.md +1 -1
- package/skill-data/ts-services/references/service-surface.md +264 -144
- package/src/app_runner/root.zig +25 -12
- package/src/app_runner/ts_compiled_view.zig +1631 -0
- package/src/app_runner/ts_core_main.zig +143 -10
- package/src/app_runner/ts_core_mobile.zig +24 -12
- package/src/automation/server.zig +1 -3
- package/src/automation/snapshot.zig +9 -637
- package/src/automation/snapshot_reference.zig +656 -0
- package/src/automation/snapshot_serialization.zig +566 -0
- package/src/platform/linux/gtk_host.c +36 -24
- package/src/platform/linux/gtk_pixels.h +118 -0
- package/src/platform/linux/gtk_pixels_test.c +241 -0
- package/src/platform/linux/root.zig +2 -0
- package/src/platform/macos/appkit_host.m +188 -30
- package/src/platform/macos/pointer_motion_test.m +96 -0
- package/src/platform/macos/scroll_driver_test.m +105 -0
- package/src/platform/macos/spectrum_bins.h +34 -0
- package/src/platform/macos/spectrum_bins_test.c +56 -0
- package/src/platform/macos/text_keyboard_test.m +80 -0
- package/src/platform/macos/widget_focus_test.m +66 -0
- package/src/platform/null_platform.zig +26 -2
- package/src/platform/null_platform_tests.zig +13 -0
- package/src/platform/root.zig +1 -0
- package/src/platform/types.zig +13 -0
- package/src/platform/windows/root.zig +2 -0
- package/src/platform/windows/webview2_host.cpp +7 -2
- package/src/primitives/app_manifest/comptime_scene.zig +1 -1
- package/src/primitives/app_manifest/root.zig +2 -0
- package/src/primitives/app_manifest/tests.zig +4 -1
- package/src/primitives/app_manifest/validation.zig +2 -0
- package/src/primitives/canvas/a11y_audit.zig +3 -1
- package/src/primitives/canvas/canvas_frame_coordination_policy.zig +134 -0
- package/src/primitives/canvas/chart_content_policy.zig +75 -0
- package/src/primitives/canvas/chart_plan_policy.zig +196 -0
- package/src/primitives/canvas/code_content_policy.zig +162 -0
- package/src/primitives/canvas/commands.zig +29 -1
- package/src/primitives/canvas/component_composition.zig +125 -0
- package/src/primitives/canvas/component_composition_policy.zig +44 -0
- package/src/primitives/canvas/component_construction_policy.zig +187 -0
- package/src/primitives/canvas/container_layout_policy.zig +87 -0
- package/src/primitives/canvas/control_appearance_policy.zig +142 -0
- package/src/primitives/canvas/control_command_policy.zig +75 -0
- package/src/primitives/canvas/control_content_policy.zig +90 -0
- package/src/primitives/canvas/control_geometry_policy.zig +165 -0
- package/src/primitives/canvas/control_payload_policy.zig +48 -0
- package/src/primitives/canvas/control_primitive_policy.zig +129 -0
- package/src/primitives/canvas/effect_plan_policy.zig +96 -0
- package/src/primitives/canvas/events.zig +1027 -1
- package/src/primitives/canvas/flow_measurement_policy.zig +237 -0
- package/src/primitives/canvas/frame.zig +92 -23
- package/src/primitives/canvas/glyph_atlas_policy.zig +40 -0
- package/src/primitives/canvas/gpu.zig +10 -0
- package/src/primitives/canvas/gpu_packet_preparation_policy.zig +325 -0
- package/src/primitives/canvas/gpu_planning_policy.zig +364 -0
- package/src/primitives/canvas/gpu_presentation_policy.zig +74 -0
- package/src/primitives/canvas/grid_layout_policy.zig +51 -0
- package/src/primitives/canvas/indicator_plan_policy.zig +128 -0
- package/src/primitives/canvas/intrinsic_layout_policy.zig +87 -0
- package/src/primitives/canvas/intrinsic_measure_policy.zig +128 -0
- package/src/primitives/canvas/layout_audit.zig +5 -2
- package/src/primitives/canvas/layout_coordination_policy.zig +262 -0
- package/src/primitives/canvas/leaf_plan_policy.zig +117 -0
- package/src/primitives/canvas/markdown.zig +13 -3
- package/src/primitives/canvas/markdown_content_policy.zig +227 -0
- package/src/primitives/canvas/markdown_image_binding.zig +81 -0
- package/src/primitives/canvas/measurement_coordination_policy.zig +288 -0
- package/src/primitives/canvas/numeric_capabilities.zig +14 -0
- package/src/primitives/canvas/reference.zig +12 -6
- package/src/primitives/canvas/registered_font_policy.zig +152 -0
- package/src/primitives/canvas/render.zig +48 -0
- package/src/primitives/canvas/render_cache_policy.zig +184 -0
- package/src/primitives/canvas/render_coordination_policy.zig +163 -0
- package/src/primitives/canvas/render_damage_policy.zig +160 -0
- package/src/primitives/canvas/render_effects.zig +14 -0
- package/src/primitives/canvas/render_generic_resources.zig +14 -0
- package/src/primitives/canvas/render_images.zig +14 -0
- package/src/primitives/canvas/render_layers.zig +14 -0
- package/src/primitives/canvas/render_override_policy.zig +119 -0
- package/src/primitives/canvas/render_paths.zig +14 -0
- package/src/primitives/canvas/render_plan_policy.zig +199 -0
- package/src/primitives/canvas/render_resource_policy.zig +476 -0
- package/src/primitives/canvas/root.zig +100 -0
- package/src/primitives/canvas/semantic_tree_policy.zig +158 -0
- package/src/primitives/canvas/serialization.zig +8 -1
- package/src/primitives/canvas/surface_layout_policy.zig +36 -0
- package/src/primitives/canvas/surface_recipe_policy.zig +231 -0
- package/src/primitives/canvas/terminal_grid.zig +10 -696
- package/src/primitives/canvas/terminal_grid_reference.zig +709 -0
- package/src/primitives/canvas/terminal_paint_policy.zig +191 -0
- package/src/primitives/canvas/text.zig +1 -0
- package/src/primitives/canvas/text_atlas.zig +113 -0
- package/src/primitives/canvas/text_cache_policy.zig +94 -0
- package/src/primitives/canvas/text_document_policy.zig +120 -0
- package/src/primitives/canvas/text_layout.zig +51 -2
- package/src/primitives/canvas/text_layout_cache.zig +29 -0
- package/src/primitives/canvas/text_layout_hash.zig +1 -0
- package/src/primitives/canvas/text_layout_types.zig +3 -0
- package/src/primitives/canvas/text_measure_cache.zig +46 -0
- package/src/primitives/canvas/text_measurement_policy.zig +124 -0
- package/src/primitives/canvas/text_metrics.zig +23 -0
- package/src/primitives/canvas/text_query_policy.zig +156 -0
- package/src/primitives/canvas/text_run_policy.zig +252 -0
- package/src/primitives/canvas/text_scalar_policy.zig +156 -0
- package/src/primitives/canvas/text_span_query_policy.zig +232 -0
- package/src/primitives/canvas/text_spans.zig +280 -8
- package/src/primitives/canvas/text_tests.zig +10 -0
- package/src/primitives/canvas/tokens.zig +38 -0
- package/src/primitives/canvas/ui.zig +250 -83
- package/src/primitives/canvas/ui_markup.zig +139 -33
- package/src/primitives/canvas/ui_markup_compiled.zig +319 -59
- package/src/primitives/canvas/ui_markup_compiled_tests.zig +225 -0
- package/src/primitives/canvas/ui_markup_contract.zig +146 -14
- package/src/primitives/canvas/ui_markup_contract_tests.zig +77 -0
- package/src/primitives/canvas/ui_markup_reflect.zig +56 -0
- package/src/primitives/canvas/ui_markup_tests.zig +116 -0
- package/src/primitives/canvas/ui_markup_view.zig +258 -32
- package/src/primitives/canvas/ui_markup_view_tests.zig +142 -10
- package/src/primitives/canvas/ui_schema.zig +13 -1
- package/src/primitives/canvas/ui_schema_tests.zig +11 -7
- package/src/primitives/canvas/ui_tests.zig +1 -0
- package/src/primitives/canvas/vector.zig +36 -2
- package/src/primitives/canvas/vector_effect_policy.zig +236 -0
- package/src/primitives/canvas/vector_raster_policy.zig +190 -0
- package/src/primitives/canvas/virtual_extent_policy.zig +292 -0
- package/src/primitives/canvas/virtual_extents.zig +99 -3
- package/src/primitives/canvas/virtual_flow_policy.zig +108 -0
- package/src/primitives/canvas/widget_audit_policy.zig +293 -0
- package/src/primitives/canvas/widget_change_policy.zig +298 -0
- package/src/primitives/canvas/widget_invalidation.zig +113 -2
- package/src/primitives/canvas/widget_layout.zig +673 -128
- package/src/primitives/canvas/widget_layout_tests.zig +4 -0
- package/src/primitives/canvas/widget_metric_policy.zig +126 -0
- package/src/primitives/canvas/widget_metrics.zig +45 -6
- package/src/primitives/canvas/widget_paint_policy.zig +166 -0
- package/src/primitives/canvas/widget_paint_walk_policy.zig +252 -0
- package/src/primitives/canvas/widget_presentation_policy.zig +168 -0
- package/src/primitives/canvas/widget_render.zig +744 -74
- package/src/primitives/canvas/widget_render_controls.zig +1217 -133
- package/src/primitives/canvas/widget_render_scroll.zig +11 -3
- package/src/primitives/canvas/widget_render_style.zig +94 -0
- package/src/primitives/canvas/widget_render_surfaces.zig +61 -50
- package/src/primitives/canvas/widget_routing.zig +75 -0
- package/src/primitives/canvas/widget_routing_policy.zig +135 -0
- package/src/primitives/canvas/widget_runtime.zig +20 -1
- package/src/primitives/canvas/widget_semantics.zig +25 -0
- package/src/primitives/canvas/widget_text_input.zig +86 -23
- package/src/primitives/canvas/widget_text_select.zig +1 -0
- package/src/primitives/canvas/widget_tree.zig +8 -1
- package/src/primitives/canvas/widgets.zig +42 -12
- package/src/primitives/canvas/wrapped_layout_policy.zig +104 -0
- package/src/root.zig +21 -0
- package/src/runtime/accessibility_policy.zig +122 -0
- package/src/runtime/api.zig +28 -0
- package/src/runtime/app_dispatch_policy.zig +68 -0
- package/src/runtime/authorization_policy.zig +150 -0
- package/src/runtime/automation_command_policy.zig +241 -0
- package/src/runtime/automation_interaction_policy.zig +107 -0
- package/src/runtime/automation_snapshot.zig +52 -22
- package/src/runtime/automation_snapshot_reference.zig +290 -0
- package/src/runtime/automation_widget_dispatch.zig +267 -355
- package/src/runtime/automation_widget_dispatch_reference.zig +900 -0
- package/src/runtime/blob_policy.zig +58 -0
- package/src/runtime/blob_reference.zig +64 -0
- package/src/runtime/bridge_descriptor_policy.zig +206 -0
- package/src/runtime/builtin_bridge.zig +180 -44
- package/src/runtime/builtin_coordination_policy.zig +121 -0
- package/src/runtime/callback_policy_test_reference.zig +97 -0
- package/src/runtime/canvas_drag_policy.zig +94 -0
- package/src/runtime/canvas_fonts.zig +38 -10
- package/src/runtime/canvas_frame.zig +590 -134
- package/src/runtime/canvas_frame_helpers.zig +1 -0
- package/src/runtime/canvas_hover_policy.zig +131 -0
- package/src/runtime/canvas_images.zig +59 -30
- package/src/runtime/canvas_keyboard_focus_policy.zig +154 -0
- package/src/runtime/canvas_limits.zig +1 -1
- package/src/runtime/canvas_presentation_lifecycle_policy.zig +86 -0
- package/src/runtime/canvas_scene_observation_policy.zig +181 -0
- package/src/runtime/canvas_widget_context_menu.zig +4 -4
- package/src/runtime/canvas_widget_display.zig +110 -9
- package/src/runtime/canvas_widget_events.zig +718 -328
- package/src/runtime/canvas_widget_runtime.zig +437 -81
- package/src/runtime/canvas_widget_scroll_drivers.zig +39 -1
- package/src/runtime/canvas_widget_scroll_tests.zig +31 -0
- package/src/runtime/canvas_widget_state.zig +93 -56
- package/src/runtime/channel_sources.zig +80 -0
- package/src/runtime/command_policy.zig +161 -0
- package/src/runtime/component_policy.zig +83 -0
- package/src/runtime/core.zig +156 -6
- package/src/runtime/desktop_files.zig +189 -0
- package/src/runtime/effects.zig +466 -29
- package/src/runtime/effects_tests.zig +28 -0
- package/src/runtime/file_policy_test_reference.zig +113 -0
- package/src/runtime/flow.zig +418 -341
- package/src/runtime/flow_reference.zig +1426 -0
- package/src/runtime/font_registry_policy.zig +72 -0
- package/src/runtime/frame_profile.zig +24 -33
- package/src/runtime/gpu_surface_events.zig +97 -35
- package/src/runtime/host_event_pump.zig +303 -0
- package/src/runtime/host_event_pump_reference.zig +268 -0
- package/src/runtime/host_flow_policy.zig +155 -0
- package/src/runtime/host_input_regions_policy.zig +156 -0
- package/src/runtime/image_registry_policy.zig +94 -0
- package/src/runtime/input_composition_policy.zig +138 -0
- package/src/runtime/journal_policy.zig +66 -0
- package/src/runtime/journal_reference.zig +53 -0
- package/src/runtime/lifecycle_policy_test_reference.zig +97 -0
- package/src/runtime/markup_development_policy.zig +91 -0
- package/src/runtime/media_surface.zig +40 -1
- package/src/runtime/motion_sampling_policy.zig +159 -0
- package/src/runtime/recording_policy.zig +42 -0
- package/src/runtime/render_animation_policy.zig +206 -0
- package/src/runtime/replay_policy.zig +66 -0
- package/src/runtime/replay_policy_reference.zig +326 -0
- package/src/runtime/replay_progress_policy.zig +64 -0
- package/src/runtime/replay_progress_reference.zig +34 -0
- package/src/runtime/request_policy_test_reference.zig +188 -0
- package/src/runtime/root.zig +13 -0
- package/src/runtime/session_blobs.zig +157 -58
- package/src/runtime/session_blobs_reference.zig +692 -0
- package/src/runtime/session_codec.zig +361 -0
- package/src/runtime/session_codec_reference.zig +1027 -0
- package/src/runtime/session_journal.zig +246 -983
- package/src/runtime/session_record.zig +224 -45
- package/src/runtime/session_replay.zig +157 -415
- package/src/runtime/session_tests.zig +552 -0
- package/src/runtime/shell_admission_policy.zig +225 -0
- package/src/runtime/shell_coordination_policy.zig +138 -0
- package/src/runtime/shell_layout.zig +126 -1
- package/src/runtime/snapshot_policy.zig +60 -0
- package/src/runtime/snapshot_reference.zig +64 -0
- package/src/runtime/state.zig +16 -0
- package/src/runtime/status_validation.zig +190 -0
- package/src/runtime/system_admission_policy.zig +140 -0
- package/src/runtime/system_services.zig +46 -36
- package/src/runtime/tests.zig +1 -0
- package/src/runtime/ts_canvas_hooks.zig +261 -0
- package/src/runtime/ts_canvas_hooks_tests.zig +279 -0
- package/src/runtime/ts_canvas_icons.zig +234 -0
- package/src/runtime/ts_core_host.zig +2325 -411
- package/src/runtime/ts_core_host_tests.zig +1982 -0
- package/src/runtime/ts_test_host.zig +699 -0
- package/src/runtime/ts_ui_app.zig +1087 -45
- package/src/runtime/ui_app.zig +1117 -629
- package/src/runtime/ui_app_provenance.zig +147 -5
- package/src/runtime/ui_app_provenance_reference.zig +370 -0
- package/src/runtime/ui_app_tests.zig +619 -9
- package/src/runtime/ui_app_window_tests.zig +89 -0
- package/src/runtime/view.zig +25 -0
- package/src/runtime/view_canvas.zig +30 -6
- package/src/runtime/view_coordination_policy.zig +147 -0
- package/src/runtime/view_widget_control.zig +51 -14
- package/src/runtime/view_widget_scroll.zig +16 -5
- package/src/runtime/view_widget_text.zig +153 -68
- package/src/runtime/view_widget_tree.zig +460 -56
- package/src/runtime/webview_view_bridge_tests.zig +2 -0
- package/src/runtime/widget_motion_policy.zig +238 -0
- package/src/runtime/window_command_bridge_tests.zig +63 -0
- package/src/runtime/window_lifecycle_policy.zig +127 -0
- package/src/runtime/window_storage.zig +74 -8
- package/src/runtime/window_view_runtime.zig +148 -33
- package/src/runtime/window_views.zig +163 -10
- package/src/tooling/components/identity_tests.zig +62 -36
- package/src/tooling/components/stepper.native +24 -0
- package/src/tooling/components/stepper.zig +0 -19
- package/src/tooling/components/timeline-item.native +22 -0
- package/src/tooling/components/timeline.native +5 -3
- package/src/tooling/components/timeline_item.zig +0 -32
- package/src/tooling/eject_components.zig +76 -8
- package/src/tooling/ios.zig +66 -12
- package/src/tooling/manifest.zig +35 -0
- package/src/tooling/raw_manifest.zig +6 -0
- package/src/tooling/templates.zig +15 -3
- package/src/tooling/ts_core.zig +13 -3
- package/src/tooling/verbs.zig +22 -0
- package/tools/corewire/build_profile.mjs +54 -0
- package/tools/corewire/contract_intake.ts +303 -0
- package/tools/corewire/contract_intake.zig +82 -0
- package/tools/corewire/core.test.ts +166 -0
- package/tools/corewire/core_abi.zig +51 -0
- package/tools/corewire/core_cases.ts +233 -0
- package/tools/corewire/core_contract.ts +407 -0
- package/tools/corewire/core_emission.ts +136 -0
- package/tools/corewire/core_emission.zig +69 -0
- package/tools/corewire/core_goldens.json +3110 -0
- package/tools/corewire/core_policy.ts +14 -0
- package/tools/corewire/core_policy.zig +48 -0
- package/tools/corewire/core_projection.ts +360 -0
- package/tools/corewire/core_vocabulary.ts +6 -0
- package/tools/corewire/emit.zig +19 -1590
- package/tools/corewire/emit_facade.ts +714 -0
- package/tools/corewire/emit_facade.zig +10 -3752
- package/tools/corewire/emit_mirror.ts +290 -0
- package/tools/corewire/emit_profile.ts +50 -0
- package/tools/corewire/emit_service.ts +331 -0
- package/tools/corewire/emit_service.zig +23 -842
- package/tools/corewire/entry.test.ts +95 -0
- package/tools/corewire/entry_coordination.ts +127 -0
- package/tools/corewire/entry_coordination.zig +190 -0
- package/tools/corewire/facade_templates.ts +85 -0
- package/tools/corewire/filesystem.test.ts +166 -0
- package/tools/corewire/filesystem_coordination.ts +213 -0
- package/tools/corewire/filesystem_coordination.zig +245 -0
- package/tools/corewire/intake.test.ts +35 -0
- package/tools/corewire/intake_cases.ts +55 -0
- package/tools/corewire/intake_goldens.json +12237 -0
- package/tools/corewire/invocation.test.ts +24 -0
- package/tools/corewire/invocation.ts +175 -0
- package/tools/corewire/invocation.zig +136 -0
- package/tools/corewire/invocation_cases.ts +60 -0
- package/tools/corewire/invocation_fixture.ts +33 -0
- package/tools/corewire/invocation_goldens.json +1143 -0
- package/tools/corewire/invocation_tests.zig +111 -0
- package/tools/corewire/invocation_usage.ts +2 -0
- package/tools/corewire/lossless_projection.ts +96 -0
- package/tools/corewire/main.zig +7 -680
- package/tools/corewire/main_reference.zig +415 -0
- package/tools/corewire/mirror_templates.ts +55 -0
- package/tools/corewire/profile.test.ts +248 -0
- package/tools/corewire/profile.zig +56 -0
- package/tools/corewire/profile_emission.ts +202 -0
- package/tools/corewire/profile_library.json +29 -0
- package/tools/corewire/profile_tests.zig +136 -0
- package/tools/corewire/service.test.ts +75 -0
- package/tools/corewire/service_cases.ts +61 -0
- package/tools/corewire/service_contract.zig +40 -146
- package/tools/corewire/service_goldens.json +650 -0
- package/tools/corewire/service_projection.zig +52 -0
- package/tools/corewire/service_templates.ts +14 -0
- package/tools/corewire/shim_rt.zig +9 -0
- package/tools/corewire/sidecar.zig +267 -1438
- package/tools/corewire/emit_profile.zig +0 -521
|
@@ -26,6 +26,7 @@ const runtime_clock = @import("clock.zig");
|
|
|
26
26
|
const runtime_effects = @import("effects.zig");
|
|
27
27
|
const journal = @import("session_journal.zig");
|
|
28
28
|
const session_blobs = @import("session_blobs.zig");
|
|
29
|
+
const recording = @import("recording_policy.zig");
|
|
29
30
|
|
|
30
31
|
/// Keep ordinary query pages self-contained while spilling pages large
|
|
31
32
|
/// enough to dominate the journal. The relational page's own hard ceiling
|
|
@@ -43,6 +44,8 @@ pub const RecorderSink = struct {
|
|
|
43
44
|
|
|
44
45
|
pub const SessionRecorder = struct {
|
|
45
46
|
sink: RecorderSink,
|
|
47
|
+
/// Compiled coordination is independent of replay callbacks. Bind before begin.
|
|
48
|
+
recording_policy: recording.Policy = null,
|
|
46
49
|
/// Where large effect payloads go out of line (`blobs/` beside the
|
|
47
50
|
/// journal, content-addressed — see session_blobs.zig). Bound by
|
|
48
51
|
/// the owner alongside the sink; null means no blob storage, and
|
|
@@ -58,6 +61,8 @@ pub const SessionRecorder = struct {
|
|
|
58
61
|
effect_count: u64 = 0,
|
|
59
62
|
checkpoint_count: u64 = 0,
|
|
60
63
|
screenshot_count: u64 = 0,
|
|
64
|
+
window_chrome_count: u64 = 0,
|
|
65
|
+
window_chrome_source: journal.WindowChromeSource = .native_queries,
|
|
61
66
|
/// Per-session salt for credential replay-placeholder digests. The digest
|
|
62
67
|
/// is deliberately independent of the secret, so a shareable journal is
|
|
63
68
|
/// not an offline guessing oracle. Successful secret bytes are never
|
|
@@ -67,7 +72,7 @@ pub const SessionRecorder = struct {
|
|
|
67
72
|
/// checkpoint follows each published frame.
|
|
68
73
|
last_checkpoint_frame: u64 = 0,
|
|
69
74
|
depth: usize = 0,
|
|
70
|
-
/// Staging-stack depth of the
|
|
75
|
+
/// Staging-stack depth of the accessibility or widget-menu action
|
|
71
76
|
/// currently being dispatched, if any. While set, nested
|
|
72
77
|
/// stage/commit pairs are suppressed: the outer action record is the
|
|
73
78
|
/// journal's WHOLE representation of the interaction (see
|
|
@@ -76,6 +81,8 @@ pub const SessionRecorder = struct {
|
|
|
76
81
|
staged_lens: [journal.max_session_event_depth]usize = [_]usize{0} ** journal.max_session_event_depth,
|
|
77
82
|
staged_suppressed: [journal.max_session_event_depth]bool = [_]bool{false} ** journal.max_session_event_depth,
|
|
78
83
|
staged: [journal.max_session_event_depth][journal.max_session_event_bytes]u8 = undefined,
|
|
84
|
+
staged_chrome_counts: [journal.max_session_event_depth]usize = @splat(0),
|
|
85
|
+
staged_chrome: [journal.max_session_event_depth][journal.max_session_window_chrome_queries]journal.WindowChromeRecord = undefined,
|
|
79
86
|
/// Encode scratch for effect payloads (up to a whole file read).
|
|
80
87
|
effect_buffer: [journal.max_session_record_bytes]u8 = undefined,
|
|
81
88
|
small_buffer: [1024]u8 = undefined,
|
|
@@ -87,8 +94,12 @@ pub const SessionRecorder = struct {
|
|
|
87
94
|
/// Write the preamble and session header. Must run before the first
|
|
88
95
|
/// dispatched event.
|
|
89
96
|
pub fn begin(self: *SessionRecorder, header: Header) void {
|
|
90
|
-
if (self.
|
|
97
|
+
if (self.recordingPlan(.begin, .{})) |decision| {
|
|
98
|
+
if (decision.action == .skip) return;
|
|
99
|
+
std.debug.assert(decision.action == .proceed);
|
|
100
|
+
} else if (self.began or self.failed) return;
|
|
91
101
|
self.began = true;
|
|
102
|
+
self.window_chrome_source = header.window_chrome_source;
|
|
92
103
|
// SessionRecorder deliberately has no ambient-I/O handle. Derive a
|
|
93
104
|
// per-session salt from the already-journaled header identity and
|
|
94
105
|
// timestamp. The resulting placeholder digest is metadata only and
|
|
@@ -104,8 +115,8 @@ pub const SessionRecorder = struct {
|
|
|
104
115
|
salt_hasher.final(&salt_digest);
|
|
105
116
|
@memcpy(&self.credentials_salt, salt_digest[0..self.credentials_salt.len]);
|
|
106
117
|
var preamble_buffer: [journal.preamble_len]u8 = undefined;
|
|
107
|
-
self.write(journal.
|
|
108
|
-
const payload = journal.
|
|
118
|
+
self.write(journal.writePreambleWithPolicy(self.recording_policy, &preamble_buffer));
|
|
119
|
+
const payload = journal.encodeHeaderWithPolicy(self.recording_policy, header, &self.small_buffer) catch {
|
|
109
120
|
return self.fail("session header does not fit its record budget");
|
|
110
121
|
};
|
|
111
122
|
self.writeRecord(.header, payload);
|
|
@@ -134,7 +145,10 @@ pub const SessionRecorder = struct {
|
|
|
134
145
|
/// the suppressed window). Effect results are NOT suppressed: they
|
|
135
146
|
/// write directly to the stream and still precede the action record,
|
|
136
147
|
/// exactly the feed-then-dispatch order replay depends on. BOTH
|
|
137
|
-
///
|
|
148
|
+
/// Declared widget-menu invocations likewise own their synthetic
|
|
149
|
+
/// selection: replay reconstructs the pending request and its token
|
|
150
|
+
/// before dispatching the selection, with chrome facts owned here.
|
|
151
|
+
/// Both accessibility entry surfaces stage the action record: the platform AX event
|
|
138
152
|
/// path stages it at the dispatch choke point, and the direct verb
|
|
139
153
|
/// surfaces (an embed host's `widgetAction`, automation
|
|
140
154
|
/// `widget_action` commands) stage a synthetic one inside
|
|
@@ -147,6 +161,27 @@ pub const SessionRecorder = struct {
|
|
|
147
161
|
/// suppressed placeholder: the outermost action owns the window and
|
|
148
162
|
/// the journal keeps exactly one record.
|
|
149
163
|
pub fn stageEvent(self: *SessionRecorder, event: platform.Event) void {
|
|
164
|
+
if (self.recordingPlan(.stage, .{ .category = @intFromBool(event == .widget_accessibility_action or event == .widget_context_menu_action) })) |decision| {
|
|
165
|
+
switch (decision.action) {
|
|
166
|
+
.skip => return,
|
|
167
|
+
.depth_budget => return self.fail("dispatch nesting exceeded max_session_event_depth - this is a runtime bug, not a session shape"),
|
|
168
|
+
.suppressed => {
|
|
169
|
+
self.staged_suppressed[self.depth] = true;
|
|
170
|
+
self.staged_lens[self.depth] = 0;
|
|
171
|
+
},
|
|
172
|
+
.proceed => {
|
|
173
|
+
const encoded = journal.encodeEventWithPolicy(self.recording_policy, event, &self.staged[self.depth]) catch
|
|
174
|
+
return self.fail("a platform event exceeded max_session_event_bytes");
|
|
175
|
+
self.staged_lens[self.depth] = encoded.len;
|
|
176
|
+
self.staged_suppressed[self.depth] = false;
|
|
177
|
+
self.staged_chrome_counts[self.depth] = 0;
|
|
178
|
+
},
|
|
179
|
+
else => @panic("invalid compiled event staging action"),
|
|
180
|
+
}
|
|
181
|
+
self.depth = decision.depth;
|
|
182
|
+
self.suppress_owner_depth = decision.owner;
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
150
185
|
if (!self.began or self.failed or self.finished) return;
|
|
151
186
|
if (self.depth >= journal.max_session_event_depth) {
|
|
152
187
|
return self.fail("dispatch nesting exceeded max_session_event_depth - this is a runtime bug, not a session shape");
|
|
@@ -157,46 +192,91 @@ pub const SessionRecorder = struct {
|
|
|
157
192
|
self.depth += 1;
|
|
158
193
|
return;
|
|
159
194
|
}
|
|
160
|
-
const encoded = journal.
|
|
195
|
+
const encoded = journal.encodeEventWithPolicy(self.recording_policy, event, &self.staged[self.depth]) catch {
|
|
161
196
|
return self.fail("a platform event exceeded max_session_event_bytes");
|
|
162
197
|
};
|
|
163
198
|
self.staged_lens[self.depth] = encoded.len;
|
|
164
199
|
self.staged_suppressed[self.depth] = false;
|
|
165
|
-
|
|
200
|
+
self.staged_chrome_counts[self.depth] = 0;
|
|
201
|
+
if (event == .widget_accessibility_action or event == .widget_context_menu_action) self.suppress_owner_depth = self.depth;
|
|
166
202
|
self.depth += 1;
|
|
167
203
|
}
|
|
168
204
|
|
|
169
205
|
/// Append the innermost staged event record. Call exactly once per
|
|
170
206
|
/// successful `stageEvent`, on dispatch exit.
|
|
171
207
|
pub fn commitEvent(self: *SessionRecorder) void {
|
|
172
|
-
if (
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
if (
|
|
208
|
+
if (self.recordingPlan(.commit, .{})) |decision| {
|
|
209
|
+
if (decision.action == .skip) return;
|
|
210
|
+
self.depth = decision.depth;
|
|
211
|
+
self.suppress_owner_depth = decision.owner;
|
|
212
|
+
if (decision.action == .suppressed) return;
|
|
213
|
+
if (decision.action != .proceed) @panic("invalid compiled event commit action");
|
|
214
|
+
} else {
|
|
215
|
+
if (!self.began or self.failed or self.finished) return;
|
|
216
|
+
if (self.depth == 0) return;
|
|
217
|
+
self.depth -= 1;
|
|
218
|
+
if (self.staged_suppressed[self.depth]) return;
|
|
219
|
+
if (self.suppress_owner_depth) |owner_depth| {
|
|
220
|
+
if (owner_depth == self.depth) self.suppress_owner_depth = null;
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
// Facts belong to the event that queried them. A nested event
|
|
224
|
+
// commits its own facts first; suppressed accessibility children
|
|
225
|
+
// contribute to their outer action in the original query order.
|
|
226
|
+
for (self.staged_chrome[self.depth][0..self.staged_chrome_counts[self.depth]]) |record| {
|
|
227
|
+
const payload = journal.encodeWindowChromeWithPolicy(self.recording_policy, record, &self.small_buffer) catch return self.fail("window chrome record over budget");
|
|
228
|
+
self.writeRecord(.window_chrome, payload);
|
|
229
|
+
self.window_chrome_count = self.nextCount(self.window_chrome_count);
|
|
178
230
|
}
|
|
179
231
|
self.writeRecord(.event, self.staged[self.depth][0..self.staged_lens[self.depth]]);
|
|
180
|
-
|
|
232
|
+
self.event_count = self.nextCount(self.event_count);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/// Stage the complete OS result beside its consuming event, rather
|
|
236
|
+
/// than publishing it ahead of an unrelated nested dispatch.
|
|
237
|
+
pub fn recordWindowChrome(self: *SessionRecorder, record: journal.WindowChromeRecord) void {
|
|
238
|
+
if (self.recordingPlan(.chrome, .{})) |decision| {
|
|
239
|
+
switch (decision.action) {
|
|
240
|
+
.skip => return,
|
|
241
|
+
.unavailable_chrome => return self.fail("a chrome-less session queried native window chrome"),
|
|
242
|
+
.unowned_chrome => return self.fail("window chrome queried outside a recorded event"),
|
|
243
|
+
.chrome_budget => return self.fail("window chrome queries exceeded their per-event budget"),
|
|
244
|
+
.proceed => {},
|
|
245
|
+
else => @panic("invalid compiled chrome staging action"),
|
|
246
|
+
}
|
|
247
|
+
self.staged_chrome[decision.depth][self.staged_chrome_counts[decision.depth]] = record;
|
|
248
|
+
self.staged_chrome_counts[decision.depth] = decision.chrome_count;
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
if (!self.began or self.failed or self.finished) return;
|
|
252
|
+
if (self.window_chrome_source == .unavailable) return self.fail("a chrome-less session queried native window chrome");
|
|
253
|
+
if (self.depth == 0) return self.fail("window chrome queried outside a recorded event");
|
|
254
|
+
const owner = self.suppress_owner_depth orelse (self.depth - 1);
|
|
255
|
+
const count = self.staged_chrome_counts[owner];
|
|
256
|
+
if (count == journal.max_session_window_chrome_queries) return self.fail("window chrome queries exceeded their per-event budget");
|
|
257
|
+
self.staged_chrome[owner][count] = record;
|
|
258
|
+
self.staged_chrome_counts[owner] = count + 1;
|
|
181
259
|
}
|
|
182
260
|
|
|
183
261
|
/// True when dispatch just returned to the top level and the frame
|
|
184
262
|
/// index moved — the once-per-published-frame checkpoint gate.
|
|
185
263
|
pub fn wantsCheckpoint(self: *const SessionRecorder, frame_index: u64) bool {
|
|
264
|
+
if (self.recordingPlan(.checkpoint_gate, .{ .a = frame_index, .b = self.last_checkpoint_frame })) |decision|
|
|
265
|
+
return decision.action == .proceed;
|
|
186
266
|
return self.began and !self.failed and !self.finished and
|
|
187
267
|
self.depth == 0 and frame_index != self.last_checkpoint_frame;
|
|
188
268
|
}
|
|
189
269
|
|
|
190
270
|
pub fn recordCheckpoint(self: *SessionRecorder, frame_index: u64, fingerprint: u64) void {
|
|
191
|
-
if (!self.
|
|
271
|
+
if (!self.active(.checkpoint)) return;
|
|
192
272
|
self.last_checkpoint_frame = frame_index;
|
|
193
|
-
const payload = journal.
|
|
273
|
+
const payload = journal.encodeCheckpointWithPolicy(self.recording_policy, .{
|
|
194
274
|
.event_ordinal = self.event_count,
|
|
195
275
|
.frame_index = frame_index,
|
|
196
276
|
.fingerprint = fingerprint,
|
|
197
277
|
}, &self.small_buffer) catch return self.fail("checkpoint record over budget");
|
|
198
278
|
self.writeRecord(.checkpoint, payload);
|
|
199
|
-
|
|
279
|
+
self.checkpoint_count = self.nextCount(self.checkpoint_count);
|
|
200
280
|
}
|
|
201
281
|
|
|
202
282
|
/// Mark the session with a pixel checkpoint (an automation
|
|
@@ -204,8 +284,8 @@ pub const SessionRecorder = struct {
|
|
|
204
284
|
/// at the same scale through the deterministic reference renderer
|
|
205
285
|
/// and compares hashes.
|
|
206
286
|
pub fn recordScreenshot(self: *SessionRecorder, view_label: []const u8, scale: f32, png_hash: u64, png_len: u64) void {
|
|
207
|
-
if (!self.
|
|
208
|
-
const payload = journal.
|
|
287
|
+
if (!self.active(.screenshot)) return;
|
|
288
|
+
const payload = journal.encodeScreenshotWithPolicy(self.recording_policy, .{
|
|
209
289
|
.event_ordinal = self.event_count,
|
|
210
290
|
.view_label = view_label,
|
|
211
291
|
.scale = scale,
|
|
@@ -213,7 +293,7 @@ pub const SessionRecorder = struct {
|
|
|
213
293
|
.png_len = png_len,
|
|
214
294
|
}, &self.small_buffer) catch return self.fail("screenshot record over budget");
|
|
215
295
|
self.writeRecord(.screenshot, payload);
|
|
216
|
-
|
|
296
|
+
self.screenshot_count = self.nextCount(self.screenshot_count);
|
|
217
297
|
}
|
|
218
298
|
|
|
219
299
|
/// Record one drained effect result (the `Effects.bindJournal`
|
|
@@ -223,13 +303,17 @@ pub const SessionRecorder = struct {
|
|
|
223
303
|
/// record keeps only the address and length, so records stay small
|
|
224
304
|
/// and identical payloads share one blob.
|
|
225
305
|
pub fn recordEffect(self: *SessionRecorder, record: runtime_effects.EffectResultRecord) void {
|
|
226
|
-
|
|
306
|
+
const decision = self.recordingPlan(.effect, .{ .category = @intFromEnum(record.kind), .file_chunk = record.file_event == .chunk, .credential_get = record.credentials_operation == .get, .credential_ok = record.credentials_outcome == .ok, .b = record.payload.len, .limit_a = max_inline_db_page_bytes });
|
|
307
|
+
if (decision) |value| {
|
|
308
|
+
if (value.action == .skip) return;
|
|
309
|
+
if (value.action != .proceed) @panic("invalid compiled effect recording action");
|
|
310
|
+
} else if (!self.began or self.failed or self.finished) return;
|
|
227
311
|
var journaled = record;
|
|
228
|
-
if (record.kind == .credentials) {
|
|
312
|
+
if (if (decision) |value| value.treatment == .redact or value.treatment == .placeholder else record.kind == .credentials) {
|
|
229
313
|
// Error bytes duplicate the closed outcome and successful get
|
|
230
314
|
// bytes are secrets. Neither belongs in a shareable artifact.
|
|
231
315
|
journaled.payload = "";
|
|
232
|
-
if (record.credentials_operation == .get and record.credentials_outcome == .ok) {
|
|
316
|
+
if (if (decision) |value| value.treatment == .placeholder else record.credentials_operation == .get and record.credentials_outcome == .ok) {
|
|
233
317
|
var hasher = std.crypto.hash.sha2.Sha256.init(.{});
|
|
234
318
|
hasher.update(&self.credentials_salt);
|
|
235
319
|
var ordinal: [8]u8 = undefined;
|
|
@@ -241,7 +325,7 @@ pub const SessionRecorder = struct {
|
|
|
241
325
|
journaled.credentials_secret_len = record.payload.len;
|
|
242
326
|
}
|
|
243
327
|
}
|
|
244
|
-
if (record.kind == .file and record.file_event == .chunk and record.payload.len > 0) {
|
|
328
|
+
if (if (decision) |value| value.treatment == .file else record.kind == .file and record.file_event == .chunk and record.payload.len > 0) {
|
|
245
329
|
const blob_sink = self.blob_sink orelse {
|
|
246
330
|
return self.fail("a streamed file chunk needs the session blob store, and none is bound - wire SessionRecorder.blob_sink");
|
|
247
331
|
};
|
|
@@ -251,7 +335,7 @@ pub const SessionRecorder = struct {
|
|
|
251
335
|
journaled.file_blob_len = record.payload.len;
|
|
252
336
|
journaled.payload = "";
|
|
253
337
|
}
|
|
254
|
-
if (record.kind == .image and record.payload.len > 0) {
|
|
338
|
+
if (if (decision) |value| value.treatment == .image else record.kind == .image and record.payload.len > 0) {
|
|
255
339
|
const blob_sink = self.blob_sink orelse {
|
|
256
340
|
return self.fail("an image effect result needs the session blob store, and none is bound - wire SessionRecorder.blob_sink (the app runner creates blobs/ beside the journal)");
|
|
257
341
|
};
|
|
@@ -267,7 +351,7 @@ pub const SessionRecorder = struct {
|
|
|
267
351
|
// content-addressed store, address into the record — stream
|
|
268
352
|
// payloads stay out of the journal and identical batches
|
|
269
353
|
// (prompts, repeated screens) share one blob.
|
|
270
|
-
if (record.kind == .pty and record.payload.len > 0) {
|
|
354
|
+
if (if (decision) |value| value.treatment == .pty else record.kind == .pty and record.payload.len > 0) {
|
|
271
355
|
const blob_sink = self.blob_sink orelse {
|
|
272
356
|
return self.fail("a pty output result needs the session blob store, and none is bound - wire SessionRecorder.blob_sink (the app runner creates blobs/ beside the journal)");
|
|
273
357
|
};
|
|
@@ -279,7 +363,7 @@ pub const SessionRecorder = struct {
|
|
|
279
363
|
journaled.pty_blob_len = record.payload.len;
|
|
280
364
|
journaled.payload = "";
|
|
281
365
|
}
|
|
282
|
-
if (record.kind == .persist and record.payload.len > 0) {
|
|
366
|
+
if (if (decision) |value| value.treatment == .persist else record.kind == .persist and record.payload.len > 0) {
|
|
283
367
|
const blob_sink = self.blob_sink orelse {
|
|
284
368
|
return self.fail("a model restore needs the session blob store, and none is bound - wire SessionRecorder.blob_sink (the app runner creates blobs/ beside the journal)");
|
|
285
369
|
};
|
|
@@ -291,7 +375,7 @@ pub const SessionRecorder = struct {
|
|
|
291
375
|
journaled.persist_blob_len = record.payload.len;
|
|
292
376
|
journaled.payload = "";
|
|
293
377
|
}
|
|
294
|
-
if (record.kind == .db and record.payload.len > max_inline_db_page_bytes) {
|
|
378
|
+
if (if (decision) |value| value.treatment == .db else record.kind == .db and record.payload.len > max_inline_db_page_bytes) {
|
|
295
379
|
const blob_sink = self.blob_sink orelse {
|
|
296
380
|
return self.fail("a large relational page needs the session blob store, and none is bound - wire SessionRecorder.blob_sink (the app runner creates blobs/ beside the journal)");
|
|
297
381
|
};
|
|
@@ -303,11 +387,11 @@ pub const SessionRecorder = struct {
|
|
|
303
387
|
journaled.db_blob_len = record.payload.len;
|
|
304
388
|
journaled.payload = "";
|
|
305
389
|
}
|
|
306
|
-
const payload = journal.
|
|
390
|
+
const payload = journal.encodeEffectWithPolicy(self.recording_policy, journaled, &self.effect_buffer) catch {
|
|
307
391
|
return self.fail("an effect result exceeded max_session_record_bytes");
|
|
308
392
|
};
|
|
309
393
|
self.writeRecord(.effect, payload);
|
|
310
|
-
|
|
394
|
+
self.effect_count = self.nextCount(self.effect_count);
|
|
311
395
|
}
|
|
312
396
|
|
|
313
397
|
/// The type-erased binding `Effects.bindJournal` takes.
|
|
@@ -324,45 +408,87 @@ pub const SessionRecorder = struct {
|
|
|
324
408
|
/// seals nothing: without the end record, replay refuses the file
|
|
325
409
|
/// as truncated rather than silently replaying a prefix.
|
|
326
410
|
pub fn finish(self: *SessionRecorder) void {
|
|
327
|
-
if (!self.
|
|
411
|
+
if (!self.active(.finish)) return;
|
|
328
412
|
self.finished = true;
|
|
329
|
-
const payload = journal.
|
|
413
|
+
const payload = journal.encodeEndWithPolicy(self.recording_policy, .{
|
|
330
414
|
.event_count = self.event_count,
|
|
331
415
|
.effect_count = self.effect_count,
|
|
332
416
|
.checkpoint_count = self.checkpoint_count,
|
|
333
417
|
.screenshot_count = self.screenshot_count,
|
|
418
|
+
.window_chrome_count = self.window_chrome_count,
|
|
334
419
|
}, &self.small_buffer) catch return self.fail("end record over budget");
|
|
335
420
|
self.writeRecord(.end, payload);
|
|
336
421
|
}
|
|
337
422
|
|
|
338
423
|
fn writeRecord(self: *SessionRecorder, kind: journal.RecordKind, payload: []const u8) void {
|
|
339
|
-
|
|
340
|
-
if (payload.len
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
424
|
+
var total: u64 = undefined;
|
|
425
|
+
if (self.recordingPlan(.record, .{ .a = self.bytes_written, .b = payload.len, .limit_a = journal.max_session_record_bytes, .limit_b = journal.max_session_journal_bytes })) |decision| {
|
|
426
|
+
switch (decision.action) {
|
|
427
|
+
.skip => return,
|
|
428
|
+
.record_budget => return self.fail("a record exceeded max_session_record_bytes"),
|
|
429
|
+
.journal_budget => return self.fail("the journal exceeded max_session_journal_bytes - recording stopped"),
|
|
430
|
+
.proceed => total = decision.value,
|
|
431
|
+
else => @panic("invalid compiled record write action"),
|
|
432
|
+
}
|
|
433
|
+
} else {
|
|
434
|
+
if (self.failed) return;
|
|
435
|
+
if (payload.len > journal.max_session_record_bytes) return self.fail("a record exceeded max_session_record_bytes");
|
|
436
|
+
total = self.bytes_written + 5 + payload.len;
|
|
437
|
+
if (total > journal.max_session_journal_bytes) return self.fail("the journal exceeded max_session_journal_bytes - recording stopped");
|
|
346
438
|
}
|
|
347
|
-
|
|
348
|
-
record_header[0] = @intFromEnum(kind);
|
|
349
|
-
std.mem.writeInt(u32, record_header[1..5], @intCast(payload.len), .little);
|
|
439
|
+
const record_header = journal.frameHeader(self.recording_policy, kind, payload.len, 5 + payload.len) catch @panic("admitted journal frame exceeded its budget");
|
|
350
440
|
self.write(&record_header);
|
|
351
441
|
self.write(payload);
|
|
352
|
-
if (
|
|
442
|
+
if (self.writable()) self.bytes_written = total;
|
|
353
443
|
}
|
|
354
444
|
|
|
355
445
|
fn write(self: *SessionRecorder, bytes: []const u8) void {
|
|
356
|
-
if (self.
|
|
446
|
+
if (!self.writable()) return;
|
|
357
447
|
self.sink.write_fn(self.sink.context, bytes) catch |err| {
|
|
358
448
|
self.fail(@errorName(err));
|
|
359
449
|
};
|
|
360
450
|
}
|
|
361
451
|
|
|
452
|
+
fn recordingPlan(self: *const SessionRecorder, stage: recording.Stage, extra: recording.Facts) ?recording.Plan {
|
|
453
|
+
if (self.recording_policy == null) return null;
|
|
454
|
+
var facts = extra;
|
|
455
|
+
facts.began = self.began;
|
|
456
|
+
facts.finished = self.finished;
|
|
457
|
+
facts.failed = self.failed;
|
|
458
|
+
facts.depth = self.depth;
|
|
459
|
+
facts.owner = self.suppress_owner_depth;
|
|
460
|
+
facts.suppressed = self.depth > 0 and self.staged_suppressed[self.depth - 1];
|
|
461
|
+
facts.chrome_unavailable = self.window_chrome_source == .unavailable;
|
|
462
|
+
if (self.depth > 0) facts.chrome_count = self.staged_chrome_counts[self.suppress_owner_depth orelse (self.depth - 1)];
|
|
463
|
+
return recording.plan(self.recording_policy, stage, facts);
|
|
464
|
+
}
|
|
465
|
+
|
|
466
|
+
fn writable(self: *const SessionRecorder) bool {
|
|
467
|
+
if (self.recordingPlan(.write, .{})) |decision| return decision.action == .proceed;
|
|
468
|
+
return !self.failed;
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
fn active(self: *const SessionRecorder, stage: recording.Stage) bool {
|
|
472
|
+
if (self.recordingPlan(stage, .{})) |decision| return decision.action == .proceed;
|
|
473
|
+
return self.began and !self.failed and !self.finished;
|
|
474
|
+
}
|
|
475
|
+
|
|
476
|
+
fn nextCount(self: *const SessionRecorder, count: u64) u64 {
|
|
477
|
+
if (self.recordingPlan(.count, .{ .a = count })) |decision| {
|
|
478
|
+
if (decision.action == .skip) return count;
|
|
479
|
+
if (decision.action != .proceed) @panic("invalid compiled recording count action");
|
|
480
|
+
return decision.value;
|
|
481
|
+
}
|
|
482
|
+
return if (self.failed) count else count + 1;
|
|
483
|
+
}
|
|
484
|
+
|
|
362
485
|
/// Flip into the failed state, loudly, once. Recording failures
|
|
363
486
|
/// degrade — the app keeps running; only the journal dies.
|
|
364
487
|
fn fail(self: *SessionRecorder, reason: []const u8) void {
|
|
365
|
-
if (self.
|
|
488
|
+
if (self.recordingPlan(.fail, .{})) |decision| {
|
|
489
|
+
if (decision.action == .skip) return;
|
|
490
|
+
if (decision.action != .proceed) @panic("invalid compiled recording failure action");
|
|
491
|
+
} else if (self.failed) return;
|
|
366
492
|
self.failed = true;
|
|
367
493
|
// No stderr on freestanding targets (the docs' wasm preview
|
|
368
494
|
// host): analyzing the print would drag `std.Io.Threaded` in.
|
|
@@ -752,3 +878,56 @@ test "checkpoint gate fires once per frame index" {
|
|
|
752
878
|
try testing.expect(!recorder.wantsCheckpoint(1));
|
|
753
879
|
try testing.expect(recorder.wantsCheckpoint(2));
|
|
754
880
|
}
|
|
881
|
+
|
|
882
|
+
test "recorder binds chrome facts to nested events and outer accessibility actions" {
|
|
883
|
+
var buffer = BufferSink{};
|
|
884
|
+
const recorder = try testing.allocator.create(SessionRecorder);
|
|
885
|
+
defer testing.allocator.destroy(recorder);
|
|
886
|
+
recorder.* = SessionRecorder.init(buffer.sink());
|
|
887
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome" });
|
|
888
|
+
recorder.stageEvent(.frame_requested);
|
|
889
|
+
recorder.recordWindowChrome(.{ .window_id = 1, .chrome = .{ .insets = .{ .left = 98 } } });
|
|
890
|
+
recorder.stageEvent(.wake);
|
|
891
|
+
recorder.recordWindowChrome(.{ .window_id = 2, .chrome = .{ .tabs_projected = true } });
|
|
892
|
+
recorder.commitEvent();
|
|
893
|
+
recorder.commitEvent();
|
|
894
|
+
recorder.stageEvent(.{ .widget_accessibility_action = .{ .window_id = 1, .label = "canvas", .id = 1, .action = .press } });
|
|
895
|
+
recorder.recordWindowChrome(.{ .window_id = 1, .chrome = .{} });
|
|
896
|
+
recorder.stageEvent(.wake);
|
|
897
|
+
recorder.recordWindowChrome(.{ .window_id = 2, .chrome = .{} });
|
|
898
|
+
recorder.commitEvent();
|
|
899
|
+
recorder.commitEvent();
|
|
900
|
+
recorder.finish();
|
|
901
|
+
try testing.expect(!recorder.failed);
|
|
902
|
+
var reader = try journal.Reader.init(buffer.bytes());
|
|
903
|
+
_ = (try reader.next()).?;
|
|
904
|
+
try testing.expectEqual(@as(u64, 2), (try reader.next()).?.window_chrome.window_id);
|
|
905
|
+
try testing.expect((try reader.next()).?.event == .wake);
|
|
906
|
+
try testing.expectEqual(@as(u64, 1), (try reader.next()).?.window_chrome.window_id);
|
|
907
|
+
try testing.expect((try reader.next()).?.event == .frame_requested);
|
|
908
|
+
try testing.expectEqual(@as(u64, 1), (try reader.next()).?.window_chrome.window_id);
|
|
909
|
+
try testing.expectEqual(@as(u64, 2), (try reader.next()).?.window_chrome.window_id);
|
|
910
|
+
try testing.expect((try reader.next()).?.event == .widget_accessibility_action);
|
|
911
|
+
const end = (try reader.next()).?.end;
|
|
912
|
+
try testing.expectEqual(@as(u64, 3), end.event_count);
|
|
913
|
+
try testing.expectEqual(@as(u64, 4), end.window_chrome_count);
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
test "recorder refuses unowned and over-budget chrome facts without sealing" {
|
|
917
|
+
var buffer = BufferSink{};
|
|
918
|
+
const recorder = try testing.allocator.create(SessionRecorder);
|
|
919
|
+
defer testing.allocator.destroy(recorder);
|
|
920
|
+
recorder.* = SessionRecorder.init(buffer.sink());
|
|
921
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome" });
|
|
922
|
+
recorder.recordWindowChrome(.{ .window_id = 1, .chrome = .{} });
|
|
923
|
+
try testing.expect(recorder.failed);
|
|
924
|
+
try testing.expect(!recorder.finished);
|
|
925
|
+
buffer.len = 0;
|
|
926
|
+
recorder.* = SessionRecorder.init(buffer.sink());
|
|
927
|
+
recorder.begin(.{ .platform_name = "test", .app_name = "chrome" });
|
|
928
|
+
recorder.stageEvent(.wake);
|
|
929
|
+
for (0..journal.max_session_window_chrome_queries + 1) |_| recorder.recordWindowChrome(.{ .window_id = 1, .chrome = .{} });
|
|
930
|
+
recorder.finish();
|
|
931
|
+
try testing.expect(recorder.failed);
|
|
932
|
+
try testing.expect(!recorder.finished);
|
|
933
|
+
}
|