@buaa_smat/hometrans 26.0.2 → 26.0.4
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 -7
- package/agents/code-reviewer.md +111 -154
- package/dist/cli/index.js +4 -1
- package/dist/cli/init.js +131 -26
- package/dist/cli/uninstall.js +5 -5
- package/dist/platform/language.js +77 -0
- package/env-requirements.json +30 -5
- package/i18n/FILE-NAMES.md +9 -0
- package/i18n/agents/code-reviewer.md +436 -0
- package/i18n/agents/model-render-worker.md +38 -0
- package/i18n/agents/specgen-worker.md +18 -0
- package/i18n/commands/hometrans.md +17 -0
- package/i18n/skills/a2h-app-migrate/SKILL.md +206 -0
- package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -0
- package/i18n/skills/a2h-app-migrate/references/feature-scope.md +121 -0
- package/i18n/skills/a2h-app-migrate/references/specs.example.json +19 -0
- package/i18n/skills/a2h-app-migrate/references/stage-map.md +50 -0
- package/i18n/skills/a2h-app-migrate/references/workflow.yaml +2007 -0
- package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +187 -0
- package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1656 -0
- package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +728 -0
- package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +541 -0
- package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
- package/i18n/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
- package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
- package/i18n/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
- package/i18n/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
- package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
- package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
- package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
- package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
- package/i18n/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
- package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
- package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
- package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
- package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
- package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
- package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
- package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
- package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
- package/i18n/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
- package/i18n/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
- package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +207 -0
- package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
- package/i18n/skills/a2h-arch-generate/SKILL.md +378 -0
- package/i18n/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
- package/i18n/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
- package/i18n/skills/a2h-arch-generate/references/arkts-mvvm-v2.md +1407 -0
- package/i18n/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
- package/i18n/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
- package/i18n/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
- package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
- package/i18n/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
- package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
- package/i18n/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
- package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +131 -0
- package/i18n/skills/a2h-arch-generate/references/source-baseline.md +93 -0
- package/i18n/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +360 -0
- package/i18n/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +798 -0
- package/i18n/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/generate.mjs +639 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
- package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1261 -0
- package/i18n/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
- package/i18n/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +851 -0
- package/i18n/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +982 -0
- package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +304 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +10 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +249 -0
- package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +344 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +877 -0
- package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
- package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +597 -0
- package/i18n/skills/a2h-batch-ui-align/SKILL.md +372 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +35 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +85 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +23 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +89 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +62 -0
- package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +30 -0
- package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +930 -0
- package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +420 -0
- package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +158 -0
- package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2552 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
- package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +175 -0
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +251 -0
- package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
- package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +232 -0
- package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +206 -0
- package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +232 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +2118 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1805 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1959 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1632 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1300 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1234 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +417 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +216 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +615 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +49 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +780 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +408 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +81 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +147 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +127 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
- package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
- package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +62 -0
- package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
- package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
- package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
- package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
- package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
- package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
- package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2050 -0
- package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
- package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
- package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
- package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
- package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
- package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
- package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
- package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
- package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
- package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
- package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
- package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
- package/i18n/skills/a2h-module-semantic-docs/SKILL.md +265 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
- package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
- package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
- package/i18n/skills/a2h-page-specgen/SKILL.md +239 -0
- package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +1174 -0
- package/i18n/skills/a2h-page-specgen/references/body-language.md +179 -0
- package/i18n/skills/a2h-page-specgen/references/gates.md +329 -0
- package/i18n/skills/a2h-page-specgen/references/page-inventory.md +220 -0
- package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +274 -0
- package/i18n/skills/a2h-page-specgen/references/spec-example.md +312 -0
- package/i18n/skills/a2h-page-specgen/references/spec-template.md +210 -0
- package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
- package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
- package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
- package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
- package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
- package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
- package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
- package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +864 -0
- package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +346 -0
- package/i18n/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +684 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +252 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
- package/i18n/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
- package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
- package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +864 -0
- package/i18n/skills/a2h-page-specgen/scripts/render.mjs +276 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +897 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +25 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +300 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +47 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +300 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +267 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +57 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +373 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +300 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +553 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +546 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +655 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1234 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +520 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1516 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +759 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +630 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +118 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +798 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +886 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1205 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +271 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1121 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +348 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +240 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +427 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +536 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1239 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
- package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
- package/i18n/skills/a2h-resource-convert/SKILL.md +375 -0
- package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +336 -0
- package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +272 -0
- package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +226 -0
- package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
- package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +251 -0
- package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
- package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2596 -0
- package/i18n/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
- package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
- package/i18n/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
- package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +238 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +358 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +307 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +103 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +266 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +71 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +55 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
- package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +246 -0
- package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +752 -0
- package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +661 -0
- package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
- package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
- package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
- package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
- package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
- package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
- package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
- package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
- package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
- package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
- package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
- package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
- package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
- package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
- package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
- package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
- package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
- package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
- package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
- package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
- package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
- package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
- package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
- package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
- package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
- package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
- package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
- package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
- package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
- package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
- package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
- package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
- package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
- package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
- package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
- package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
- package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
- package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
- package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
- package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
- package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
- package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
- package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
- package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
- package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
- package/i18n/skills/a2h-utg-explorer/SKILL.md +126 -0
- package/i18n/skills/a2h-utg-explorer/references/architecture.md +282 -0
- package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +908 -0
- package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
- package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
- package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
- package/i18n/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
- package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +647 -0
- package/i18n/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +252 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
- package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1562 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
- package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2714 -0
- package/i18n/skills/a2h-utg-static/SKILL.md +372 -0
- package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
- package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
- package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2190 -0
- package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
- package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +720 -0
- package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
- package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
- package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
- package/i18n/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
- package/i18n/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
- package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
- package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +705 -0
- package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
- package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +958 -0
- package/i18n/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
- package/i18n/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
- package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +545 -0
- package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
- package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +125 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +113 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +457 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +78 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +330 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
- package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
- package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1394 -0
- package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
- package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
- package/package.json +11 -161
- package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
- package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
- package/skills/a2h-app-migrate/SKILL.md +31 -12
- package/skills/a2h-app-migrate/references/config.example.json +1 -0
- package/skills/a2h-app-migrate/references/feature-scope.md +121 -0
- package/skills/a2h-app-migrate/references/stage-map.md +4 -2
- package/skills/a2h-app-migrate/references/workflow.yaml +427 -103
- package/skills/a2h-app-migrate/scripts/android_index.mjs +35 -8
- package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +39 -1
- package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +78 -6
- package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +144 -9
- package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +14 -1
- package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +46 -5
- package/skills/a2h-app-migrate/scripts/diagnose.mjs +162 -0
- package/skills/a2h-app-migrate/scripts/env_preflight.mjs +178 -44
- package/skills/a2h-app-migrate/scripts/feature_scope.mjs +347 -0
- package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +81 -11
- package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +17 -1
- package/skills/a2h-app-migrate/scripts/ledger.mjs +80 -10
- package/skills/a2h-app-migrate/scripts/migration_manifest.mjs +351 -0
- package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +9 -23
- package/skills/a2h-app-migrate/scripts/resume_plan.mjs +72 -12
- package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +33 -1
- package/skills/a2h-app-migrate/scripts/run_dir.mjs +137 -41
- package/skills/a2h-app-migrate/scripts/scope_model.mjs +255 -0
- package/skills/a2h-app-migrate/scripts/scope_report.mjs +128 -0
- package/skills/a2h-app-migrate/scripts/source_fp.mjs +120 -0
- package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
- package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
- package/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
- package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
- package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
- package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
- package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
- package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
- package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
- package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
- package/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
- package/skills/a2h-app-migrate/test/test_feature_scope.mjs +217 -0
- package/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
- package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
- package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
- package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +51 -0
- package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
- package/skills/a2h-app-migrate/test/test_incremental_acceptance.mjs +145 -0
- package/skills/a2h-app-migrate/test/test_incremental_phase2.mjs +223 -0
- package/skills/a2h-app-migrate/test/test_incremental_phase2_acceptance.mjs +157 -0
- package/skills/a2h-app-migrate/test/test_incremental_profile.mjs +84 -0
- package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +101 -0
- package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
- package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
- package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +150 -0
- package/skills/a2h-app-migrate/test/test_migration_manifest.mjs +225 -0
- package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +86 -0
- package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
- package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
- package/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
- package/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
- package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
- package/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
- package/skills/a2h-app-migrate/test/test_scope_model.mjs +172 -0
- package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
- package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
- package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +155 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
- package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
- package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +511 -0
- package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_capture_audit.mjs +106 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +65 -0
- package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
- package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
- package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
- package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
- package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +214 -0
- package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
- package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
- package/skills/a2h-arch-generate/SKILL.md +20 -17
- package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
- package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
- package/skills/a2h-arch-generate/references/homegraph-workflow.md +25 -14
- package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
- package/skills/a2h-arch-generate/references/source-baseline.md +4 -4
- package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +34 -3
- package/skills/a2h-arch-generate/scripts/create_project.mjs +24 -1
- package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
- package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +29 -5
- package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
- package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
- package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
- package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1260 -0
- package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +208 -0
- package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
- package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
- package/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
- package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +164 -0
- package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
- package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +4 -2
- package/skills/a2h-arkts-logic-coder/SKILL.md +163 -15
- package/skills/a2h-arkts-logic-coder/references/ISSUES.md +3 -1
- package/skills/a2h-arkts-logic-coder/references/code-generation.md +120 -1
- package/skills/a2h-arkts-logic-coder/references/spec-design.md +46 -11
- package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
- package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +873 -0
- package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
- package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
- package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
- package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
- package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
- package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
- package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
- package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
- package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +596 -0
- package/skills/a2h-batch-ui-align/SKILL.md +78 -26
- package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +16 -2
- package/skills/a2h-batch-ui-align/references/cards/alignment.md +5 -1
- package/skills/a2h-batch-ui-align/references/cards/geometry.md +6 -1
- package/skills/a2h-batch-ui-align/references/cards/interaction.md +2 -1
- package/skills/a2h-batch-ui-align/references/cards/resources.md +9 -3
- package/skills/a2h-batch-ui-align/references/cards/widgets.md +27 -3
- package/skills/a2h-batch-ui-align/references/cards/window.md +2 -1
- package/skills/a2h-batch-ui-align/references/checker-rules.md +301 -13
- package/skills/a2h-batch-ui-align/references/conversion-procedure.md +53 -13
- package/skills/a2h-batch-ui-align/references/host-dispatch.md +2 -0
- package/skills/a2h-batch-ui-align/references/incremental-scope.md +28 -9
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +14 -9
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
- package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +28 -1
- package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/243/205/351/245/260/345/231/250/351/200/237/346/237/245.md +30 -0
- package/skills/a2h-batch-ui-align/references/step3-capture.md +25 -6
- package/skills/a2h-batch-ui-align/references/step4-prepare.md +7 -2
- package/skills/a2h-batch-ui-align/references/step5-convert.md +33 -9
- package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
- package/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
- package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +463 -22
- package/skills/a2h-batch-ui-align/scripts/capture_audit.mjs +474 -0
- package/skills/a2h-batch-ui-align/scripts/capture_fast.mjs +665 -0
- package/skills/a2h-batch-ui-align/scripts/capture_verify.mjs +552 -0
- package/skills/a2h-batch-ui-align/scripts/detach.mjs +5 -2
- package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
- package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +263 -0
- package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +20 -3
- package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
- package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +220 -35
- package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +517 -41
- package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
- package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
- package/skills/a2h-batch-ui-align/scripts/list_existing.mjs +141 -0
- package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +239 -14
- package/skills/a2h-batch-ui-align/scripts/page_gap.mjs +210 -0
- package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +98 -11
- package/skills/a2h-batch-ui-align/scripts/progress_identity.mjs +208 -0
- package/skills/a2h-batch-ui-align/scripts/scroll_verdict.mjs +62 -0
- package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +118 -4
- package/skills/a2h-batch-ui-align/scripts/shell_requests.mjs +273 -0
- package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +9 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/baseline.ts +79 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
- package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +90 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +44 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +61 -12
- package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +32 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +3 -17
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +1 -19
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +234 -5
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +110 -12
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +3 -2
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +54 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -23
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +4 -4
- package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
- package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +30 -2
- package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +231 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_baseline.test.mjs +129 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_runtime2.test.mjs +697 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +298 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +269 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +346 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme_runtime.test.mjs +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
- package/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
- package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +291 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_audit.test.mjs +179 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_fast.test.mjs +56 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_gate.test.mjs +197 -0
- package/skills/a2h-batch-ui-align/scripts/tests/capture_review_fixes.test.mjs +322 -0
- package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +93 -0
- package/skills/a2h-batch-ui-align/scripts/tests/detect_paradigm.test.mjs +260 -0
- package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
- package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +435 -0
- package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
- package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/SearchMenuDialog.buggy.ets +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/meta.json +21 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/screenshot.png +0 -0
- package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/view.xml +35 -0
- package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_pack_evidence.test.mjs +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1782 -0
- package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
- package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
- package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
- package/skills/a2h-batch-ui-align/scripts/tests/icon_coverage.test.mjs +314 -0
- package/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
- package/skills/a2h-batch-ui-align/scripts/tests/list_existing.test.mjs +157 -0
- package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
- package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
- package/skills/a2h-batch-ui-align/scripts/tests/page_gap.test.mjs +115 -0
- package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
- package/skills/a2h-batch-ui-align/scripts/tests/progress_identity.test.mjs +174 -0
- package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +302 -0
- package/skills/a2h-batch-ui-align/scripts/tests/shell_requests.test.mjs +158 -0
- package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
- package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
- package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
- package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
- package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
- package/skills/a2h-coldstart-smoke-gate/SKILL.md +7 -4
- package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
- package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
- package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
- package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
- package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
- package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
- package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
- package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
- package/skills/a2h-dashboard-render/test/test_device_locale_dialogs.mjs +17 -0
- package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
- package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
- package/skills/a2h-module-semantic-docs/SKILL.md +51 -13
- package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +66 -11
- package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
- package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
- package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
- package/skills/a2h-module-semantic-docs/test/test_incremental_fingerprint.mjs +94 -0
- package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
- package/skills/a2h-page-specgen/SKILL.md +240 -0
- package/skills/a2h-page-specgen/references/behavior-ledger.md +1170 -0
- package/skills/a2h-page-specgen/references/body-language.md +179 -0
- package/skills/a2h-page-specgen/references/evidence.md +105 -0
- package/skills/a2h-page-specgen/references/execution-model.md +364 -0
- package/skills/a2h-page-specgen/references/footprint-and-grouping.md +255 -0
- package/skills/a2h-page-specgen/references/gates.md +323 -0
- package/skills/a2h-page-specgen/references/page-inventory.md +220 -0
- package/skills/a2h-page-specgen/references/scenario-authoring.md +272 -0
- package/skills/a2h-page-specgen/references/spec-example.md +312 -0
- package/skills/a2h-page-specgen/references/spec-template.md +210 -0
- package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
- package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
- package/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
- package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
- package/skills/a2h-page-specgen/scripts/dispatch.mjs +212 -0
- package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
- package/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
- package/skills/a2h-page-specgen/scripts/finalize.mjs +825 -0
- package/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
- package/skills/a2h-page-specgen/scripts/gate.mjs +848 -0
- package/skills/a2h-page-specgen/scripts/interactions.mjs +344 -0
- package/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
- package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
- package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
- package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +229 -0
- package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
- package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
- package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
- package/skills/a2h-page-specgen/scripts/lib/hg.mjs +683 -0
- package/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
- package/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
- package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +478 -0
- package/skills/a2h-page-specgen/scripts/lib/main-module.mjs +24 -0
- package/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
- package/skills/a2h-page-specgen/scripts/lib/prose.mjs +238 -0
- package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
- package/skills/a2h-page-specgen/scripts/lib/recovery-policy.mjs +28 -0
- package/skills/a2h-page-specgen/scripts/lib/scope.mjs +355 -0
- package/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
- package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
- package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
- package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
- package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
- package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
- package/skills/a2h-page-specgen/scripts/prepare.mjs +840 -0
- package/skills/a2h-page-specgen/scripts/render.mjs +294 -0
- package/skills/a2h-page-specgen/scripts/report.mjs +340 -0
- package/skills/a2h-page-specgen/scripts/submission.mjs +697 -0
- package/skills/a2h-page-specgen/scripts/submit.mjs +85 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +871 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.java +15 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +26 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +298 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.java +36 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +43 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +298 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +265 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.java +47 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +54 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +347 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +298 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +515 -0
- package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
- package/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
- package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +543 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +652 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1231 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +494 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1513 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +758 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +623 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +116 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +795 -0
- package/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +883 -0
- package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
- package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
- package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
- package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1203 -0
- package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +243 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +112 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.java +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.kt +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanelsKotlinForms.kt +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ChildContent.java +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ComposeLifecycle.kt +26 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleCallAndOverride.java +10 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleHooks.kt +31 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyLifecycleHooks.kt +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshOnResume.java +7 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshResultNoise.kt +36 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/SelectionView.java +5 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ShowPage.vue +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/ThirdPartyLifecycle.kt +25 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/src/fragment_detail.xml +1 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
- package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
- package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
- package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
- package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
- package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1078 -0
- package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
- package/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
- package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
- package/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
- package/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
- package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
- package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +310 -0
- package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
- package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
- package/skills/a2h-page-specgen/scripts/test/ledger-lock.test.mjs +77 -0
- package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
- package/skills/a2h-page-specgen/scripts/test/main-module.test.mjs +43 -0
- package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
- package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
- package/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
- package/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
- package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +160 -0
- package/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
- package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +236 -0
- package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +398 -0
- package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
- package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
- package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
- package/skills/a2h-page-specgen/scripts/test/recovery-policy.test.mjs +14 -0
- package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
- package/skills/a2h-page-specgen/scripts/test/render.test.mjs +546 -0
- package/skills/a2h-page-specgen/scripts/test/report.test.mjs +296 -0
- package/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
- package/skills/a2h-page-specgen/scripts/test/scope.test.mjs +292 -0
- package/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
- package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
- package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1231 -0
- package/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
- package/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
- package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
- package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
- package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
- package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1993 -0
- package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +342 -0
- package/skills/a2h-page-specgen/scripts/waker.mjs +1301 -0
- package/skills/a2h-page-specgen/scripts/watchdog.mjs +299 -0
- package/skills/a2h-resource-convert/SKILL.md +9 -1
- package/skills/a2h-resource-convert/references/code-vector-icon-rules.md +2 -1
- package/skills/a2h-resource-convert/references/incremental-page-migration.md +23 -2
- package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +7 -0
- package/skills/a2h-resource-convert/references/step4-resource-types.md +2 -0
- package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +115 -53
- package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +68 -0
- package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +45 -3
- package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +42 -5
- package/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
- package/skills/a2h-resource-convert/scripts/lottie_refs.ts +398 -0
- package/skills/a2h-resource-convert/scripts/merge_mapping.ts +316 -0
- package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +2 -1
- package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
- package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
- package/skills/a2h-resource-convert/scripts/tests/code_vector_guard.test.mjs +75 -0
- package/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
- package/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
- package/skills/a2h-resource-convert/scripts/tests/lottie_incremental.test.mjs +178 -0
- package/skills/a2h-resource-convert/scripts/tests/merge_mapping.test.mjs +201 -0
- package/skills/a2h-spec-design-pipeline/SKILL.md +98 -121
- package/skills/a2h-spec-design-pipeline/references/coding-loop.md +170 -45
- package/skills/a2h-spec-design-pipeline/references/execution-model.md +62 -12
- package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -4
- package/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +229 -0
- package/skills/a2h-spec-design-pipeline/references/initialization.md +49 -6
- package/skills/a2h-spec-design-pipeline/references/merge-queue.md +198 -54
- package/skills/a2h-spec-design-pipeline/references/permission-index.json +206 -0
- package/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
- package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +67 -0
- package/skills/a2h-spec-design-pipeline/references/review-loop.md +46 -0
- package/skills/a2h-spec-design-pipeline/references/scripts.md +47 -14
- package/skills/a2h-spec-design-pipeline/references/shared-layer.md +390 -0
- package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +148 -29
- package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +104 -24
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +18 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +16 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +47 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +31 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +698 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +96 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +103 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +124 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +138 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +106 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +113 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +705 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +1063 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +473 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/platform/ExtraDataSubCheck.js +485 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +13 -0
- package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +18 -0
- package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
- package/skills/a2h-spec-design-pipeline/scripts/check_design_map.ts +108 -0
- package/skills/a2h-spec-design-pipeline/scripts/check_permissions.ts +420 -0
- package/skills/a2h-spec-design-pipeline/scripts/check_review_evidence.ts +45 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +95 -7
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +156 -7
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +71 -0
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +22 -3
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +63 -4
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +33 -3
- package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
- package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +232 -13
- package/skills/a2h-spec-design-pipeline/scripts/ensure_index.ts +866 -0
- package/skills/a2h-spec-design-pipeline/scripts/fixtures/homecheck-stub.cjs +47 -0
- package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +220 -44
- package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
- package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
- package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
- package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +178 -14
- package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
- package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +368 -0
- package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
- package/skills/a2h-spec-design-pipeline/scripts/sync_permission_index.ts +340 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +281 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +690 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_check_design_map.ts +46 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_check_permissions.ts +201 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +42 -8
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +27 -9
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +242 -9
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +192 -7
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +531 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +49 -1
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +92 -4
- package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +51 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index.ts +572 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index_real.ts +56 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +17 -10
- package/skills/a2h-spec-design-pipeline/scripts/test_homegraph_docs.ts +217 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_permission_index.ts +214 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +155 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +308 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +401 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +165 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
- package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
- package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
- package/skills/a2h-spec-generate/SKILL.md +89 -23
- package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
- package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
- package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
- package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
- package/skills/a2h-spec-generate/references/specs.schema.json +24 -11
- package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
- package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
- package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
- package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
- package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
- package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
- package/skills/a2h-spec-generate/scripts/ensure-index.mjs +1 -2
- package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
- package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
- package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
- package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
- package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
- package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
- package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
- package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
- package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
- package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
- package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
- package/skills/a2h-spec-generate/scripts/reqgen/test/zip.test.ts +61 -0
- package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
- package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
- package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
- package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
- package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
- package/skills/a2h-spec-generate/test/ensure-index.test.mjs +229 -0
- package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
- package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
- package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
- package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
- package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
- package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
- package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
- package/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
- package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
- package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
- package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
- package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
- package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
- package/skills/a2h-utg-explorer/SKILL.md +9 -3
- package/skills/a2h-utg-explorer/references/architecture.md +7 -0
- package/skills/a2h-utg-explorer/scripts/audit.mjs +8 -2
- package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +120 -85
- package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +47 -2
- package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
- package/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
- package/skills/a2h-utg-explorer/scripts/plan.mjs +8 -0
- package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
- package/skills/a2h-utg-explorer/scripts/recover_d.mjs +288 -21
- package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
- package/skills/a2h-utg-explorer/scripts/report.mjs +89 -0
- package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +67 -10
- package/skills/a2h-utg-explorer/scripts/run_device.mjs +10 -2
- package/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
- package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
- package/skills/a2h-utg-explorer/scripts/tests/blank_wait.test.mjs +126 -0
- package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
- package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
- package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
- package/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
- package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
- package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +231 -0
- package/skills/a2h-utg-explorer/scripts/tests/default_override.test.mjs +109 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_locale_dialogs.test.mjs +29 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -0
- package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
- package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +254 -0
- package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
- package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +137 -0
- package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
- package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
- package/skills/a2h-utg-explorer/scripts/tests/foreground_spelling.test.mjs +155 -0
- package/skills/a2h-utg-explorer/scripts/tests/fresh_state_plan.test.mjs +78 -0
- package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
- package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
- package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
- package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +120 -0
- package/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
- package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
- package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
- package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -0
- package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
- package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
- package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
- package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
- package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
- package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
- package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +218 -0
- package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +292 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
- package/skills/a2h-utg-explorer/scripts/tests/recover_d_grounding.test.mjs +164 -0
- package/skills/a2h-utg-explorer/scripts/tests/replay_reroute.test.mjs +143 -0
- package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
- package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +458 -0
- package/skills/a2h-utg-explorer/scripts/tests/run_cycle_follow.test.mjs +35 -0
- package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
- package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
- package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
- package/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
- package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
- package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
- package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
- package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
- package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -0
- package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
- package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
- package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
- package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
- package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +135 -7
- package/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +245 -69
- package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +164 -0
- package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +718 -42
- package/skills/a2h-utg-explorer/scripts/variant.mjs +57 -11
- package/skills/a2h-utg-static/SKILL.md +6 -2
- package/skills/a2h-utg-static/scripts/assemble.mjs +93 -3
- package/skills/a2h-utg-static/scripts/click_paths.mjs +135 -25
- package/skills/a2h-utg-static/scripts/compose_body_text.mjs +3 -3
- package/skills/a2h-utg-static/scripts/compose_overlay.mjs +110 -3
- package/skills/a2h-utg-static/scripts/compose_titles.mjs +5 -5
- package/skills/a2h-utg-static/scripts/compose_widgets.mjs +4 -4
- package/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
- package/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
- package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
- package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +46 -1
- package/skills/a2h-utg-static/scripts/label_resolve.mjs +49 -4
- package/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
- package/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
- package/skills/a2h-utg-static/scripts/menu_nav.mjs +1 -1
- package/skills/a2h-utg-static/scripts/nl_hints.mjs +34 -7
- package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
- package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
- package/skills/a2h-utg-static/scripts/run_pipeline.mjs +86 -4
- package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
- package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
- package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +30 -0
- package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +18 -0
- package/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
- package/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +114 -0
- package/skills/a2h-utg-static/scripts/tests/test_guard_kinds_locale.mjs +12 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
- package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +165 -1
- package/skills/a2h-utg-static/scripts/tests/test_library_activity.mjs +45 -0
- package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
- package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +35 -1
- package/skills/a2h-utg-static/scripts/tests/test_nl_hints_default_override.mjs +50 -0
- package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +21 -0
- package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +172 -0
- package/skills/a2h-utg-static/scripts/tests/test_redirect_path_cost.mjs +136 -0
- package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_route_jump.mjs +175 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
- package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +99 -0
- package/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
- package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +21 -0
- package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +112 -69
- package/skills/a2h-utg-static/scripts/vm_nav.mjs +9 -1
- package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
- package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
- package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
- package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +0 -885
- package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +0 -856
- package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
- package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
- package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
- package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
- package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
- package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
|
@@ -0,0 +1,1801 @@
|
|
|
1
|
+
import test from "node:test";
|
|
2
|
+
import assert from "node:assert/strict";
|
|
3
|
+
import crypto from "node:crypto";
|
|
4
|
+
import fs from "node:fs";
|
|
5
|
+
import os from "node:os";
|
|
6
|
+
import path from "node:path";
|
|
7
|
+
import { spawn, spawnSync } from "node:child_process";
|
|
8
|
+
import { fileURLToPath, pathToFileURL } from "node:url";
|
|
9
|
+
import {
|
|
10
|
+
acquireWakerLock,
|
|
11
|
+
renewWakerHeartbeat,
|
|
12
|
+
probeWaker,
|
|
13
|
+
stopWaker,
|
|
14
|
+
rearmWaker,
|
|
15
|
+
runWaker,
|
|
16
|
+
handleWakerEvent,
|
|
17
|
+
writeWakerEvent,
|
|
18
|
+
claimWakerEvent,
|
|
19
|
+
quarantineInvalidEvent,
|
|
20
|
+
} from "../waker.mjs";
|
|
21
|
+
import { readJson, writeJsonAtomic } from "../lib/fsx.mjs";
|
|
22
|
+
import {
|
|
23
|
+
planVersionFor,
|
|
24
|
+
seedV2,
|
|
25
|
+
seededPlan as seededPlanWithRealVersion,
|
|
26
|
+
writePlanFixture,
|
|
27
|
+
} from "./helpers.mjs";
|
|
28
|
+
|
|
29
|
+
// Event fixtures use the same authenticated content version as their seeded plan.
|
|
30
|
+
const PLAN_VERSION = planVersionFor({
|
|
31
|
+
groups: [{ group_id: "g1", kind: "page", pages: ["p1"], spec_ids: ["p1"] }],
|
|
32
|
+
units: [{ spec_id: "p1", page_id: "p1", dir: "g1" }],
|
|
33
|
+
pages: [{ page_id: "p1", label: "Home", out_edges: [], widgets: [], interactions: [] }],
|
|
34
|
+
});
|
|
35
|
+
const EMPTY_PLAN_VERSION = planVersionFor({ groups: [], units: [], pages: [] });
|
|
36
|
+
const seededPlan = seededPlanWithRealVersion;
|
|
37
|
+
|
|
38
|
+
const cliPath = fileURLToPath(new URL("../waker.mjs", import.meta.url));
|
|
39
|
+
const moduleUrl = pathToFileURL(cliPath).href;
|
|
40
|
+
const running = () => ({
|
|
41
|
+
status: "running", live: [], claimed: [], orphaned: [], to_dispatch: ["g1"],
|
|
42
|
+
partial: [], overdue: [], abandoned: [], recovery_results: [], slots: 7, nextDeadline: null,
|
|
43
|
+
});
|
|
44
|
+
const complete = () => ({ ...running(), status: "complete", to_dispatch: [], slots: 8 });
|
|
45
|
+
|
|
46
|
+
function seedAt(outDir, specIds = ["p1"]) {
|
|
47
|
+
const groups = specIds.length === 0 ? [] : [{
|
|
48
|
+
group_id: "g1", kind: "page", pages: specIds, spec_ids: specIds,
|
|
49
|
+
}];
|
|
50
|
+
const units = specIds.map(specId => ({ spec_id: specId, page_id: specId, dir: "g1" }));
|
|
51
|
+
const pages = specIds.map(pageId => ({
|
|
52
|
+
page_id: pageId, label: "Home", out_edges: [], widgets: [], interactions: [],
|
|
53
|
+
}));
|
|
54
|
+
seedV2(outDir, groups);
|
|
55
|
+
writePlanFixture(outDir, { groups, units, pages });
|
|
56
|
+
return outDir;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
function seedSpacedOutput(specIds = ["p1"], t = null) {
|
|
60
|
+
const outDir = fs.mkdtempSync(path.join(os.tmpdir(), "waker spaced café "));
|
|
61
|
+
t?.after(() => fs.rmSync(outDir, { recursive: true, force: true }));
|
|
62
|
+
return seedAt(outDir, specIds);
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
function writeState(outDir, revision) {
|
|
66
|
+
writeJsonAtomic(path.join(outDir, "state.json"), { revision });
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
function pendingEventDirectory(outDir) {
|
|
70
|
+
return path.join(outDir, "waker.events", "pending");
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
function pendingEvents(outDir) {
|
|
74
|
+
const directory = pendingEventDirectory(outDir);
|
|
75
|
+
if (!fs.existsSync(directory)) return [];
|
|
76
|
+
return fs.readdirSync(directory)
|
|
77
|
+
.filter(name => !name.startsWith(".") && name.endsWith(".json"))
|
|
78
|
+
.sort()
|
|
79
|
+
.map(name => readJson(path.join(directory, name)));
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
function onlyPendingEvent(outDir) {
|
|
83
|
+
const events = pendingEvents(outDir);
|
|
84
|
+
assert.equal(events.length, 1, "exactly one visible pending event");
|
|
85
|
+
return events[0];
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function activeEventFiles(outDir) {
|
|
89
|
+
return fs.readdirSync(outDir).filter(name =>
|
|
90
|
+
name.startsWith("waker.claiming.") || name.startsWith("waker.consuming.") ||
|
|
91
|
+
name.startsWith("waker.quarantining."));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
function assertNoEventMutexArtifacts(outDir) {
|
|
95
|
+
const forbidden = fs.readdirSync(outDir).filter(name => name.startsWith("waker.event.json.lock"));
|
|
96
|
+
assert.deepEqual(forbidden, [], "no event mutex, reaper, or reclaim guard may be created");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
function assertQueueEmpty(outDir) {
|
|
100
|
+
assert.deepEqual(pendingEvents(outDir), []);
|
|
101
|
+
assert.deepEqual(activeEventFiles(outDir), []);
|
|
102
|
+
assertNoEventMutexArtifacts(outDir);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function replaceLock(outDir, replacementNonce = "replacement-owner") {
|
|
106
|
+
const lockPath = path.join(outDir, "waker.lock");
|
|
107
|
+
const old = readJson(lockPath);
|
|
108
|
+
fs.renameSync(lockPath, path.join(outDir, `waker.lock.stale.${old.nonce}`));
|
|
109
|
+
const fd = fs.openSync(lockPath, "wx");
|
|
110
|
+
try {
|
|
111
|
+
fs.writeSync(fd, `${JSON.stringify({
|
|
112
|
+
pid: process.pid, host: os.hostname(), nonce: replacementNonce,
|
|
113
|
+
startedAt: new Date().toISOString(), plan_version: PLAN_VERSION,
|
|
114
|
+
})}\n`);
|
|
115
|
+
fs.fsyncSync(fd);
|
|
116
|
+
} finally {
|
|
117
|
+
fs.closeSync(fd);
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
function spawnBounded(t, args, { timeout = 30_000 } = {}) {
|
|
122
|
+
const child = spawn(process.execPath, args, { stdio: ["ignore", "pipe", "pipe"] });
|
|
123
|
+
let stdout = "";
|
|
124
|
+
let stderr = "";
|
|
125
|
+
let timer;
|
|
126
|
+
child.stdout.setEncoding("utf8");
|
|
127
|
+
child.stderr.setEncoding("utf8");
|
|
128
|
+
child.stdout.on("data", chunk => { stdout += chunk; });
|
|
129
|
+
child.stderr.on("data", chunk => { stderr += chunk; });
|
|
130
|
+
const finished = new Promise((resolve, reject) => {
|
|
131
|
+
child.once("error", reject);
|
|
132
|
+
child.once("close", (code, signal) => resolve({ code, signal, stdout, stderr }));
|
|
133
|
+
});
|
|
134
|
+
timer = setTimeout(() => {
|
|
135
|
+
child.kill();
|
|
136
|
+
}, timeout);
|
|
137
|
+
t.after(async () => {
|
|
138
|
+
clearTimeout(timer);
|
|
139
|
+
if (child.exitCode === null && child.signalCode === null) child.kill();
|
|
140
|
+
await finished;
|
|
141
|
+
});
|
|
142
|
+
return finished.then(result => {
|
|
143
|
+
clearTimeout(timer);
|
|
144
|
+
assert.equal(result.signal, null, `${args.join(" ")}\n${result.stderr}`);
|
|
145
|
+
return result;
|
|
146
|
+
});
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
async function waitForFile(file, timeout = 5000) {
|
|
150
|
+
const deadline = Date.now() + timeout;
|
|
151
|
+
while (!fs.existsSync(file)) {
|
|
152
|
+
if (Date.now() >= deadline) throw new Error(`timed out waiting for ${file}`);
|
|
153
|
+
await new Promise(resolve => setTimeout(resolve, 10));
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
test("stale takeover preserves an immutable replacement lock and rejects the old heartbeat", () => {
|
|
158
|
+
const outDir = seededPlan(["p1"]);
|
|
159
|
+
const oldOwner = acquireWakerLock(outDir, { pid: 999999, now: 0, ttl: 1 });
|
|
160
|
+
assert.equal(probeWaker(outDir, { now: 1000, ttl: 100 }).reason, "dead-pid");
|
|
161
|
+
const replacement = acquireWakerLock(outDir, { pid: process.pid, now: 2000, ttl: 100 });
|
|
162
|
+
assert.ok(oldOwner);
|
|
163
|
+
assert.ok(replacement);
|
|
164
|
+
assert.notEqual(oldOwner.nonce, replacement.nonce);
|
|
165
|
+
assert.equal(probeWaker(outDir, { now: 3000, ttl: 100 }).nonce, replacement.nonce);
|
|
166
|
+
assert.ok(fs.existsSync(path.join(outDir, `waker.lock.stale.${oldOwner.nonce}`)));
|
|
167
|
+
|
|
168
|
+
const before = fs.readFileSync(path.join(outDir, "waker.lock"));
|
|
169
|
+
const renewed = renewWakerHeartbeat(outDir, replacement, 3000);
|
|
170
|
+
assert.equal(renewed.active, true);
|
|
171
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, "waker.lock")), before);
|
|
172
|
+
assert.deepEqual(readJson(path.join(outDir, `waker.heartbeat.${replacement.nonce}.json`)), {
|
|
173
|
+
nonce: replacement.nonce,
|
|
174
|
+
renewedAt: new Date(3000).toISOString(),
|
|
175
|
+
});
|
|
176
|
+
assert.equal(renewWakerHeartbeat(outDir, oldOwner, 3001).active, false);
|
|
177
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, "waker.lock")), before);
|
|
178
|
+
});
|
|
179
|
+
|
|
180
|
+
test("a dead process's interrupted takeover placeholder cannot block stale recovery", () => {
|
|
181
|
+
const outDir = seededPlan(["p1"]);
|
|
182
|
+
const oldOwner = acquireWakerLock(outDir, { pid: 999999, now: 0, ttl: 1 });
|
|
183
|
+
const stalePath = path.join(outDir, `waker.lock.stale.${oldOwner.nonce}`);
|
|
184
|
+
writeJsonAtomic(stalePath, {
|
|
185
|
+
takeover_nonce: "interrupted-owner",
|
|
186
|
+
pid: 999999,
|
|
187
|
+
host: os.hostname(),
|
|
188
|
+
at: new Date(1000).toISOString(),
|
|
189
|
+
});
|
|
190
|
+
const replacement = acquireWakerLock(outDir, { pid: process.pid, now: 2000, ttl: 1 });
|
|
191
|
+
assert.ok(replacement);
|
|
192
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, replacement.nonce);
|
|
193
|
+
assert.equal(readJson(stalePath).nonce, oldOwner.nonce);
|
|
194
|
+
assert.ok(fs.existsSync(`${stalePath}.interrupted.interrupted-owner`));
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test("a live expired owner is stale hard-blocked and cannot be taken over", () => {
|
|
198
|
+
const outDir = seededPlan(["p1"]);
|
|
199
|
+
const owner = acquireWakerLock(outDir, { now: 0, ttl: 1 });
|
|
200
|
+
const before = fs.readFileSync(path.join(outDir, "waker.lock"));
|
|
201
|
+
|
|
202
|
+
const probe = probeWaker(outDir, { now: 2000, ttl: 1 });
|
|
203
|
+
assert.equal(probe.inPlace, false);
|
|
204
|
+
assert.equal(probe.reason, "stale");
|
|
205
|
+
assert.equal(probe.hardBlock, true);
|
|
206
|
+
assert.equal(acquireWakerLock(outDir, { now: 2000, ttl: 1 }), null);
|
|
207
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, "waker.lock")), before);
|
|
208
|
+
assert.equal(fs.existsSync(path.join(outDir, `waker.lock.stale.${owner.nonce}`)), false);
|
|
209
|
+
const blocked = runWaker(outDir, {
|
|
210
|
+
now: 100_000,
|
|
211
|
+
reconcile: () => { throw new Error("stale hard-block must not reconcile"); },
|
|
212
|
+
});
|
|
213
|
+
assert.equal(blocked.code, 5);
|
|
214
|
+
assert.equal(blocked.reason, "stale");
|
|
215
|
+
assert.equal(blocked.probe.hardBlock, true);
|
|
216
|
+
assert.equal(pendingEvents(outDir).length, 0);
|
|
217
|
+
|
|
218
|
+
fs.unlinkSync(path.join(outDir, `waker.heartbeat.${owner.nonce}.json`));
|
|
219
|
+
const missingHeartbeat = probeWaker(outDir, { now: 2001, ttl: 1 });
|
|
220
|
+
assert.equal(missingHeartbeat.reason, "stale");
|
|
221
|
+
assert.equal(missingHeartbeat.hardBlock, true);
|
|
222
|
+
assert.equal(acquireWakerLock(outDir, { now: 2001, ttl: 1 }), null);
|
|
223
|
+
});
|
|
224
|
+
|
|
225
|
+
test("a live plan-mismatched owner is not automatically displaced", () => {
|
|
226
|
+
const outDir = seededPlan(["p1"]);
|
|
227
|
+
const owner = acquireWakerLock(outDir, { now: 0, ttl: 10 });
|
|
228
|
+
const plan = readJson(path.join(outDir, "plan.json"));
|
|
229
|
+
writeJsonAtomic(path.join(outDir, "plan.json"), { ...plan, plan_version: "p-2" });
|
|
230
|
+
const probe = probeWaker(outDir, { now: 1000, ttl: 10 });
|
|
231
|
+
assert.equal(probe.reason, "plan-mismatch");
|
|
232
|
+
assert.equal(probe.hardBlock, true);
|
|
233
|
+
assert.equal(acquireWakerLock(outDir, { now: 1000, ttl: 10 }), null);
|
|
234
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, owner.nonce);
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
test("malformed takeover guards have a bounded initialization grace and become reclaimable", () => {
|
|
238
|
+
const outDir = seededPlan(["p1"]);
|
|
239
|
+
const oldOwner = acquireWakerLock(outDir, { pid: 999999, now: 0, ttl: 1 });
|
|
240
|
+
const stalePath = path.join(outDir, `waker.lock.stale.${oldOwner.nonce}`);
|
|
241
|
+
fs.writeFileSync(stalePath, "{");
|
|
242
|
+
fs.utimesSync(stalePath, new Date(1000), new Date(1000));
|
|
243
|
+
|
|
244
|
+
assert.equal(acquireWakerLock(outDir, { now: 1500, ttl: 1 }), null);
|
|
245
|
+
const replacement = acquireWakerLock(outDir, { now: 4000, ttl: 1 });
|
|
246
|
+
assert.ok(replacement);
|
|
247
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, replacement.nonce);
|
|
248
|
+
assert.ok(fs.readdirSync(outDir).some(name => name.startsWith(`waker.lock.stale.${oldOwner.nonce}.interrupted.malformed.`)));
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
test("a timed-out takeover guard with a live pid is an explicit error, not silent blockage", () => {
|
|
252
|
+
const outDir = seededPlan(["p1"]);
|
|
253
|
+
const oldOwner = acquireWakerLock(outDir, { pid: 999999, now: 0, ttl: 1 });
|
|
254
|
+
const stalePath = path.join(outDir, `waker.lock.stale.${oldOwner.nonce}`);
|
|
255
|
+
writeJsonAtomic(stalePath, {
|
|
256
|
+
takeover_nonce: "stuck-owner",
|
|
257
|
+
pid: process.pid,
|
|
258
|
+
host: os.hostname(),
|
|
259
|
+
at: new Date(1000).toISOString(),
|
|
260
|
+
});
|
|
261
|
+
assert.equal(acquireWakerLock(outDir, { now: 2000, ttl: 1 }), null);
|
|
262
|
+
assert.throws(() => acquireWakerLock(outDir, { now: 5000, ttl: 1 }), error => {
|
|
263
|
+
assert.equal(error.code, "waker-takeover-stalled");
|
|
264
|
+
return true;
|
|
265
|
+
});
|
|
266
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.lock")), true);
|
|
267
|
+
});
|
|
268
|
+
|
|
269
|
+
test("a live owner is exclusive and probe reports dead, expired, plan-mismatched, and stopped owners", () => {
|
|
270
|
+
const outDir = seededPlan(["p1"]);
|
|
271
|
+
const owner = acquireWakerLock(outDir, { now: 1000, ttl: 10 });
|
|
272
|
+
assert.ok(owner);
|
|
273
|
+
assert.equal(acquireWakerLock(outDir, { now: 1001, ttl: 10 }), null);
|
|
274
|
+
assert.equal(probeWaker(outDir, { now: 1001, ttl: 10 }).inPlace, true);
|
|
275
|
+
const plan = readJson(path.join(outDir, "plan.json"));
|
|
276
|
+
writeJsonAtomic(path.join(outDir, "plan.json"), { ...plan, plan_version: "p-2" });
|
|
277
|
+
assert.equal(probeWaker(outDir, { now: 1001, ttl: 10 }).reason, "plan-mismatch");
|
|
278
|
+
writeJsonAtomic(path.join(outDir, "plan.json"), plan);
|
|
279
|
+
fs.unlinkSync(path.join(outDir, `waker.heartbeat.${owner.nonce}.json`));
|
|
280
|
+
assert.equal(probeWaker(outDir, { now: 1001, ttl: 10 }).inPlace, false);
|
|
281
|
+
assert.equal(renewWakerHeartbeat(outDir, owner, 1001).active, true);
|
|
282
|
+
assert.equal(probeWaker(outDir, { now: 11_001, ttl: 10 }).inPlace, false);
|
|
283
|
+
|
|
284
|
+
stopWaker(outDir, PLAN_VERSION, { now: 12_000 });
|
|
285
|
+
assert.equal(probeWaker(outDir, { now: 12_000, ttl: 10 }).reason, "stopped");
|
|
286
|
+
assert.equal(acquireWakerLock(outDir, { now: 12_000, ttl: 10 }), null);
|
|
287
|
+
rearmWaker(outDir, PLAN_VERSION);
|
|
288
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
289
|
+
});
|
|
290
|
+
|
|
291
|
+
test("complete writes a nonce-bearing event and normal exit leaves the lock byte-identical", () => {
|
|
292
|
+
const outDir = seededPlan(["p1"]);
|
|
293
|
+
let lockBytesWhileRunning;
|
|
294
|
+
const result = runWaker(outDir, {
|
|
295
|
+
now: 0,
|
|
296
|
+
reconcile: current => {
|
|
297
|
+
lockBytesWhileRunning = fs.readFileSync(path.join(current, "waker.lock"));
|
|
298
|
+
writeState(current, 1);
|
|
299
|
+
return complete();
|
|
300
|
+
},
|
|
301
|
+
});
|
|
302
|
+
assert.equal(result.code, 0);
|
|
303
|
+
assert.equal(result.event.kind, "complete");
|
|
304
|
+
const owner = readJson(path.join(outDir, "waker.lock"));
|
|
305
|
+
assert.equal(result.event.nonce, owner.nonce);
|
|
306
|
+
assert.ok(lockBytesWhileRunning, "baseline is captured while the waker owns the lock");
|
|
307
|
+
assert.equal(pendingEvents(outDir).length, 1);
|
|
308
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, "waker.lock")), lockBytesWhileRunning);
|
|
309
|
+
});
|
|
310
|
+
|
|
311
|
+
test("a changed file reconciles and exits with the observed event; stale recovery also wakes", () => {
|
|
312
|
+
for (const [kind, staleDrafts] of [["ledger", []], ["drafts", [{ status: "submitted" }]]]) {
|
|
313
|
+
const outDir = seededPlan(["p1"]);
|
|
314
|
+
let calls = 0;
|
|
315
|
+
const result = runWaker(outDir, {
|
|
316
|
+
now: 0,
|
|
317
|
+
waitFn: () => ({ code: 0, event: { kind, detail: "changed" } }),
|
|
318
|
+
reconcile: current => {
|
|
319
|
+
calls += 1;
|
|
320
|
+
writeState(current, calls);
|
|
321
|
+
return { ...running(), recovery_results: calls === 1 ? [] : staleDrafts };
|
|
322
|
+
},
|
|
323
|
+
});
|
|
324
|
+
assert.equal(calls, 2);
|
|
325
|
+
assert.equal(result.code, 0);
|
|
326
|
+
assert.equal(result.event.kind, kind);
|
|
327
|
+
assert.equal(onlyPendingEvent(outDir).nonce, readJson(path.join(outDir, "waker.lock")).nonce);
|
|
328
|
+
}
|
|
329
|
+
});
|
|
330
|
+
|
|
331
|
+
test("startup recovery emits drafts immediately without an empty polling round", () => {
|
|
332
|
+
const outDir = seededPlan(["p1"]);
|
|
333
|
+
let waits = 0;
|
|
334
|
+
const result = runWaker(outDir, {
|
|
335
|
+
now: 0,
|
|
336
|
+
waitFn: () => {
|
|
337
|
+
waits += 1;
|
|
338
|
+
throw new Error("startup recovery must not enter wait");
|
|
339
|
+
},
|
|
340
|
+
reconcile: current => {
|
|
341
|
+
writeState(current, 1);
|
|
342
|
+
return { ...running(), recovery_results: [{ status: "submitted" }] };
|
|
343
|
+
},
|
|
344
|
+
});
|
|
345
|
+
assert.equal(result.code, 0);
|
|
346
|
+
assert.equal(result.event.kind, "drafts");
|
|
347
|
+
assert.equal(waits, 0);
|
|
348
|
+
});
|
|
349
|
+
|
|
350
|
+
test("permanent startup conflicts do not repeatedly emit immediate drafts events", () => {
|
|
351
|
+
const outDir = seededPlan(["p1"]);
|
|
352
|
+
const conflictSnapshot = () => ({
|
|
353
|
+
...running(),
|
|
354
|
+
recovery_results: [{ status: "invalid", reason: "conflict" }],
|
|
355
|
+
});
|
|
356
|
+
const results = [];
|
|
357
|
+
for (let startup = 0; startup < 2; startup += 1) {
|
|
358
|
+
const result = runWaker(outDir, {
|
|
359
|
+
now: startup,
|
|
360
|
+
reconcile: conflictSnapshot,
|
|
361
|
+
waitFn: () => ({ code: 0, event: { kind: "deadline", detail: "later deadline" } }),
|
|
362
|
+
});
|
|
363
|
+
results.push(result);
|
|
364
|
+
const consumed = claimWakerEvent(outDir);
|
|
365
|
+
assert.equal(handleWakerEvent(outDir, consumed, {
|
|
366
|
+
now: startup + 0.5,
|
|
367
|
+
reconcile: conflictSnapshot,
|
|
368
|
+
}).action, "arm");
|
|
369
|
+
const lock = readJson(path.join(outDir, "waker.lock"));
|
|
370
|
+
fs.renameSync(
|
|
371
|
+
path.join(outDir, "waker.lock"),
|
|
372
|
+
path.join(outDir, `waker.lock.stale.${lock.nonce}`),
|
|
373
|
+
);
|
|
374
|
+
fs.unlinkSync(path.join(outDir, `waker.heartbeat.${lock.nonce}.json`));
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
assert.deepEqual(results.map(result => result.event.kind), ["deadline", "deadline"]);
|
|
378
|
+
assert.deepEqual(results.map(result => result.event.detail), ["later deadline", "later deadline"]);
|
|
379
|
+
});
|
|
380
|
+
|
|
381
|
+
test("healthy empty rounds emit only relay at max(600, 2 * interval)", () => {
|
|
382
|
+
const outDir = seededPlan(["p1"]);
|
|
383
|
+
let now = 0;
|
|
384
|
+
let waits = 0;
|
|
385
|
+
const result = runWaker(outDir, {
|
|
386
|
+
interval: 30,
|
|
387
|
+
poll: 1,
|
|
388
|
+
now: () => now,
|
|
389
|
+
waitFn: (_outDir, { maxWait }) => {
|
|
390
|
+
waits += 1;
|
|
391
|
+
now += maxWait * 1000;
|
|
392
|
+
return { code: 5 };
|
|
393
|
+
},
|
|
394
|
+
reconcile: current => {
|
|
395
|
+
writeState(current, 1);
|
|
396
|
+
return running();
|
|
397
|
+
},
|
|
398
|
+
});
|
|
399
|
+
assert.equal(result.code, 0);
|
|
400
|
+
assert.equal(result.event.kind, "relay");
|
|
401
|
+
assert.equal(now, 600_000);
|
|
402
|
+
assert.equal(waits, 20);
|
|
403
|
+
assert.equal(pendingEvents(outDir).length, 1);
|
|
404
|
+
});
|
|
405
|
+
|
|
406
|
+
test("stop exits through the event protocol, blocks automatic arm, and requires manual rearm", () => {
|
|
407
|
+
const outDir = seededPlan(["p1"]);
|
|
408
|
+
stopWaker(outDir, PLAN_VERSION, { now: 0 });
|
|
409
|
+
assert.equal(runWaker(outDir, { now: 0 }).code, 5);
|
|
410
|
+
assert.equal(pendingEvents(outDir).length, 0);
|
|
411
|
+
|
|
412
|
+
rearmWaker(outDir, PLAN_VERSION);
|
|
413
|
+
const result = runWaker(outDir, {
|
|
414
|
+
now: 0,
|
|
415
|
+
waitFn: () => {
|
|
416
|
+
stopWaker(outDir, PLAN_VERSION, { now: 1 });
|
|
417
|
+
return { code: 5 };
|
|
418
|
+
},
|
|
419
|
+
reconcile: current => {
|
|
420
|
+
writeState(current, 1);
|
|
421
|
+
return running();
|
|
422
|
+
},
|
|
423
|
+
});
|
|
424
|
+
assert.equal(result.code, 0);
|
|
425
|
+
assert.equal(result.event.kind, "stop");
|
|
426
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), true);
|
|
427
|
+
assert.equal(runWaker(outDir, { now: 2 }).code, 5);
|
|
428
|
+
});
|
|
429
|
+
|
|
430
|
+
test("a fatal waker error writes error, then handling always archives and hard-blocks", () => {
|
|
431
|
+
const outDir = seededPlan(["p1"]);
|
|
432
|
+
const result = runWaker(outDir, {
|
|
433
|
+
now: 0,
|
|
434
|
+
reconcile: () => { throw new Error("baseline failed"); },
|
|
435
|
+
});
|
|
436
|
+
assert.equal(result.code, 2);
|
|
437
|
+
assert.equal(result.event.kind, "error");
|
|
438
|
+
const consumed = claimWakerEvent(outDir);
|
|
439
|
+
const outcome = handleWakerEvent(outDir, consumed, {
|
|
440
|
+
reconcile: () => { throw new Error("reconcile still failed"); },
|
|
441
|
+
});
|
|
442
|
+
assert.equal(outcome.action, "hard-block");
|
|
443
|
+
assert.equal(fs.existsSync(consumed.path), false);
|
|
444
|
+
assert.ok(fs.existsSync(path.join(outDir, "waker.errors", `${consumed.event.event_id}.json`)));
|
|
445
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), true);
|
|
446
|
+
assert.equal(runWaker(outDir, { interval: 1, poll: 1 }).reason, "stopped");
|
|
447
|
+
rearmWaker(outDir, PLAN_VERSION);
|
|
448
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
449
|
+
|
|
450
|
+
const successful = seededPlan(["p1"]);
|
|
451
|
+
const successfulOwner = acquireWakerLock(successful, { now: 0 });
|
|
452
|
+
writeWakerEvent(successful, {
|
|
453
|
+
kind: "error", planVersion: PLAN_VERSION, detail: "failed", nonce: successfulOwner.nonce,
|
|
454
|
+
});
|
|
455
|
+
const successfulClaim = claimWakerEvent(successful);
|
|
456
|
+
assert.equal(handleWakerEvent(successful, successfulClaim, {
|
|
457
|
+
reconcile: () => running(),
|
|
458
|
+
}).action, "hard-block");
|
|
459
|
+
assert.ok(fs.existsSync(path.join(successful, "waker.errors", `${successfulClaim.event.event_id}.json`)));
|
|
460
|
+
assert.equal(fs.existsSync(path.join(successful, "waker.stop")), true);
|
|
461
|
+
});
|
|
462
|
+
|
|
463
|
+
test("non-error handling deletes consuming only after reconcile and never rearms a stop", () => {
|
|
464
|
+
const armed = seededPlan(["p1"]);
|
|
465
|
+
const armedOwner = acquireWakerLock(armed, { now: 0 });
|
|
466
|
+
writeWakerEvent(armed, { kind: "relay", planVersion: PLAN_VERSION, detail: "E1", nonce: armedOwner.nonce });
|
|
467
|
+
const consumed = claimWakerEvent(armed);
|
|
468
|
+
assert.equal(handleWakerEvent(armed, consumed, { reconcile: () => running() }).action, "arm");
|
|
469
|
+
assert.equal(fs.existsSync(consumed.path), false);
|
|
470
|
+
assert.equal(fs.existsSync(path.join(armed, "waker.stop")), false);
|
|
471
|
+
|
|
472
|
+
const finalized = seededPlan(["p1"]);
|
|
473
|
+
const finalOwner = acquireWakerLock(finalized, { now: 0 });
|
|
474
|
+
writeWakerEvent(finalized, { kind: "complete", planVersion: PLAN_VERSION, detail: "done", nonce: finalOwner.nonce });
|
|
475
|
+
const finalConsumed = claimWakerEvent(finalized);
|
|
476
|
+
assert.equal(handleWakerEvent(finalized, finalConsumed, { reconcile: () => complete() }).action, "finalize-ready");
|
|
477
|
+
assert.equal(fs.existsSync(path.join(finalized, "waker.stop")), true);
|
|
478
|
+
assert.equal(runWaker(finalized, { now: 1 }).reason, "stopped");
|
|
479
|
+
|
|
480
|
+
const newerPending = seededPlan(["p1"]);
|
|
481
|
+
const pendingOwner = acquireWakerLock(newerPending, { now: 0 });
|
|
482
|
+
writeWakerEvent(newerPending, { kind: "relay", planVersion: PLAN_VERSION, detail: "E1", nonce: pendingOwner.nonce });
|
|
483
|
+
const firstConsumed = claimWakerEvent(newerPending);
|
|
484
|
+
const second = writeWakerEvent(newerPending, { kind: "relay", planVersion: PLAN_VERSION, detail: "E2", nonce: pendingOwner.nonce });
|
|
485
|
+
assert.equal(handleWakerEvent(newerPending, firstConsumed, { reconcile: () => running() }).action, "event-pending");
|
|
486
|
+
assert.equal(readJson(path.join(pendingEventDirectory(newerPending), `${second.event_id}.json`)).detail, "E2");
|
|
487
|
+
assert.equal(runWaker(newerPending, { now: 1 }).reason, "event-pending");
|
|
488
|
+
|
|
489
|
+
const failed = seededPlan(["p1"]);
|
|
490
|
+
const failedOwner = acquireWakerLock(failed, { now: 0 });
|
|
491
|
+
writeWakerEvent(failed, { kind: "relay", planVersion: PLAN_VERSION, detail: "retry", nonce: failedOwner.nonce });
|
|
492
|
+
const retained = claimWakerEvent(failed);
|
|
493
|
+
assert.throws(() => handleWakerEvent(failed, retained, {
|
|
494
|
+
reconcile: () => { throw new Error("not yet"); },
|
|
495
|
+
}), /not yet/);
|
|
496
|
+
assert.equal(fs.existsSync(retained.path), true);
|
|
497
|
+
});
|
|
498
|
+
|
|
499
|
+
test("complete fatal race windows use real barriers and finalize-ready drains before finalize", { timeout: 20_000 }, async t => {
|
|
500
|
+
for (const window of ["before-first-check", "between-stop-and-second-check", "after-second-check"]) {
|
|
501
|
+
const outDir = seedSpacedOutput([]);
|
|
502
|
+
const owner = acquireWakerLock(outDir, { now: 0 });
|
|
503
|
+
const completeEvent = writeWakerEvent(outDir, {
|
|
504
|
+
kind: "complete", planVersion: EMPTY_PLAN_VERSION, detail: window, nonce: owner.nonce, now: 0,
|
|
505
|
+
});
|
|
506
|
+
const consumed = claimWakerEvent(outDir);
|
|
507
|
+
const entered = path.join(outDir, `complete ${window} entered`);
|
|
508
|
+
const release = path.join(outDir, `complete ${window} release`);
|
|
509
|
+
const handlerScript = `
|
|
510
|
+
import fs from "node:fs";
|
|
511
|
+
import path from "node:path";
|
|
512
|
+
import { handleWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
513
|
+
const [outDir, consumedJson, window, entered, release] = process.argv.slice(1);
|
|
514
|
+
const consumed = JSON.parse(consumedJson);
|
|
515
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
516
|
+
const barrier = () => {
|
|
517
|
+
fs.writeFileSync(entered, "entered");
|
|
518
|
+
const until = Date.now() + 7000;
|
|
519
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
520
|
+
if (!fs.existsSync(release)) throw new Error("barrier timed out");
|
|
521
|
+
};
|
|
522
|
+
if (window === "between-stop-and-second-check") {
|
|
523
|
+
const originalLinkSync = fs.linkSync;
|
|
524
|
+
fs.linkSync = (from, to) => {
|
|
525
|
+
originalLinkSync(from, to);
|
|
526
|
+
if (path.resolve(to) === path.resolve(outDir, "waker.stop")) barrier();
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
if (window === "after-second-check") {
|
|
530
|
+
const originalRenameSync = fs.renameSync;
|
|
531
|
+
fs.renameSync = (from, to) => {
|
|
532
|
+
if (path.resolve(from) === path.resolve(consumed.path) &&
|
|
533
|
+
path.resolve(path.dirname(to)) === path.resolve(path.join(outDir, "waker.duplicates", "verified"))) barrier();
|
|
534
|
+
return originalRenameSync(from, to);
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
const result = handleWakerEvent(outDir, consumed, {
|
|
538
|
+
now: 1,
|
|
539
|
+
reconcile: () => {
|
|
540
|
+
if (window === "before-first-check") barrier();
|
|
541
|
+
return { status: "complete", recovery_results: [] };
|
|
542
|
+
},
|
|
543
|
+
});
|
|
544
|
+
process.stdout.write(JSON.stringify(result));
|
|
545
|
+
`;
|
|
546
|
+
const handler = spawnBounded(t, [
|
|
547
|
+
"--input-type=module", "-e", handlerScript,
|
|
548
|
+
outDir, JSON.stringify(consumed), window, entered, release,
|
|
549
|
+
]);
|
|
550
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(release)) fs.writeFileSync(release, "cleanup"); });
|
|
551
|
+
await waitForFile(entered);
|
|
552
|
+
const fatal = writeWakerEvent(outDir, {
|
|
553
|
+
kind: "error", planVersion: EMPTY_PLAN_VERSION, detail: `fatal ${window}`, nonce: null, now: 2,
|
|
554
|
+
});
|
|
555
|
+
fs.writeFileSync(release, "go");
|
|
556
|
+
const handlerResult = await handler;
|
|
557
|
+
assert.equal(handlerResult.code, 0, handlerResult.stderr);
|
|
558
|
+
const outcome = JSON.parse(handlerResult.stdout);
|
|
559
|
+
const fatalPath = path.join(pendingEventDirectory(outDir), `${fatal.event_id}.json`);
|
|
560
|
+
|
|
561
|
+
if (window === "after-second-check") {
|
|
562
|
+
assert.equal(outcome.action, "finalize-ready", window);
|
|
563
|
+
assert.equal(fs.existsSync(consumed.path), false, window);
|
|
564
|
+
assert.equal(readJson(path.join(outDir, "waker.stop")).reason, "complete", window);
|
|
565
|
+
} else {
|
|
566
|
+
assert.equal(outcome.action, "event-pending", window);
|
|
567
|
+
assert.equal(fs.existsSync(consumed.path), true, window);
|
|
568
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), window !== "before-first-check", window);
|
|
569
|
+
if (window === "between-stop-and-second-check") {
|
|
570
|
+
assert.deepEqual(readJson(path.join(outDir, "waker.stop")), {
|
|
571
|
+
plan_version: EMPTY_PLAN_VERSION,
|
|
572
|
+
at: new Date(1).toISOString(),
|
|
573
|
+
reason: "complete",
|
|
574
|
+
event_id: completeEvent.event_id,
|
|
575
|
+
});
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
assert.deepEqual(readJson(fatalPath), fatal, `${window}: fatal evidence must remain intact`);
|
|
579
|
+
|
|
580
|
+
// The orchestrator must drain before actual finalize. A hard-block cancels finalize.
|
|
581
|
+
const next = claimWakerEvent(outDir);
|
|
582
|
+
assert.equal(next.event.event_id, fatal.event_id, window);
|
|
583
|
+
const drained = handleWakerEvent(outDir, next, {
|
|
584
|
+
now: 3,
|
|
585
|
+
reconcile: () => ({ status: "running", recovery_results: [] }),
|
|
586
|
+
});
|
|
587
|
+
assert.equal(drained.action, "hard-block", window);
|
|
588
|
+
assert.equal(readJson(path.join(outDir, "waker.stop")).reason, "error", window);
|
|
589
|
+
assert.equal(readJson(path.join(outDir, "waker.stop")).event_id, fatal.event_id, window);
|
|
590
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.errors", `${fatal.event_id}.json`)), true, window);
|
|
591
|
+
assert.equal(claimWakerEvent(outDir), null, `${window}: ordinary complete stays frozen after fatal drain`);
|
|
592
|
+
}
|
|
593
|
+
});
|
|
594
|
+
|
|
595
|
+
test("stale owner and plan events are quarantined before reconcile, stop, finalize, or arm", () => {
|
|
596
|
+
for (const mismatch of ["nonce", "plan"]) {
|
|
597
|
+
const outDir = seededPlan(["p1"]);
|
|
598
|
+
const currentOwner = acquireWakerLock(outDir, { now: 0 });
|
|
599
|
+
writeWakerEvent(outDir, {
|
|
600
|
+
kind: "error",
|
|
601
|
+
planVersion: mismatch === "plan" ? "p-old" : PLAN_VERSION,
|
|
602
|
+
detail: "retired owner error",
|
|
603
|
+
nonce: mismatch === "nonce" ? "retired-owner" : currentOwner.nonce,
|
|
604
|
+
});
|
|
605
|
+
const consumed = claimWakerEvent(outDir);
|
|
606
|
+
let reconciles = 0;
|
|
607
|
+
const outcome = handleWakerEvent(outDir, consumed, {
|
|
608
|
+
reconcile: () => {
|
|
609
|
+
reconciles += 1;
|
|
610
|
+
return complete();
|
|
611
|
+
},
|
|
612
|
+
});
|
|
613
|
+
assert.equal(outcome.action, "ignore");
|
|
614
|
+
assert.equal(outcome.reason, "stale");
|
|
615
|
+
assert.equal(reconciles, 0);
|
|
616
|
+
assert.equal(fs.existsSync(consumed.path), false);
|
|
617
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
618
|
+
const evidence = path.join(outDir, "waker.stale", `${consumed.event.event_id}.json`);
|
|
619
|
+
assert.equal(fs.existsSync(evidence), true);
|
|
620
|
+
assert.equal(readJson(evidence).event_id, consumed.event.event_id);
|
|
621
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, currentOwner.nonce);
|
|
622
|
+
}
|
|
623
|
+
});
|
|
624
|
+
|
|
625
|
+
test("an event invalidated during reconcile cannot stop or arm its successor", () => {
|
|
626
|
+
const outDir = seededPlan(["p1"]);
|
|
627
|
+
const retired = acquireWakerLock(outDir, { now: 0 });
|
|
628
|
+
writeWakerEvent(outDir, {
|
|
629
|
+
kind: "error", planVersion: PLAN_VERSION, detail: "late failure", nonce: retired.nonce,
|
|
630
|
+
});
|
|
631
|
+
const consumed = claimWakerEvent(outDir);
|
|
632
|
+
const outcome = handleWakerEvent(outDir, consumed, {
|
|
633
|
+
reconcile: () => {
|
|
634
|
+
replaceLock(outDir, "successor-owner");
|
|
635
|
+
return running();
|
|
636
|
+
},
|
|
637
|
+
});
|
|
638
|
+
assert.equal(outcome.action, "ignore");
|
|
639
|
+
assert.equal(outcome.reason, "stale");
|
|
640
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
641
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, "successor-owner");
|
|
642
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stale", `${consumed.event.event_id}.json`)), true);
|
|
643
|
+
});
|
|
644
|
+
|
|
645
|
+
test("a dispossessed waker silently skips post-wait reconcile and event production", () => {
|
|
646
|
+
const outDir = seededPlan(["p1"]);
|
|
647
|
+
let reconciles = 0;
|
|
648
|
+
const result = runWaker(outDir, {
|
|
649
|
+
now: 0,
|
|
650
|
+
reconcile: current => {
|
|
651
|
+
reconciles += 1;
|
|
652
|
+
writeState(current, reconciles);
|
|
653
|
+
return running();
|
|
654
|
+
},
|
|
655
|
+
waitFn: () => {
|
|
656
|
+
replaceLock(outDir);
|
|
657
|
+
return { code: 0, event: { kind: "ledger", detail: "must not be emitted" } };
|
|
658
|
+
},
|
|
659
|
+
});
|
|
660
|
+
assert.equal(result.code, 5);
|
|
661
|
+
assert.equal(result.reason, "lock-lost");
|
|
662
|
+
assert.equal(reconciles, 1, "only startup reconcile ran before ownership was lost");
|
|
663
|
+
assert.equal(pendingEvents(outDir).length, 0);
|
|
664
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, "replacement-owner");
|
|
665
|
+
});
|
|
666
|
+
|
|
667
|
+
test("a live stale waker cannot be replaced between ownership check and reconcile or emit", { timeout: 15_000 }, async t => {
|
|
668
|
+
const outDir = seedSpacedOutput();
|
|
669
|
+
const entered = path.join(outDir, "reconcile entered");
|
|
670
|
+
const release = path.join(outDir, "release reconcile");
|
|
671
|
+
const script = `
|
|
672
|
+
import fs from "node:fs";
|
|
673
|
+
import { runWaker } from ${JSON.stringify(moduleUrl)};
|
|
674
|
+
const [outDir, entered, release] = process.argv.slice(1);
|
|
675
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
676
|
+
const result = runWaker(outDir, {
|
|
677
|
+
interval: 0.05,
|
|
678
|
+
poll: 0.01,
|
|
679
|
+
reconcile: () => {
|
|
680
|
+
fs.writeFileSync(entered, "entered");
|
|
681
|
+
const until = Date.now() + 6000;
|
|
682
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
683
|
+
return { status: "complete", recovery_results: [] };
|
|
684
|
+
},
|
|
685
|
+
});
|
|
686
|
+
process.stdout.write(JSON.stringify(result));
|
|
687
|
+
`;
|
|
688
|
+
const child = spawnBounded(t, ["--input-type=module", "-e", script, outDir, entered, release]);
|
|
689
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(release)) fs.writeFileSync(release, "cleanup"); });
|
|
690
|
+
await waitForFile(entered);
|
|
691
|
+
const retired = readJson(path.join(outDir, "waker.lock"));
|
|
692
|
+
const before = fs.readFileSync(path.join(outDir, "waker.lock"));
|
|
693
|
+
const attempted = acquireWakerLock(outDir, { now: Date.now() + 120_000, ttl: 1 });
|
|
694
|
+
const probe = probeWaker(outDir, { now: Date.now() + 120_000, ttl: 1 });
|
|
695
|
+
fs.writeFileSync(release, "go");
|
|
696
|
+
const first = await child;
|
|
697
|
+
|
|
698
|
+
assert.equal(attempted, null);
|
|
699
|
+
assert.equal(probe.reason, "stale");
|
|
700
|
+
assert.equal(probe.hardBlock, true);
|
|
701
|
+
assert.equal(first.code, 0, first.stderr);
|
|
702
|
+
assert.equal(JSON.parse(first.stdout).event.kind, "complete");
|
|
703
|
+
assert.equal(onlyPendingEvent(outDir).nonce, retired.nonce);
|
|
704
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, "waker.lock")), before);
|
|
705
|
+
|
|
706
|
+
const consumed = claimWakerEvent(outDir);
|
|
707
|
+
assert.equal(handleWakerEvent(outDir, consumed, { reconcile: () => complete() }).action, "finalize-ready");
|
|
708
|
+
rearmWaker(outDir, PLAN_VERSION);
|
|
709
|
+
const replacement = acquireWakerLock(outDir, { now: Date.now(), ttl: 1 });
|
|
710
|
+
assert.ok(replacement, "the retired pid can be taken over after child close");
|
|
711
|
+
assert.notEqual(replacement.nonce, retired.nonce);
|
|
712
|
+
});
|
|
713
|
+
|
|
714
|
+
test("a real relay immediately rearmed waits for the old process to close", { timeout: 15_000 }, async t => {
|
|
715
|
+
const outDir = seedSpacedOutput();
|
|
716
|
+
const emitted = path.join(outDir, "relay emitted");
|
|
717
|
+
const release = path.join(outDir, "release relay");
|
|
718
|
+
const attempting = path.join(outDir, "arm attempting");
|
|
719
|
+
const firstScript = `
|
|
720
|
+
import fs from "node:fs";
|
|
721
|
+
import { runWaker } from ${JSON.stringify(moduleUrl)};
|
|
722
|
+
const [outDir, emitted, release] = process.argv.slice(1);
|
|
723
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
724
|
+
let now = Date.now();
|
|
725
|
+
const snapshot = { status: "running", recovery_results: [], nextDeadline: null };
|
|
726
|
+
const result = runWaker(outDir, {
|
|
727
|
+
interval: 30,
|
|
728
|
+
poll: 1,
|
|
729
|
+
now: () => now,
|
|
730
|
+
reconcile: () => snapshot,
|
|
731
|
+
waitFn: (_outDir, { maxWait }) => {
|
|
732
|
+
now += maxWait * 1000;
|
|
733
|
+
return { code: 5 };
|
|
734
|
+
},
|
|
735
|
+
});
|
|
736
|
+
fs.writeFileSync(emitted, JSON.stringify(result));
|
|
737
|
+
const until = Date.now() + 6000;
|
|
738
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
739
|
+
process.stdout.write(JSON.stringify(result));
|
|
740
|
+
`;
|
|
741
|
+
const first = spawnBounded(t, ["--input-type=module", "-e", firstScript, outDir, emitted, release]);
|
|
742
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(release)) fs.writeFileSync(release, "cleanup"); });
|
|
743
|
+
await waitForFile(emitted);
|
|
744
|
+
const retired = readJson(path.join(outDir, "waker.lock"));
|
|
745
|
+
assert.equal(onlyPendingEvent(outDir).kind, "relay");
|
|
746
|
+
const consumed = claimWakerEvent(outDir);
|
|
747
|
+
assert.equal(handleWakerEvent(outDir, consumed, { reconcile: () => running() }).action, "arm");
|
|
748
|
+
|
|
749
|
+
const secondScript = `
|
|
750
|
+
import fs from "node:fs";
|
|
751
|
+
import { runWaker } from ${JSON.stringify(moduleUrl)};
|
|
752
|
+
const [outDir, attempting] = process.argv.slice(1);
|
|
753
|
+
fs.writeFileSync(attempting, "attempting");
|
|
754
|
+
const result = runWaker(outDir, {
|
|
755
|
+
interval: 0.05,
|
|
756
|
+
poll: 0.01,
|
|
757
|
+
reconcile: () => ({ status: "complete", recovery_results: [] }),
|
|
758
|
+
});
|
|
759
|
+
process.stdout.write(JSON.stringify(result));
|
|
760
|
+
`;
|
|
761
|
+
const second = spawnBounded(t, ["--input-type=module", "-e", secondScript, outDir, attempting]);
|
|
762
|
+
await waitForFile(attempting);
|
|
763
|
+
await new Promise(resolve => setTimeout(resolve, 150));
|
|
764
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, retired.nonce);
|
|
765
|
+
fs.writeFileSync(release, "go");
|
|
766
|
+
const [firstResult, secondResult] = await Promise.all([first, second]);
|
|
767
|
+
assert.equal(firstResult.code, 0, firstResult.stderr);
|
|
768
|
+
assert.equal(JSON.parse(firstResult.stdout).event.kind, "relay");
|
|
769
|
+
assert.equal(secondResult.code, 0, secondResult.stderr);
|
|
770
|
+
const successor = JSON.parse(secondResult.stdout);
|
|
771
|
+
assert.equal(successor.code, 0, successor.reason);
|
|
772
|
+
assert.equal(successor.event.kind, "complete");
|
|
773
|
+
const current = readJson(path.join(outDir, "waker.lock"));
|
|
774
|
+
assert.notEqual(current.nonce, retired.nonce);
|
|
775
|
+
assert.equal(successor.event.nonce, current.nonce);
|
|
776
|
+
});
|
|
777
|
+
|
|
778
|
+
test("two real processes racing to take a stale lock produce exactly one owner", { timeout: 15_000 }, async t => {
|
|
779
|
+
const outDir = seedSpacedOutput();
|
|
780
|
+
const stale = acquireWakerLock(outDir, { pid: 999999, now: 0, ttl: 1 });
|
|
781
|
+
assert.ok(stale);
|
|
782
|
+
const startFile = path.join(outDir, "start race");
|
|
783
|
+
const script = `
|
|
784
|
+
import fs from "node:fs";
|
|
785
|
+
import { acquireWakerLock } from ${JSON.stringify(moduleUrl)};
|
|
786
|
+
const [outDir, startFile] = process.argv.slice(1);
|
|
787
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
788
|
+
const until = Date.now() + 5000;
|
|
789
|
+
while (!fs.existsSync(startFile) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
790
|
+
const owner = acquireWakerLock(outDir, { now: Date.now(), ttl: 1 });
|
|
791
|
+
if (owner) Atomics.wait(cell, 0, 0, 1000);
|
|
792
|
+
process.stdout.write(JSON.stringify(owner));
|
|
793
|
+
`;
|
|
794
|
+
const args = ["--input-type=module", "-e", script, outDir, startFile];
|
|
795
|
+
const first = spawnBounded(t, args);
|
|
796
|
+
const second = spawnBounded(t, args);
|
|
797
|
+
fs.writeFileSync(startFile, "go");
|
|
798
|
+
const results = await Promise.all([first, second]);
|
|
799
|
+
for (const result of results) assert.equal(result.code, 0, result.stderr);
|
|
800
|
+
const owners = results.map(result => JSON.parse(result.stdout)).filter(Boolean);
|
|
801
|
+
assert.equal(owners.length, 1);
|
|
802
|
+
const current = readJson(path.join(outDir, "waker.lock"));
|
|
803
|
+
assert.equal(current.nonce, owners[0].nonce);
|
|
804
|
+
assert.equal(probeWaker(outDir, { ttl: 1 }).nonce, current.nonce);
|
|
805
|
+
});
|
|
806
|
+
|
|
807
|
+
test("a later process takes over the immutable lock retained by a normally exited process", { timeout: 15_000 }, async t => {
|
|
808
|
+
const outDir = seedSpacedOutput([]);
|
|
809
|
+
const first = await spawnBounded(t, [cliPath, outDir, "waker", "--interval", "0.05", "--poll", "0.01"]);
|
|
810
|
+
assert.equal(first.code, 0, first.stderr);
|
|
811
|
+
const retired = readJson(path.join(outDir, "waker.lock"));
|
|
812
|
+
const consumed = claimWakerEvent(outDir);
|
|
813
|
+
assert.equal(handleWakerEvent(outDir, consumed, { reconcile: () => complete() }).action, "finalize-ready");
|
|
814
|
+
rearmWaker(outDir, EMPTY_PLAN_VERSION);
|
|
815
|
+
const second = await spawnBounded(t, [cliPath, outDir, "waker", "--interval", "0.05", "--poll", "0.01"]);
|
|
816
|
+
assert.equal(second.code, 0, second.stderr);
|
|
817
|
+
const current = readJson(path.join(outDir, "waker.lock"));
|
|
818
|
+
assert.notEqual(current.nonce, retired.nonce);
|
|
819
|
+
assert.ok(fs.existsSync(path.join(outDir, `waker.lock.stale.${retired.nonce}`)));
|
|
820
|
+
});
|
|
821
|
+
|
|
822
|
+
test("real waker CLI exits on complete, change, error, and stop in a spaced non-ASCII path", { timeout: 30_000 }, async t => {
|
|
823
|
+
const completed = seedSpacedOutput([]);
|
|
824
|
+
const completeRun = await spawnBounded(t, [cliPath, completed, "waker", "--interval", "0.05", "--poll", "0.01"]);
|
|
825
|
+
assert.equal(completeRun.code, 0, completeRun.stderr);
|
|
826
|
+
assert.equal(onlyPendingEvent(completed).kind, "complete");
|
|
827
|
+
assert.equal(fs.existsSync(path.join(completed, "waker.lock")), true, "normal exit retains the lock");
|
|
828
|
+
|
|
829
|
+
const changed = seedSpacedOutput();
|
|
830
|
+
const changePromise = spawnBounded(t, [cliPath, changed, "waker", "--interval", "0.05", "--poll", "0.01"]);
|
|
831
|
+
await waitForFile(path.join(changed, "wait.baseline.json"));
|
|
832
|
+
writeJsonAtomic(path.join(changed, "drafts", "attempt-1", "p1.json"), { spec_id: "p1" });
|
|
833
|
+
const changeRun = await changePromise;
|
|
834
|
+
assert.equal(changeRun.code, 0, changeRun.stderr);
|
|
835
|
+
assert.equal(onlyPendingEvent(changed).kind, "drafts");
|
|
836
|
+
|
|
837
|
+
const failed = seedSpacedOutput();
|
|
838
|
+
fs.appendFileSync(path.join(failed, "ledger.jsonl"), "{broken\n");
|
|
839
|
+
const errorRun = await spawnBounded(t, [cliPath, failed, "waker", "--interval", "0.05", "--poll", "0.01"]);
|
|
840
|
+
assert.equal(errorRun.code, 2, errorRun.stderr);
|
|
841
|
+
assert.equal(onlyPendingEvent(failed).kind, "error");
|
|
842
|
+
|
|
843
|
+
const stopped = seedSpacedOutput();
|
|
844
|
+
const stopPromise = spawnBounded(t, [cliPath, stopped, "waker", "--interval", "0.05", "--poll", "0.01"]);
|
|
845
|
+
await waitForFile(path.join(stopped, "wait.baseline.json"));
|
|
846
|
+
const stopCommand = spawnSync(process.execPath, [cliPath, stopped, "stop"], { encoding: "utf8", timeout: 5000 });
|
|
847
|
+
assert.equal(stopCommand.status, 0, stopCommand.stderr);
|
|
848
|
+
const stopRun = await stopPromise;
|
|
849
|
+
assert.equal(stopRun.code, 0, stopRun.stderr);
|
|
850
|
+
assert.equal(onlyPendingEvent(stopped).kind, "stop");
|
|
851
|
+
const blocked = spawnSync(process.execPath, [cliPath, stopped, "waker", "--interval", "0.01", "--poll", "0.01"], { encoding: "utf8", timeout: 5000 });
|
|
852
|
+
assert.equal(blocked.status, 5, blocked.stderr);
|
|
853
|
+
const rearmed = spawnSync(process.execPath, [cliPath, stopped, "rearm"], { encoding: "utf8", timeout: 5000 });
|
|
854
|
+
assert.equal(rearmed.status, 0, rearmed.stderr);
|
|
855
|
+
assert.equal(fs.existsSync(path.join(stopped, "waker.stop")), false);
|
|
856
|
+
const probe = spawnSync(process.execPath, [cliPath, stopped, "probe"], { encoding: "utf8", timeout: 5000 });
|
|
857
|
+
assert.equal(probe.status, 0, probe.stderr);
|
|
858
|
+
assert.equal(typeof JSON.parse(probe.stdout).inPlace, "boolean");
|
|
859
|
+
});
|
|
860
|
+
|
|
861
|
+
test("a real event producer cannot be deleted by an older consuming process", { timeout: 10_000 }, async t => {
|
|
862
|
+
const outDir = seedSpacedOutput();
|
|
863
|
+
writeWakerEvent(outDir, { kind: "relay", planVersion: PLAN_VERSION, detail: "E1", nonce: "owner-1" });
|
|
864
|
+
const consumed = claimWakerEvent(outDir);
|
|
865
|
+
const script = `
|
|
866
|
+
import { writeWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
867
|
+
writeWakerEvent(process.argv[1], { kind: "complete", planVersion: ${JSON.stringify(PLAN_VERSION)}, detail: "E2", nonce: "owner-2" });
|
|
868
|
+
`;
|
|
869
|
+
const produced = await spawnBounded(t, ["--input-type=module", "-e", script, outDir]);
|
|
870
|
+
assert.equal(produced.code, 0, produced.stderr);
|
|
871
|
+
fs.unlinkSync(consumed.path);
|
|
872
|
+
const newer = onlyPendingEvent(outDir);
|
|
873
|
+
assert.equal(newer.detail, "E2");
|
|
874
|
+
assert.equal(newer.nonce, "owner-2");
|
|
875
|
+
});
|
|
876
|
+
|
|
877
|
+
test("a live creator's malformed lock is hard-blocked during and after initialization grace", { timeout: 15_000 }, async t => {
|
|
878
|
+
const outDir = seedSpacedOutput();
|
|
879
|
+
const created = path.join(outDir, "malformed lock created");
|
|
880
|
+
const release = path.join(outDir, "release malformed creator");
|
|
881
|
+
const script = `
|
|
882
|
+
import fs from "node:fs";
|
|
883
|
+
const [outDir, created, release] = process.argv.slice(1);
|
|
884
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
885
|
+
fs.writeFileSync(outDir + "/waker.lock", "{");
|
|
886
|
+
fs.writeFileSync(created, "created");
|
|
887
|
+
const until = Date.now() + 6000;
|
|
888
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
889
|
+
`;
|
|
890
|
+
const creator = spawnBounded(t, ["--input-type=module", "-e", script, outDir, created, release]);
|
|
891
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(release)) fs.writeFileSync(release, "cleanup"); });
|
|
892
|
+
await waitForFile(created);
|
|
893
|
+
|
|
894
|
+
const initializing = probeWaker(outDir);
|
|
895
|
+
assert.equal(initializing.hardBlock, true);
|
|
896
|
+
assert.equal(initializing.reason, "initializing");
|
|
897
|
+
const ancient = new Date(Date.now() - 5000);
|
|
898
|
+
fs.utimesSync(path.join(outDir, "waker.lock"), ancient, ancient);
|
|
899
|
+
const before = fs.readFileSync(path.join(outDir, "waker.lock"));
|
|
900
|
+
const probe = probeWaker(outDir);
|
|
901
|
+
assert.equal(probe.reason, "stale");
|
|
902
|
+
assert.equal(probe.hardBlock, true);
|
|
903
|
+
assert.equal(acquireWakerLock(outDir), null);
|
|
904
|
+
const blocked = runWaker(outDir, {
|
|
905
|
+
reconcile: () => { throw new Error("invalid lock must not reconcile"); },
|
|
906
|
+
});
|
|
907
|
+
assert.equal(blocked.code, 5);
|
|
908
|
+
assert.equal(blocked.reason, "stale");
|
|
909
|
+
assert.equal(blocked.probe.hardBlock, true);
|
|
910
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, "waker.lock")), before);
|
|
911
|
+
|
|
912
|
+
fs.writeFileSync(release, "go");
|
|
913
|
+
const creatorResult = await creator;
|
|
914
|
+
assert.equal(creatorResult.code, 0, creatorResult.stderr);
|
|
915
|
+
assert.equal(probeWaker(outDir).hardBlock, true);
|
|
916
|
+
assert.equal(acquireWakerLock(outDir), null, "creator exit never makes malformed JSON take overable");
|
|
917
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, "waker.lock")), before);
|
|
918
|
+
});
|
|
919
|
+
|
|
920
|
+
test("empty and structurally invalid locks are never treated as corrupt recovery", () => {
|
|
921
|
+
const invalidRecords = [
|
|
922
|
+
"",
|
|
923
|
+
"{}\n",
|
|
924
|
+
"[]\n",
|
|
925
|
+
`${JSON.stringify({ nonce: "missing-pid", startedAt: new Date(0).toISOString() })}\n`,
|
|
926
|
+
];
|
|
927
|
+
for (const bytes of invalidRecords) {
|
|
928
|
+
const outDir = seededPlan(["p1"]);
|
|
929
|
+
const file = path.join(outDir, "waker.lock");
|
|
930
|
+
fs.writeFileSync(file, bytes);
|
|
931
|
+
fs.utimesSync(file, new Date(0), new Date(0));
|
|
932
|
+
const probe = probeWaker(outDir, { now: 5000, ttl: 1 });
|
|
933
|
+
assert.equal(probe.reason, "stale");
|
|
934
|
+
assert.equal(probe.hardBlock, true);
|
|
935
|
+
assert.equal(acquireWakerLock(outDir, { now: 5000, ttl: 1 }), null);
|
|
936
|
+
assert.equal(fs.readFileSync(file, "utf8"), bytes);
|
|
937
|
+
assert.equal(fs.readdirSync(outDir).some(name => name.startsWith("waker.lock.stale.")), false);
|
|
938
|
+
}
|
|
939
|
+
});
|
|
940
|
+
|
|
941
|
+
test("dead-PID takeover requires a matching plan and nonce-owned heartbeat", () => {
|
|
942
|
+
const outDir = seededPlan(["p1"]);
|
|
943
|
+
const retired = acquireWakerLock(outDir, { pid: 999999, now: 0, ttl: 1 });
|
|
944
|
+
const plan = readJson(path.join(outDir, "plan.json"));
|
|
945
|
+
writeJsonAtomic(path.join(outDir, "plan.json"), { ...plan, plan_version: "p-2" });
|
|
946
|
+
const mismatched = probeWaker(outDir, { now: 1000, ttl: 1 });
|
|
947
|
+
assert.equal(mismatched.reason, "plan-mismatch");
|
|
948
|
+
assert.equal(mismatched.hardBlock, true);
|
|
949
|
+
assert.equal(acquireWakerLock(outDir, { now: 1000, ttl: 1 }), null);
|
|
950
|
+
|
|
951
|
+
writeJsonAtomic(path.join(outDir, "plan.json"), plan);
|
|
952
|
+
fs.unlinkSync(path.join(outDir, `waker.heartbeat.${retired.nonce}.json`));
|
|
953
|
+
const unknownHeartbeat = probeWaker(outDir, { now: 1000, ttl: 1 });
|
|
954
|
+
assert.equal(unknownHeartbeat.reason, "stale");
|
|
955
|
+
assert.equal(unknownHeartbeat.hardBlock, true);
|
|
956
|
+
assert.equal(acquireWakerLock(outDir, { now: 1000, ttl: 1 }), null);
|
|
957
|
+
assert.equal(fs.existsSync(path.join(outDir, `waker.lock.stale.${retired.nonce}`)), false);
|
|
958
|
+
|
|
959
|
+
assert.equal(renewWakerHeartbeat(outDir, retired, 1000).active, true);
|
|
960
|
+
assert.equal(probeWaker(outDir, { now: 1000, ttl: 1 }).reason, "dead-pid");
|
|
961
|
+
const replacement = acquireWakerLock(outDir, { now: 1001, ttl: 1 });
|
|
962
|
+
assert.ok(replacement);
|
|
963
|
+
assert.notEqual(replacement.nonce, retired.nonce);
|
|
964
|
+
});
|
|
965
|
+
|
|
966
|
+
test("pending, claiming, consuming, quarantining, and legacy artifacts fence acquisition and automatic arm", () => {
|
|
967
|
+
for (const artifact of [
|
|
968
|
+
path.join("waker.events", "pending", "interrupted.json"),
|
|
969
|
+
"waker.claiming.interrupted.json",
|
|
970
|
+
"waker.consuming.interrupted.json",
|
|
971
|
+
`waker.quarantining.${"a".repeat(64)}.0123456789abcdef.json`,
|
|
972
|
+
"waker.event.json",
|
|
973
|
+
]) {
|
|
974
|
+
const outDir = seededPlan(["p1"]);
|
|
975
|
+
const retired = acquireWakerLock(outDir, { pid: 999999, now: 0, ttl: 1 });
|
|
976
|
+
stopWaker(outDir, PLAN_VERSION, { now: 1 });
|
|
977
|
+
const pending = path.join(outDir, artifact);
|
|
978
|
+
fs.mkdirSync(path.dirname(pending), { recursive: true });
|
|
979
|
+
fs.writeFileSync(pending, "{}\n");
|
|
980
|
+
|
|
981
|
+
const probe = probeWaker(outDir, { now: 1000, ttl: 1 });
|
|
982
|
+
assert.equal(probe.reason, "event-pending", artifact);
|
|
983
|
+
assert.equal(acquireWakerLock(outDir, { now: 1000, ttl: 1 }), null, artifact);
|
|
984
|
+
const armed = runWaker(outDir, {
|
|
985
|
+
now: 1000,
|
|
986
|
+
reconcile: () => { throw new Error("event-pending arm must not reconcile"); },
|
|
987
|
+
});
|
|
988
|
+
assert.equal(armed.code, 5, artifact);
|
|
989
|
+
assert.equal(armed.reason, "event-pending", artifact);
|
|
990
|
+
assert.equal(fs.existsSync(path.join(outDir, `waker.lock.stale.${retired.nonce}`)), false);
|
|
991
|
+
|
|
992
|
+
fs.unlinkSync(pending);
|
|
993
|
+
assert.equal(probeWaker(outDir, { now: 1000, ttl: 1 }).reason, "stopped");
|
|
994
|
+
assert.equal(runWaker(outDir, { now: 1000 }).reason, "stopped");
|
|
995
|
+
rearmWaker(outDir, PLAN_VERSION);
|
|
996
|
+
assert.ok(acquireWakerLock(outDir, { now: 1001, ttl: 1 }), artifact);
|
|
997
|
+
}
|
|
998
|
+
});
|
|
999
|
+
|
|
1000
|
+
test("a consuming event fences real processes until disposition permits dead-PID takeover", { timeout: 15_000 }, async t => {
|
|
1001
|
+
const outDir = seedSpacedOutput();
|
|
1002
|
+
const retiredScript = `
|
|
1003
|
+
import { acquireWakerLock, writeWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
1004
|
+
const outDir = process.argv[1];
|
|
1005
|
+
const owner = acquireWakerLock(outDir, { now: Date.now(), ttl: 1 });
|
|
1006
|
+
if (!owner) throw new Error("failed to create retired owner");
|
|
1007
|
+
writeWakerEvent(outDir, { kind: "relay", planVersion: ${JSON.stringify(PLAN_VERSION)}, detail: "retire", nonce: owner.nonce });
|
|
1008
|
+
process.stdout.write(JSON.stringify(owner));
|
|
1009
|
+
`;
|
|
1010
|
+
const retiredResult = await spawnBounded(t, ["--input-type=module", "-e", retiredScript, outDir]);
|
|
1011
|
+
assert.equal(retiredResult.code, 0, retiredResult.stderr);
|
|
1012
|
+
const retired = JSON.parse(retiredResult.stdout);
|
|
1013
|
+
const consumed = claimWakerEvent(outDir);
|
|
1014
|
+
assert.equal(consumed.event.nonce, retired.nonce);
|
|
1015
|
+
|
|
1016
|
+
const blockedScript = `
|
|
1017
|
+
import { runWaker } from ${JSON.stringify(moduleUrl)};
|
|
1018
|
+
const result = runWaker(process.argv[1], {
|
|
1019
|
+
reconcile: () => { throw new Error("event-pending process reconciled"); },
|
|
1020
|
+
});
|
|
1021
|
+
process.stdout.write(JSON.stringify(result));
|
|
1022
|
+
`;
|
|
1023
|
+
const blockedResult = await spawnBounded(t, ["--input-type=module", "-e", blockedScript, outDir]);
|
|
1024
|
+
assert.equal(blockedResult.code, 0, blockedResult.stderr);
|
|
1025
|
+
const blocked = JSON.parse(blockedResult.stdout);
|
|
1026
|
+
assert.equal(blocked.code, 5);
|
|
1027
|
+
assert.equal(blocked.reason, "event-pending");
|
|
1028
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, retired.nonce);
|
|
1029
|
+
assert.equal(fs.existsSync(consumed.path), true);
|
|
1030
|
+
|
|
1031
|
+
assert.equal(handleWakerEvent(outDir, consumed, { reconcile: () => running() }).action, "arm");
|
|
1032
|
+
const successorScript = `
|
|
1033
|
+
import { acquireWakerLock } from ${JSON.stringify(moduleUrl)};
|
|
1034
|
+
process.stdout.write(JSON.stringify(acquireWakerLock(process.argv[1], { now: Date.now(), ttl: 1 })));
|
|
1035
|
+
`;
|
|
1036
|
+
const successorResult = await spawnBounded(t, ["--input-type=module", "-e", successorScript, outDir]);
|
|
1037
|
+
assert.equal(successorResult.code, 0, successorResult.stderr);
|
|
1038
|
+
const successor = JSON.parse(successorResult.stdout);
|
|
1039
|
+
assert.ok(successor);
|
|
1040
|
+
assert.notEqual(successor.nonce, retired.nonce);
|
|
1041
|
+
});
|
|
1042
|
+
|
|
1043
|
+
test("a failed handoff attempt still takes over when the old process exits before the next probe", { timeout: 15_000 }, async t => {
|
|
1044
|
+
const outDir = seedSpacedOutput();
|
|
1045
|
+
const ready = path.join(outDir, "old owner ready");
|
|
1046
|
+
const releaseOld = path.join(outDir, "release old owner");
|
|
1047
|
+
const attempted = path.join(outDir, "failed attempt observed");
|
|
1048
|
+
const releaseProbe = path.join(outDir, "release post-attempt probe");
|
|
1049
|
+
const oldScript = `
|
|
1050
|
+
import fs from "node:fs";
|
|
1051
|
+
import { acquireWakerLock } from ${JSON.stringify(moduleUrl)};
|
|
1052
|
+
const [outDir, ready, releaseOld] = process.argv.slice(1);
|
|
1053
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
1054
|
+
const owner = acquireWakerLock(outDir, { now: Date.now(), ttl: 90 });
|
|
1055
|
+
if (!owner) throw new Error("old owner acquisition failed");
|
|
1056
|
+
fs.writeFileSync(ready, JSON.stringify(owner));
|
|
1057
|
+
const until = Date.now() + 8000;
|
|
1058
|
+
while (!fs.existsSync(releaseOld) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1059
|
+
`;
|
|
1060
|
+
const oldProcess = spawnBounded(t, ["--input-type=module", "-e", oldScript, outDir, ready, releaseOld]);
|
|
1061
|
+
t.after(() => { if (!fs.existsSync(releaseOld)) fs.writeFileSync(releaseOld, "cleanup"); });
|
|
1062
|
+
await waitForFile(ready);
|
|
1063
|
+
const retired = readJson(ready);
|
|
1064
|
+
|
|
1065
|
+
const successorScript = `
|
|
1066
|
+
import fs from "node:fs";
|
|
1067
|
+
import { acquireWakerLock } from ${JSON.stringify(moduleUrl)};
|
|
1068
|
+
const [outDir, attempted, releaseProbe] = process.argv.slice(1);
|
|
1069
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
1070
|
+
let attempts = 0;
|
|
1071
|
+
const owner = acquireWakerLock(outDir, {
|
|
1072
|
+
now: Date.now(),
|
|
1073
|
+
ttl: 90,
|
|
1074
|
+
handoffTimeoutMs: 4000,
|
|
1075
|
+
handoffPollMs: 10,
|
|
1076
|
+
afterAttempt: current => {
|
|
1077
|
+
attempts += 1;
|
|
1078
|
+
if (attempts === 1) {
|
|
1079
|
+
if (current) throw new Error("first attempt unexpectedly acquired the live lock");
|
|
1080
|
+
fs.writeFileSync(attempted, "failed");
|
|
1081
|
+
const until = Date.now() + 6000;
|
|
1082
|
+
while (!fs.existsSync(releaseProbe) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1083
|
+
}
|
|
1084
|
+
},
|
|
1085
|
+
});
|
|
1086
|
+
process.stdout.write(JSON.stringify({ owner, attempts }));
|
|
1087
|
+
`;
|
|
1088
|
+
const successorProcess = spawnBounded(t, ["--input-type=module", "-e", successorScript, outDir, attempted, releaseProbe]);
|
|
1089
|
+
t.after(() => { if (!fs.existsSync(releaseProbe)) fs.writeFileSync(releaseProbe, "cleanup"); });
|
|
1090
|
+
await waitForFile(attempted);
|
|
1091
|
+
fs.writeFileSync(releaseOld, "go");
|
|
1092
|
+
const oldResult = await oldProcess;
|
|
1093
|
+
assert.equal(oldResult.code, 0, oldResult.stderr);
|
|
1094
|
+
fs.writeFileSync(releaseProbe, "go");
|
|
1095
|
+
const successorResult = await successorProcess;
|
|
1096
|
+
assert.equal(successorResult.code, 0, successorResult.stderr);
|
|
1097
|
+
const { owner, attempts } = JSON.parse(successorResult.stdout);
|
|
1098
|
+
assert.ok(owner, "dead-PID observed after a failed attempt must retry within the handoff deadline");
|
|
1099
|
+
assert.ok(attempts >= 2);
|
|
1100
|
+
assert.notEqual(owner.nonce, retired.nonce);
|
|
1101
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, owner.nonce);
|
|
1102
|
+
});
|
|
1103
|
+
|
|
1104
|
+
test("a real stale error interleaved during reconcile cannot stop its successor", { timeout: 15_000 }, async t => {
|
|
1105
|
+
const outDir = seedSpacedOutput();
|
|
1106
|
+
const entered = path.join(outDir, "error reconcile entered");
|
|
1107
|
+
const release = path.join(outDir, "release error reconcile");
|
|
1108
|
+
const retiredScript = `
|
|
1109
|
+
import { acquireWakerLock, writeWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
1110
|
+
const owner = acquireWakerLock(process.argv[1], { now: Date.now(), ttl: 1 });
|
|
1111
|
+
if (!owner) throw new Error("retired acquisition failed");
|
|
1112
|
+
writeWakerEvent(process.argv[1], { kind: "error", planVersion: ${JSON.stringify(PLAN_VERSION)}, detail: "late error", nonce: owner.nonce });
|
|
1113
|
+
process.stdout.write(JSON.stringify(owner));
|
|
1114
|
+
`;
|
|
1115
|
+
const retiredResult = await spawnBounded(t, ["--input-type=module", "-e", retiredScript, outDir]);
|
|
1116
|
+
assert.equal(retiredResult.code, 0, retiredResult.stderr);
|
|
1117
|
+
const retired = JSON.parse(retiredResult.stdout);
|
|
1118
|
+
const consumed = claimWakerEvent(outDir);
|
|
1119
|
+
|
|
1120
|
+
const handlerScript = `
|
|
1121
|
+
import fs from "node:fs";
|
|
1122
|
+
import { handleWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
1123
|
+
const [outDir, consumedJson, entered, release] = process.argv.slice(1);
|
|
1124
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
1125
|
+
const result = handleWakerEvent(outDir, JSON.parse(consumedJson), {
|
|
1126
|
+
reconcile: () => {
|
|
1127
|
+
fs.writeFileSync(entered, "entered");
|
|
1128
|
+
const until = Date.now() + 6000;
|
|
1129
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1130
|
+
return { status: "running", recovery_results: [] };
|
|
1131
|
+
},
|
|
1132
|
+
});
|
|
1133
|
+
process.stdout.write(JSON.stringify(result));
|
|
1134
|
+
`;
|
|
1135
|
+
const handler = spawnBounded(t, [
|
|
1136
|
+
"--input-type=module", "-e", handlerScript,
|
|
1137
|
+
outDir, JSON.stringify(consumed), entered, release,
|
|
1138
|
+
]);
|
|
1139
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(release)) fs.writeFileSync(release, "cleanup"); });
|
|
1140
|
+
await waitForFile(entered);
|
|
1141
|
+
|
|
1142
|
+
const successorScript = `
|
|
1143
|
+
import fs from "node:fs";
|
|
1144
|
+
import os from "node:os";
|
|
1145
|
+
const outDir = process.argv[1];
|
|
1146
|
+
const lock = outDir + "/waker.lock";
|
|
1147
|
+
const old = JSON.parse(fs.readFileSync(lock, "utf8"));
|
|
1148
|
+
fs.renameSync(lock, outDir + "/waker.lock.stale." + old.nonce + ".fault");
|
|
1149
|
+
const owner = {
|
|
1150
|
+
pid: process.pid, host: os.hostname(), nonce: "real-successor-owner",
|
|
1151
|
+
startedAt: new Date().toISOString(), plan_version: ${JSON.stringify(PLAN_VERSION)},
|
|
1152
|
+
};
|
|
1153
|
+
const fd = fs.openSync(lock, "wx");
|
|
1154
|
+
try {
|
|
1155
|
+
fs.writeSync(fd, JSON.stringify(owner), null, "utf8");
|
|
1156
|
+
fs.fsyncSync(fd);
|
|
1157
|
+
} finally { fs.closeSync(fd); }
|
|
1158
|
+
fs.writeFileSync(outDir + "/waker.heartbeat." + owner.nonce + ".json", JSON.stringify({
|
|
1159
|
+
nonce: owner.nonce, renewedAt: new Date().toISOString(),
|
|
1160
|
+
}));
|
|
1161
|
+
process.stdout.write(JSON.stringify(owner));
|
|
1162
|
+
`;
|
|
1163
|
+
const successorResult = await spawnBounded(t, ["--input-type=module", "-e", successorScript, outDir]);
|
|
1164
|
+
assert.equal(successorResult.code, 0, successorResult.stderr);
|
|
1165
|
+
const successor = JSON.parse(successorResult.stdout);
|
|
1166
|
+
fs.writeFileSync(release, "go");
|
|
1167
|
+
const handlerResult = await handler;
|
|
1168
|
+
assert.equal(handlerResult.code, 0, handlerResult.stderr);
|
|
1169
|
+
const outcome = JSON.parse(handlerResult.stdout);
|
|
1170
|
+
assert.equal(outcome.action, "ignore");
|
|
1171
|
+
assert.equal(outcome.reason, "stale");
|
|
1172
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
1173
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stale", `${consumed.event.event_id}.json`)), true);
|
|
1174
|
+
assert.equal(readJson(path.join(outDir, "waker.lock")).nonce, successor.nonce);
|
|
1175
|
+
assert.notEqual(successor.nonce, retired.nonce);
|
|
1176
|
+
});
|
|
1177
|
+
|
|
1178
|
+
test("independent wait events are consumed without impersonating a lock owner", () => {
|
|
1179
|
+
for (const specIds of [["p1"], []]) {
|
|
1180
|
+
const outDir = seedAt(fs.mkdtempSync(path.join(os.tmpdir(), "wait-consume-")), specIds);
|
|
1181
|
+
const deadline = new Date().toISOString();
|
|
1182
|
+
const waited = spawnSync(process.execPath, [
|
|
1183
|
+
cliPath, outDir, "wait", "--max-wait", "0", "--poll", "0", "--deadline", deadline,
|
|
1184
|
+
], { encoding: "utf8", timeout: 5000 });
|
|
1185
|
+
assert.equal(waited.status, 0, waited.stderr);
|
|
1186
|
+
const event = onlyPendingEvent(outDir);
|
|
1187
|
+
assert.equal(event.source, "wait");
|
|
1188
|
+
assert.equal(event.plan_version, specIds.length === 0 ? EMPTY_PLAN_VERSION : PLAN_VERSION);
|
|
1189
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.lock")), false);
|
|
1190
|
+
|
|
1191
|
+
const consumed = claimWakerEvent(outDir);
|
|
1192
|
+
const outcome = handleWakerEvent(outDir, consumed);
|
|
1193
|
+
|
|
1194
|
+
assert.equal(outcome.action, "arm");
|
|
1195
|
+
assert.equal(fs.existsSync(consumed.path), false);
|
|
1196
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.lock")), false, "wait never fabricates ownership");
|
|
1197
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
1198
|
+
|
|
1199
|
+
if (specIds.length === 0) {
|
|
1200
|
+
const startup = runWaker(outDir, { now: 0 });
|
|
1201
|
+
assert.equal(startup.event.kind, "complete", "the next waker startup emits the authoritative completion");
|
|
1202
|
+
const completeConsumed = claimWakerEvent(outDir);
|
|
1203
|
+
assert.equal(handleWakerEvent(outDir, completeConsumed).action, "finalize-ready");
|
|
1204
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), true);
|
|
1205
|
+
}
|
|
1206
|
+
}
|
|
1207
|
+
});
|
|
1208
|
+
|
|
1209
|
+
test("an owner-waker producer cannot forge the independent wait source", () => {
|
|
1210
|
+
const outDir = seededPlan(["p1"]);
|
|
1211
|
+
writeWakerEvent(outDir, {
|
|
1212
|
+
kind: "relay",
|
|
1213
|
+
planVersion: PLAN_VERSION,
|
|
1214
|
+
detail: "forged wait",
|
|
1215
|
+
source: "wait",
|
|
1216
|
+
nonce: "not-an-owner",
|
|
1217
|
+
});
|
|
1218
|
+
const consumed = claimWakerEvent(outDir);
|
|
1219
|
+
|
|
1220
|
+
const outcome = handleWakerEvent(outDir, consumed, {
|
|
1221
|
+
reconcile: () => { throw new Error("forged wait source must not reconcile"); },
|
|
1222
|
+
});
|
|
1223
|
+
|
|
1224
|
+
assert.equal(consumed.event.source, "waker");
|
|
1225
|
+
assert.equal(outcome.action, "ignore");
|
|
1226
|
+
assert.equal(outcome.reason, "stale");
|
|
1227
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
1228
|
+
});
|
|
1229
|
+
|
|
1230
|
+
test("a wait event with a stale plan_version is quarantined without reconcile", () => {
|
|
1231
|
+
const outDir = seededPlan(["p1"]);
|
|
1232
|
+
const waited = spawnSync(process.execPath, [
|
|
1233
|
+
cliPath, outDir, "wait", "--max-wait", "0", "--poll", "0",
|
|
1234
|
+
"--deadline", new Date().toISOString(),
|
|
1235
|
+
], { encoding: "utf8", timeout: 5000 });
|
|
1236
|
+
assert.equal(waited.status, 0, waited.stderr);
|
|
1237
|
+
const plan = readJson(path.join(outDir, "plan.json"));
|
|
1238
|
+
writeJsonAtomic(path.join(outDir, "plan.json"), { ...plan, plan_version: "p-new" });
|
|
1239
|
+
const consumed = claimWakerEvent(outDir);
|
|
1240
|
+
|
|
1241
|
+
const outcome = handleWakerEvent(outDir, consumed, {
|
|
1242
|
+
reconcile: () => { throw new Error("stale wait must not reconcile"); },
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1245
|
+
assert.equal(outcome.action, "ignore");
|
|
1246
|
+
assert.equal(outcome.reason, "stale");
|
|
1247
|
+
assert.equal(fs.existsSync(consumed.path), false);
|
|
1248
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), false);
|
|
1249
|
+
});
|
|
1250
|
+
|
|
1251
|
+
test("a missing plan before owner acquisition produces a consumable hard-block error", () => {
|
|
1252
|
+
const outDir = fs.mkdtempSync(path.join(os.tmpdir(), "waker-no-plan-"));
|
|
1253
|
+
|
|
1254
|
+
const result = runWaker(outDir, { now: 0 });
|
|
1255
|
+
|
|
1256
|
+
assert.equal(result.code, 2);
|
|
1257
|
+
assert.equal(result.reason, "hard-block");
|
|
1258
|
+
assert.equal(result.event.kind, "error");
|
|
1259
|
+
assert.equal(result.event.nonce, null);
|
|
1260
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.lock")), false);
|
|
1261
|
+
const consumed = claimWakerEvent(outDir);
|
|
1262
|
+
const outcome = handleWakerEvent(outDir, consumed, { reconcile: () => running(), now: 1 });
|
|
1263
|
+
assert.equal(outcome.action, "hard-block");
|
|
1264
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.stop")), true);
|
|
1265
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.errors", `${consumed.event.event_id}.json`)), true);
|
|
1266
|
+
assert.equal(runWaker(outDir, { now: 2 }).reason, "stopped");
|
|
1267
|
+
});
|
|
1268
|
+
|
|
1269
|
+
test("an acquire throw before ownership produces an error event and persistent stop", () => {
|
|
1270
|
+
const outDir = seededPlan(["p1"]);
|
|
1271
|
+
const originalOpenSync = fs.openSync;
|
|
1272
|
+
fs.openSync = function (file, flags, ...args) {
|
|
1273
|
+
if (path.resolve(file) === path.resolve(path.join(outDir, "waker.lock")) && flags === "wx") {
|
|
1274
|
+
throw new Error("acquire exploded");
|
|
1275
|
+
}
|
|
1276
|
+
return originalOpenSync.call(fs, file, flags, ...args);
|
|
1277
|
+
};
|
|
1278
|
+
let result;
|
|
1279
|
+
try {
|
|
1280
|
+
result = runWaker(outDir, { now: 0 });
|
|
1281
|
+
} finally {
|
|
1282
|
+
fs.openSync = originalOpenSync;
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
assert.equal(result.code, 2);
|
|
1286
|
+
assert.equal(result.reason, "hard-block");
|
|
1287
|
+
assert.equal(result.event.kind, "error");
|
|
1288
|
+
assert.match(result.event.detail, /acquire exploded/);
|
|
1289
|
+
const consumed = claimWakerEvent(outDir);
|
|
1290
|
+
assert.equal(handleWakerEvent(outDir, consumed, { reconcile: () => running(), now: 1 }).action, "hard-block");
|
|
1291
|
+
assert.equal(readJson(path.join(outDir, "waker.stop")).plan_version, PLAN_VERSION);
|
|
1292
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.errors", `${consumed.event.event_id}.json`)), true);
|
|
1293
|
+
assert.equal(runWaker(outDir, { now: 2 }).reason, "stopped");
|
|
1294
|
+
});
|
|
1295
|
+
|
|
1296
|
+
function spawnEventFault(t, outDir, operation, point) {
|
|
1297
|
+
const script = `
|
|
1298
|
+
import fs from "node:fs";
|
|
1299
|
+
import path from "node:path";
|
|
1300
|
+
import { writeWakerEvent, claimWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
1301
|
+
const [outDir, operation, point] = process.argv.slice(1);
|
|
1302
|
+
const pending = path.join(outDir, "waker.events", "pending");
|
|
1303
|
+
const originalLinkSync = fs.linkSync;
|
|
1304
|
+
fs.linkSync = function (from, to) {
|
|
1305
|
+
const pendingPublication = path.resolve(path.dirname(to)) === path.resolve(pending) &&
|
|
1306
|
+
path.basename(to).endsWith(".json");
|
|
1307
|
+
const pendingClaim = path.resolve(path.dirname(from)) === path.resolve(pending) &&
|
|
1308
|
+
path.basename(to).startsWith("waker.claiming.");
|
|
1309
|
+
if (pendingPublication && point === "before-event-publish") process.exit(91);
|
|
1310
|
+
const result = originalLinkSync.call(fs, from, to);
|
|
1311
|
+
if (pendingPublication && point === "after-event-publish") process.exit(92);
|
|
1312
|
+
if (pendingClaim && point === "after-source-claiming") process.exit(93);
|
|
1313
|
+
if (path.basename(to).startsWith("waker.consuming.") && point === "after-claiming-consuming") {
|
|
1314
|
+
process.exit(94);
|
|
1315
|
+
}
|
|
1316
|
+
return result;
|
|
1317
|
+
};
|
|
1318
|
+
const result = operation === "claim"
|
|
1319
|
+
? claimWakerEvent(outDir)
|
|
1320
|
+
: writeWakerEvent(outDir, { kind: "relay", planVersion: ${JSON.stringify(PLAN_VERSION)}, detail: "after crash", nonce: null });
|
|
1321
|
+
process.stdout.write(JSON.stringify(result));
|
|
1322
|
+
`;
|
|
1323
|
+
return spawnBounded(t, ["--input-type=module", "-e", script, outDir, operation, point]);
|
|
1324
|
+
}
|
|
1325
|
+
|
|
1326
|
+
test("a crash before event publication leaves only ignored hidden pending debris", { timeout: 10_000 }, async t => {
|
|
1327
|
+
const outDir = seedSpacedOutput();
|
|
1328
|
+
const crashed = await spawnEventFault(t, outDir, "write", "before-event-publish");
|
|
1329
|
+
|
|
1330
|
+
assert.equal(crashed.code, 91, crashed.stderr);
|
|
1331
|
+
const pending = pendingEventDirectory(outDir);
|
|
1332
|
+
assert.equal(pendingEvents(outDir).length, 0);
|
|
1333
|
+
const debris = fs.readdirSync(pending).filter(name => name.startsWith(".") && name.endsWith(".tmp"));
|
|
1334
|
+
assert.equal(debris.length, 1);
|
|
1335
|
+
assert.equal(readJson(path.join(pending, debris[0])).detail, "after crash");
|
|
1336
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.event.json.lock")), false);
|
|
1337
|
+
|
|
1338
|
+
const recovered = writeWakerEvent(outDir, {
|
|
1339
|
+
kind: "deadline", planVersion: PLAN_VERSION, detail: "recovered", nonce: null,
|
|
1340
|
+
});
|
|
1341
|
+
assert.deepEqual(onlyPendingEvent(outDir), recovered);
|
|
1342
|
+
assert.equal(fs.readdirSync(pending).filter(name => name === debris[0]).length, 1);
|
|
1343
|
+
});
|
|
1344
|
+
|
|
1345
|
+
test("a crash after event publication preserves the pending event for claiming", { timeout: 10_000 }, async t => {
|
|
1346
|
+
const outDir = seedSpacedOutput();
|
|
1347
|
+
const crashed = await spawnEventFault(t, outDir, "write", "after-event-publish");
|
|
1348
|
+
|
|
1349
|
+
assert.equal(crashed.code, 92, crashed.stderr);
|
|
1350
|
+
const produced = onlyPendingEvent(outDir);
|
|
1351
|
+
assert.equal(produced.detail, "after crash");
|
|
1352
|
+
const claimed = claimWakerEvent(outDir);
|
|
1353
|
+
assert.deepEqual(claimed.event, produced);
|
|
1354
|
+
assert.deepEqual(readJson(claimed.path), produced);
|
|
1355
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.event.json.lock")), false);
|
|
1356
|
+
});
|
|
1357
|
+
|
|
1358
|
+
test("a crash after the pending hard link resumes duplicate copies into one consuming event", { timeout: 10_000 }, async t => {
|
|
1359
|
+
const outDir = seedSpacedOutput();
|
|
1360
|
+
const produced = writeWakerEvent(outDir, {
|
|
1361
|
+
kind: "drafts", planVersion: PLAN_VERSION, detail: "claiming survivor", nonce: null,
|
|
1362
|
+
});
|
|
1363
|
+
const crashed = await spawnEventFault(t, outDir, "claim", "after-source-claiming");
|
|
1364
|
+
|
|
1365
|
+
assert.equal(crashed.code, 93, crashed.stderr);
|
|
1366
|
+
assert.deepEqual(pendingEvents(outDir), [produced], "the unlinked pending duplicate remains fenced");
|
|
1367
|
+
const claiming = fs.readdirSync(outDir).filter(name => name.startsWith("waker.claiming."));
|
|
1368
|
+
assert.equal(claiming.length, 1);
|
|
1369
|
+
assert.deepEqual(readJson(path.join(outDir, claiming[0])), produced);
|
|
1370
|
+
|
|
1371
|
+
const claimed = claimWakerEvent(outDir);
|
|
1372
|
+
assert.deepEqual(claimed.event, produced);
|
|
1373
|
+
assert.deepEqual(readJson(claimed.path), produced);
|
|
1374
|
+
assert.equal(claimed.path, path.join(outDir, `waker.consuming.${produced.event_id}.json`));
|
|
1375
|
+
assert.equal(fs.readdirSync(outDir).some(name => name.startsWith("waker.claiming.")), false);
|
|
1376
|
+
assert.deepEqual(pendingEvents(outDir), [], "recovery removes only the byte-identical pending duplicate");
|
|
1377
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.event.json.lock")), false);
|
|
1378
|
+
});
|
|
1379
|
+
|
|
1380
|
+
test("a crash after claiming to consuming recovers fatal handling and stop metadata", { timeout: 10_000 }, async t => {
|
|
1381
|
+
const outDir = seedSpacedOutput();
|
|
1382
|
+
const produced = writeWakerEvent(outDir, {
|
|
1383
|
+
kind: "error", planVersion: PLAN_VERSION, detail: "fatal survivor", nonce: null,
|
|
1384
|
+
});
|
|
1385
|
+
const crashed = await spawnEventFault(t, outDir, "claim", "after-claiming-consuming");
|
|
1386
|
+
|
|
1387
|
+
assert.equal(crashed.code, 94, crashed.stderr);
|
|
1388
|
+
const consuming = path.join(outDir, `waker.consuming.${produced.event_id}.json`);
|
|
1389
|
+
assert.deepEqual(readJson(consuming), produced);
|
|
1390
|
+
assert.equal(fs.readdirSync(outDir).filter(name => name.startsWith("waker.claiming.")).length, 1);
|
|
1391
|
+
const recovered = claimWakerEvent(outDir);
|
|
1392
|
+
assert.deepEqual(recovered.event, produced);
|
|
1393
|
+
assert.equal(recovered.path, consuming);
|
|
1394
|
+
assert.equal(fs.readdirSync(outDir).some(name => name.startsWith("waker.claiming.")), false);
|
|
1395
|
+
|
|
1396
|
+
const outcome = handleWakerEvent(outDir, recovered, {
|
|
1397
|
+
reconcile: () => running(), now: 1,
|
|
1398
|
+
});
|
|
1399
|
+
assert.equal(outcome.action, "hard-block");
|
|
1400
|
+
assert.equal(readJson(path.join(outDir, "waker.stop")).reason, "error");
|
|
1401
|
+
assert.equal(readJson(path.join(outDir, "waker.stop")).event_id, produced.event_id);
|
|
1402
|
+
assert.deepEqual(readJson(path.join(outDir, "waker.errors", `${produced.event_id}.json`)), produced);
|
|
1403
|
+
assert.equal(fs.existsSync(consuming), false);
|
|
1404
|
+
});
|
|
1405
|
+
|
|
1406
|
+
test("lock-free queue lifecycle creates no event mutex, reaper, or guard files", async t => {
|
|
1407
|
+
const outDir = seedSpacedOutput(["p1"], t);
|
|
1408
|
+
const owner = acquireWakerLock(outDir, { now: 0 });
|
|
1409
|
+
const first = writeWakerEvent(outDir, {
|
|
1410
|
+
kind: "relay", planVersion: PLAN_VERSION, detail: "first", nonce: owner.nonce, now: 1,
|
|
1411
|
+
});
|
|
1412
|
+
const second = writeWakerEvent(outDir, {
|
|
1413
|
+
kind: "drafts", planVersion: PLAN_VERSION, detail: "second", nonce: owner.nonce, now: 2,
|
|
1414
|
+
});
|
|
1415
|
+
assert.equal(new Set([first.event_id, second.event_id]).size, 2);
|
|
1416
|
+
assert.equal(fs.existsSync(path.join(outDir, "waker.event.json")), false);
|
|
1417
|
+
|
|
1418
|
+
const consumedFirst = claimWakerEvent(outDir);
|
|
1419
|
+
assert.equal(consumedFirst.event.event_id, first.event_id);
|
|
1420
|
+
assert.deepEqual(pendingEvents(outDir), [second]);
|
|
1421
|
+
assert.equal(handleWakerEvent(outDir, consumedFirst, { reconcile: () => running() }).action, "event-pending");
|
|
1422
|
+
const consumedSecond = claimWakerEvent(outDir);
|
|
1423
|
+
assert.equal(consumedSecond.event.event_id, second.event_id);
|
|
1424
|
+
assert.equal(handleWakerEvent(outDir, consumedSecond, { reconcile: () => running() }).action, "arm");
|
|
1425
|
+
assertQueueEmpty(outDir);
|
|
1426
|
+
});
|
|
1427
|
+
|
|
1428
|
+
test("real concurrent producers preserve every ordinary and fatal event exactly once", { timeout: 60_000 }, async t => {
|
|
1429
|
+
const outDir = seedSpacedOutput(["p1"], t);
|
|
1430
|
+
const owner = acquireWakerLock(outDir, { now: 0 });
|
|
1431
|
+
const start = path.join(outDir, "start producers");
|
|
1432
|
+
const producerCount = 6;
|
|
1433
|
+
const script = `
|
|
1434
|
+
import fs from "node:fs";
|
|
1435
|
+
import { writeWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
1436
|
+
const [outDir, producerText, start] = process.argv.slice(1);
|
|
1437
|
+
const producer = Number(producerText);
|
|
1438
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
1439
|
+
fs.writeFileSync(outDir + "/producer " + producer + ".ready", "ready");
|
|
1440
|
+
const until = Date.now() + 20000;
|
|
1441
|
+
while (!fs.existsSync(start) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1442
|
+
if (!fs.existsSync(start)) throw new Error("producer barrier timed out");
|
|
1443
|
+
const published = [];
|
|
1444
|
+
for (let sequence = 0; sequence < 3; sequence += 1) {
|
|
1445
|
+
const kind = (producer + sequence) % 3 === 0 ? "error" : sequence % 2 === 0 ? "relay" : "drafts";
|
|
1446
|
+
published.push(writeWakerEvent(outDir, {
|
|
1447
|
+
kind,
|
|
1448
|
+
planVersion: ${JSON.stringify(PLAN_VERSION)},
|
|
1449
|
+
detail: "producer " + producer + " event " + sequence,
|
|
1450
|
+
nonce: ${JSON.stringify(owner.nonce)},
|
|
1451
|
+
now: 1000 + producer * 10 + sequence,
|
|
1452
|
+
}));
|
|
1453
|
+
}
|
|
1454
|
+
process.stdout.write(JSON.stringify(published));
|
|
1455
|
+
`;
|
|
1456
|
+
const producers = Array.from({ length: producerCount }, (_, producer) =>
|
|
1457
|
+
spawnBounded(t, ["--input-type=module", "-e", script, outDir, String(producer), start]));
|
|
1458
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(start)) fs.writeFileSync(start, "cleanup"); });
|
|
1459
|
+
await Promise.all(Array.from({ length: producerCount }, (_, producer) =>
|
|
1460
|
+
waitForFile(path.join(outDir, `producer ${producer}.ready`))));
|
|
1461
|
+
fs.writeFileSync(start, "go");
|
|
1462
|
+
const results = await Promise.all(producers);
|
|
1463
|
+
for (const result of results) assert.equal(result.code, 0, result.stderr);
|
|
1464
|
+
const published = results.flatMap(result => JSON.parse(result.stdout));
|
|
1465
|
+
assert.equal(published.length, producerCount * 3);
|
|
1466
|
+
assert.equal(new Set(published.map(event => event.event_id)).size, published.length);
|
|
1467
|
+
assert.ok(published.filter(event => event.kind === "error").length >= 4);
|
|
1468
|
+
assert.deepEqual(pendingEvents(outDir).map(event => event.event_id).sort(),
|
|
1469
|
+
published.map(event => event.event_id).sort());
|
|
1470
|
+
assertNoEventMutexArtifacts(outDir);
|
|
1471
|
+
|
|
1472
|
+
const expectedErrors = published.filter(event => event.kind === "error")
|
|
1473
|
+
.sort((left, right) => left.at.localeCompare(right.at) || left.event_id.localeCompare(right.event_id));
|
|
1474
|
+
const consumedErrors = [];
|
|
1475
|
+
for (const expected of expectedErrors) {
|
|
1476
|
+
const consumed = claimWakerEvent(outDir);
|
|
1477
|
+
assert.equal(consumed.event.event_id, expected.event_id, "fatal events preempt every ordinary event");
|
|
1478
|
+
assert.equal(handleWakerEvent(outDir, consumed, {
|
|
1479
|
+
now: 2000,
|
|
1480
|
+
reconcile: () => running(),
|
|
1481
|
+
}).action, "hard-block");
|
|
1482
|
+
consumedErrors.push(consumed.event);
|
|
1483
|
+
}
|
|
1484
|
+
assert.equal(claimWakerEvent(outDir), null, "stop freezes ordinary events after the fatal drain");
|
|
1485
|
+
assert.deepEqual(consumedErrors, expectedErrors);
|
|
1486
|
+
assert.deepEqual(pendingEvents(outDir).map(event => event.event_id).sort(),
|
|
1487
|
+
published.filter(event => event.kind !== "error").map(event => event.event_id).sort());
|
|
1488
|
+
for (const expected of expectedErrors) {
|
|
1489
|
+
assert.deepEqual(readJson(path.join(outDir, "waker.errors", `${expected.event_id}.json`)), expected);
|
|
1490
|
+
}
|
|
1491
|
+
assertNoEventMutexArtifacts(outDir);
|
|
1492
|
+
|
|
1493
|
+
rearmWaker(outDir, PLAN_VERSION);
|
|
1494
|
+
const expectedOrdinary = published.filter(event => event.kind !== "error")
|
|
1495
|
+
.sort((left, right) => left.at.localeCompare(right.at) || left.event_id.localeCompare(right.event_id));
|
|
1496
|
+
const consumedOrdinary = [];
|
|
1497
|
+
for (const expected of expectedOrdinary) {
|
|
1498
|
+
const consumed = claimWakerEvent(outDir);
|
|
1499
|
+
assert.equal(consumed.event.event_id, expected.event_id);
|
|
1500
|
+
handleWakerEvent(outDir, consumed, { now: 3000, reconcile: () => running() });
|
|
1501
|
+
consumedOrdinary.push(consumed.event);
|
|
1502
|
+
}
|
|
1503
|
+
assert.deepEqual(consumedOrdinary, expectedOrdinary);
|
|
1504
|
+
assert.deepEqual([...consumedErrors, ...consumedOrdinary].map(event => event.event_id).sort(),
|
|
1505
|
+
published.map(event => event.event_id).sort());
|
|
1506
|
+
assertQueueEmpty(outDir);
|
|
1507
|
+
});
|
|
1508
|
+
|
|
1509
|
+
test("two real consumers produce exactly one disposition and one reconcile", { timeout: 60_000 }, async t => {
|
|
1510
|
+
const outDir = seedSpacedOutput(["p1"], t);
|
|
1511
|
+
const owner = acquireWakerLock(outDir, { now: 0 });
|
|
1512
|
+
const produced = writeWakerEvent(outDir, {
|
|
1513
|
+
kind: "relay", planVersion: PLAN_VERSION, detail: "same pending race", nonce: owner.nonce, now: 1,
|
|
1514
|
+
});
|
|
1515
|
+
const pending = path.join(pendingEventDirectory(outDir), `${produced.event_id}.json`);
|
|
1516
|
+
const release = path.join(outDir, "release consumers");
|
|
1517
|
+
const dispositionComplete = path.join(outDir, "disposition complete");
|
|
1518
|
+
const script = `
|
|
1519
|
+
import fs from "node:fs";
|
|
1520
|
+
import path from "node:path";
|
|
1521
|
+
import { claimWakerEvent, handleWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
1522
|
+
const [outDir, consumer, pending, release, dispositionComplete] = process.argv.slice(1);
|
|
1523
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
1524
|
+
const originalLinkSync = fs.linkSync;
|
|
1525
|
+
const originalRenameSync = fs.renameSync;
|
|
1526
|
+
let pendingClaimWins = 0;
|
|
1527
|
+
let pendingArchiveWins = 0;
|
|
1528
|
+
let pendingClaimingRenames = 0;
|
|
1529
|
+
const claimLog = [];
|
|
1530
|
+
fs.linkSync = function (from, to) {
|
|
1531
|
+
if (path.resolve(from) === path.resolve(pending)) {
|
|
1532
|
+
fs.writeFileSync(outDir + "/consumer " + consumer + ".ready", "ready");
|
|
1533
|
+
const until = Date.now() + 20000;
|
|
1534
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1535
|
+
if (!fs.existsSync(release)) throw new Error("consumer barrier timed out");
|
|
1536
|
+
}
|
|
1537
|
+
const before = path.resolve(from) === path.resolve(pending) ? fs.existsSync(from) : null;
|
|
1538
|
+
try {
|
|
1539
|
+
const result = originalLinkSync.call(fs, from, to);
|
|
1540
|
+
if (path.resolve(from) === path.resolve(pending)) {
|
|
1541
|
+
pendingClaimWins += 1;
|
|
1542
|
+
claimLog.push({ from, to, before, result: "success" });
|
|
1543
|
+
fs.writeFileSync(outDir + "/consumer " + consumer + ".attempted", "done");
|
|
1544
|
+
// Do not move claiming aside until the peer has attempted the same
|
|
1545
|
+
// fixed destination; otherwise a late peer can win a second race.
|
|
1546
|
+
const peer = consumer === "1" ? "2" : "1";
|
|
1547
|
+
const attempted = outDir + "/consumer " + peer + ".attempted";
|
|
1548
|
+
const until = Date.now() + 20000;
|
|
1549
|
+
while (!fs.existsSync(attempted) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1550
|
+
if (!fs.existsSync(attempted)) throw new Error("peer installation barrier timed out");
|
|
1551
|
+
}
|
|
1552
|
+
return result;
|
|
1553
|
+
} catch (error) {
|
|
1554
|
+
if (path.resolve(from) === path.resolve(pending)) {
|
|
1555
|
+
claimLog.push({ from, to, before, result: error.code });
|
|
1556
|
+
fs.writeFileSync(outDir + "/consumer " + consumer + ".attempted", "done");
|
|
1557
|
+
// Keep the loser inside its failed atomic installation until the
|
|
1558
|
+
// winner's single disposition is durable. Otherwise claimEvent can
|
|
1559
|
+
// legitimately retry as a new consumer and invalidate this test's
|
|
1560
|
+
// fixed-installation-winner scenario instead of exercising it.
|
|
1561
|
+
const until = Date.now() + 20000;
|
|
1562
|
+
while (!fs.existsSync(dispositionComplete) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1563
|
+
if (!fs.existsSync(dispositionComplete)) throw new Error("disposition barrier timed out");
|
|
1564
|
+
}
|
|
1565
|
+
throw error;
|
|
1566
|
+
}
|
|
1567
|
+
};
|
|
1568
|
+
fs.renameSync = function (from, to) {
|
|
1569
|
+
if (path.resolve(from) !== path.resolve(pending)) return originalRenameSync.call(fs, from, to);
|
|
1570
|
+
const archive = path.resolve(path.dirname(to)) === path.resolve(path.join(outDir, "waker.duplicates"));
|
|
1571
|
+
if (!archive) pendingClaimingRenames += 1;
|
|
1572
|
+
try {
|
|
1573
|
+
const result = originalRenameSync.call(fs, from, to);
|
|
1574
|
+
if (archive) pendingArchiveWins += 1;
|
|
1575
|
+
claimLog.push({ from, to, operation: archive ? "archive" : "active-overwrite", result: "success" });
|
|
1576
|
+
return result;
|
|
1577
|
+
} catch (error) {
|
|
1578
|
+
claimLog.push({ from, to, operation: archive ? "archive" : "active-overwrite", result: error.code });
|
|
1579
|
+
throw error;
|
|
1580
|
+
}
|
|
1581
|
+
};
|
|
1582
|
+
const consumed = claimWakerEvent(outDir);
|
|
1583
|
+
const outcome = consumed?.event ? handleWakerEvent(outDir, consumed, {
|
|
1584
|
+
reconcile: () => {
|
|
1585
|
+
fs.appendFileSync(outDir + "/reconcile.calls", consumer + "\\n");
|
|
1586
|
+
return { status: "running", recovery_results: [] };
|
|
1587
|
+
},
|
|
1588
|
+
}) : consumed?.hardBlock ? { action: "claim-hard-block", claim: consumed.hardBlock } : { action: "lock-held" };
|
|
1589
|
+
if (pendingClaimWins === 1) fs.writeFileSync(dispositionComplete, "done");
|
|
1590
|
+
process.stdout.write(JSON.stringify({ consumed, outcome, pendingClaimWins, pendingArchiveWins, pendingClaimingRenames, claimLog }));
|
|
1591
|
+
`;
|
|
1592
|
+
const args = consumer => ["--input-type=module", "-e", script, outDir, String(consumer), pending, release, dispositionComplete];
|
|
1593
|
+
const first = spawnBounded(t, args(1));
|
|
1594
|
+
const second = spawnBounded(t, args(2));
|
|
1595
|
+
t.after(() => {
|
|
1596
|
+
if (!fs.existsSync(outDir)) return;
|
|
1597
|
+
if (!fs.existsSync(release)) fs.writeFileSync(release, "cleanup");
|
|
1598
|
+
if (!fs.existsSync(dispositionComplete)) fs.writeFileSync(dispositionComplete, "cleanup");
|
|
1599
|
+
});
|
|
1600
|
+
await Promise.all([1, 2].map(consumer => waitForFile(path.join(outDir, `consumer ${consumer}.ready`))));
|
|
1601
|
+
assert.deepEqual(readJson(pending), produced, "both consumers inspected the same pending file");
|
|
1602
|
+
fs.writeFileSync(release, "go");
|
|
1603
|
+
const results = await Promise.all([first, second]);
|
|
1604
|
+
for (const result of results) assert.equal(result.code, 0, result.stderr);
|
|
1605
|
+
const claims = results.map(result => JSON.parse(result.stdout));
|
|
1606
|
+
assert.equal(claims.reduce((sum, claim) => sum + claim.pendingClaimWins, 0), 1,
|
|
1607
|
+
`only one pending-to-claiming atomic installation may win: ${JSON.stringify({ claims, active: activeEventFiles(outDir) })}`);
|
|
1608
|
+
assert.equal(claims.reduce((sum, claim) => sum + claim.pendingArchiveWins, 0), 1,
|
|
1609
|
+
`only the installation winner may archive the pending duplicate: ${JSON.stringify({ claims, active: activeEventFiles(outDir) })}`);
|
|
1610
|
+
assert.equal(claims.reduce((sum, claim) => sum + claim.pendingClaimingRenames, 0), 0,
|
|
1611
|
+
`no consumer may rename pending over fixed claiming: ${JSON.stringify({ claims, active: activeEventFiles(outDir) })}`);
|
|
1612
|
+
const winners = claims.filter(claim => claim.consumed !== null);
|
|
1613
|
+
assert.equal(winners.length, 1,
|
|
1614
|
+
`only the fixed installation winner may obtain disposition rights: ${JSON.stringify({ claims, active: activeEventFiles(outDir) })}`);
|
|
1615
|
+
assert.equal(claims.filter(claim => claim.outcome.action === "lock-held").length, 1,
|
|
1616
|
+
`the loser returns null/lock-held instead of recovering the same consuming: ${JSON.stringify({ claims, active: activeEventFiles(outDir) })}`);
|
|
1617
|
+
assert.equal(winners[0].outcome.action, "arm");
|
|
1618
|
+
assert.deepEqual(winners[0].consumed.event, produced);
|
|
1619
|
+
assert.equal(winners[0].consumed.path, path.join(outDir, `waker.consuming.${produced.event_id}.json`));
|
|
1620
|
+
assert.equal(fs.readFileSync(path.join(outDir, "reconcile.calls"), "utf8").trim().split(/\r?\n/).length, 1,
|
|
1621
|
+
"the losing child must not reconcile or archive a duplicate disposition");
|
|
1622
|
+
const duplicateDirectory = path.join(outDir, "waker.duplicates", "verified");
|
|
1623
|
+
const archived = fs.readdirSync(duplicateDirectory).sort()
|
|
1624
|
+
.map(name => fs.readFileSync(path.join(duplicateDirectory, name)));
|
|
1625
|
+
const expectedBytes = Buffer.from(`${JSON.stringify(produced, null, 2)}\n`);
|
|
1626
|
+
assert.equal(archived.length, 4, "two claim sources plus the byte-checked disposition checkpoint and consuming archive");
|
|
1627
|
+
archived.forEach(bytes => assert.deepEqual(bytes, expectedBytes));
|
|
1628
|
+
assertQueueEmpty(outDir);
|
|
1629
|
+
});
|
|
1630
|
+
|
|
1631
|
+
test("real stopped consumers resume fatal claiming and consuming while ordinary evidence stays frozen", { timeout: 60_000 }, async t => {
|
|
1632
|
+
for (const fatalLocation of ["claiming", "consuming"]) {
|
|
1633
|
+
const outDir = seedSpacedOutput(["p1"], t);
|
|
1634
|
+
const owner = acquireWakerLock(outDir, { now: 0 });
|
|
1635
|
+
const ordinary = writeWakerEvent(outDir, {
|
|
1636
|
+
kind: "relay", planVersion: PLAN_VERSION, detail: `frozen ${fatalLocation}`, nonce: owner.nonce, now: 0,
|
|
1637
|
+
});
|
|
1638
|
+
const ordinaryTarget = path.join(outDir, fatalLocation === "claiming"
|
|
1639
|
+
? `waker.consuming.${ordinary.event_id}.json`
|
|
1640
|
+
: "waker.claiming.frozen ordinary.json");
|
|
1641
|
+
fs.renameSync(path.join(pendingEventDirectory(outDir), `${ordinary.event_id}.json`), ordinaryTarget);
|
|
1642
|
+
const ordinaryBytes = fs.readFileSync(ordinaryTarget);
|
|
1643
|
+
const fatal = writeWakerEvent(outDir, {
|
|
1644
|
+
kind: "error", planVersion: PLAN_VERSION, detail: `recover ${fatalLocation}`, nonce: owner.nonce, now: 1,
|
|
1645
|
+
});
|
|
1646
|
+
const fatalTarget = path.join(outDir, fatalLocation === "claiming"
|
|
1647
|
+
? "waker.claiming.fatal recovery.json"
|
|
1648
|
+
: `waker.consuming.${fatal.event_id}.json`);
|
|
1649
|
+
fs.renameSync(path.join(pendingEventDirectory(outDir), `${fatal.event_id}.json`), fatalTarget);
|
|
1650
|
+
stopWaker(outDir, PLAN_VERSION, { now: 2, reason: "error", eventId: fatal.event_id });
|
|
1651
|
+
|
|
1652
|
+
const entered = path.join(outDir, `${fatalLocation} recovery entered`);
|
|
1653
|
+
const release = path.join(outDir, `${fatalLocation} recovery release`);
|
|
1654
|
+
const script = `
|
|
1655
|
+
import fs from "node:fs";
|
|
1656
|
+
import path from "node:path";
|
|
1657
|
+
import { claimWakerEvent, handleWakerEvent } from ${JSON.stringify(moduleUrl)};
|
|
1658
|
+
const [outDir, fatalLocation, fatalId, entered, release] = process.argv.slice(1);
|
|
1659
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
1660
|
+
let paused = false;
|
|
1661
|
+
const barrier = () => {
|
|
1662
|
+
if (paused) return;
|
|
1663
|
+
paused = true;
|
|
1664
|
+
fs.writeFileSync(entered, "entered");
|
|
1665
|
+
const until = Date.now() + 20000;
|
|
1666
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1667
|
+
if (!fs.existsSync(release)) throw new Error("stop recovery barrier timed out");
|
|
1668
|
+
};
|
|
1669
|
+
const originalLinkSync = fs.linkSync;
|
|
1670
|
+
fs.linkSync = function (from, to) {
|
|
1671
|
+
if (fatalLocation === "claiming" && path.basename(to) === "waker.consuming." + fatalId + ".json") barrier();
|
|
1672
|
+
return originalLinkSync.call(fs, from, to);
|
|
1673
|
+
};
|
|
1674
|
+
const consumed = claimWakerEvent(outDir);
|
|
1675
|
+
if (!consumed || consumed.event.event_id !== fatalId) throw new Error("fatal recovery was not selected under stop");
|
|
1676
|
+
const outcome = handleWakerEvent(outDir, consumed, {
|
|
1677
|
+
now: 3,
|
|
1678
|
+
reconcile: () => {
|
|
1679
|
+
if (fatalLocation === "consuming") barrier();
|
|
1680
|
+
return { status: "running", recovery_results: [] };
|
|
1681
|
+
},
|
|
1682
|
+
});
|
|
1683
|
+
process.stdout.write(JSON.stringify({ consumed, outcome }));
|
|
1684
|
+
`;
|
|
1685
|
+
const child = spawnBounded(t, [
|
|
1686
|
+
"--input-type=module", "-e", script,
|
|
1687
|
+
outDir, fatalLocation, fatal.event_id, entered, release,
|
|
1688
|
+
]);
|
|
1689
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(release)) fs.writeFileSync(release, "cleanup"); });
|
|
1690
|
+
await waitForFile(entered);
|
|
1691
|
+
assert.deepEqual(fs.readFileSync(ordinaryTarget), ordinaryBytes, fatalLocation);
|
|
1692
|
+
assert.equal(readJson(path.join(outDir, "waker.stop")).reason, "error", fatalLocation);
|
|
1693
|
+
fs.writeFileSync(release, "go");
|
|
1694
|
+
const result = await child;
|
|
1695
|
+
assert.equal(result.code, 0, result.stderr);
|
|
1696
|
+
const { consumed, outcome } = JSON.parse(result.stdout);
|
|
1697
|
+
assert.equal(consumed.event.event_id, fatal.event_id, fatalLocation);
|
|
1698
|
+
assert.equal(consumed.location, "consuming", fatalLocation);
|
|
1699
|
+
assert.equal(outcome.action, "hard-block", fatalLocation);
|
|
1700
|
+
assert.deepEqual(readJson(path.join(outDir, "waker.errors", `${fatal.event_id}.json`)), fatal, fatalLocation);
|
|
1701
|
+
assert.deepEqual(fs.readFileSync(ordinaryTarget), ordinaryBytes, fatalLocation);
|
|
1702
|
+
assert.equal(claimWakerEvent(outDir), null, `${fatalLocation}: ordinary recovery remains frozen`);
|
|
1703
|
+
assert.deepEqual(activeEventFiles(outDir), [path.basename(ordinaryTarget)], fatalLocation);
|
|
1704
|
+
assertNoEventMutexArtifacts(outDir);
|
|
1705
|
+
}
|
|
1706
|
+
});
|
|
1707
|
+
|
|
1708
|
+
test("real quarantining crashes recover before and after evidence publication", { timeout: 60_000 }, async t => {
|
|
1709
|
+
for (const point of ["before-evidence", "after-evidence"]) {
|
|
1710
|
+
const outDir = seedSpacedOutput(["p1"], t);
|
|
1711
|
+
const pending = pendingEventDirectory(outDir);
|
|
1712
|
+
fs.mkdirSync(pending, { recursive: true });
|
|
1713
|
+
const invalidPath = path.join(pending, "broken café evidence.json");
|
|
1714
|
+
const invalidBytes = Buffer.from([0x7b, 0x22, 0x74, 0x6f, 0x72, 0x6e, 0x20, 0xff, 0x0a]);
|
|
1715
|
+
fs.writeFileSync(invalidPath, invalidBytes);
|
|
1716
|
+
const evidenceId = crypto.createHash("sha256")
|
|
1717
|
+
.update(`pending\0${path.basename(invalidPath)}\0`, "utf8")
|
|
1718
|
+
.update(invalidBytes)
|
|
1719
|
+
.digest("hex");
|
|
1720
|
+
const evidence = path.join(outDir, "waker.errors", `invalid-${evidenceId}.json`);
|
|
1721
|
+
const entered = path.join(outDir, `${point} entered`);
|
|
1722
|
+
const release = path.join(outDir, `${point} release`);
|
|
1723
|
+
const crashCode = point === "before-evidence" ? 95 : 96;
|
|
1724
|
+
const script = `
|
|
1725
|
+
import fs from "node:fs";
|
|
1726
|
+
import path from "node:path";
|
|
1727
|
+
import { claimWakerEvent, quarantineInvalidEvent } from ${JSON.stringify(moduleUrl)};
|
|
1728
|
+
const [outDir, point, invalidPath, evidence, entered, release, crashCodeText] = process.argv.slice(1);
|
|
1729
|
+
const cell = new Int32Array(new SharedArrayBuffer(4));
|
|
1730
|
+
const pauseAndExit = () => {
|
|
1731
|
+
fs.writeFileSync(entered, "entered");
|
|
1732
|
+
const until = Date.now() + 20000;
|
|
1733
|
+
while (!fs.existsSync(release) && Date.now() < until) Atomics.wait(cell, 0, 0, 5);
|
|
1734
|
+
if (!fs.existsSync(release)) throw new Error("quarantine crash barrier timed out");
|
|
1735
|
+
process.exit(Number(crashCodeText));
|
|
1736
|
+
};
|
|
1737
|
+
const originalRenameSync = fs.renameSync;
|
|
1738
|
+
fs.renameSync = function (from, to) {
|
|
1739
|
+
const result = originalRenameSync.call(fs, from, to);
|
|
1740
|
+
if (point === "before-evidence" && path.resolve(from) === path.resolve(invalidPath) &&
|
|
1741
|
+
path.basename(to).startsWith("waker.quarantining.")) pauseAndExit();
|
|
1742
|
+
return result;
|
|
1743
|
+
};
|
|
1744
|
+
const originalLinkSync = fs.linkSync;
|
|
1745
|
+
fs.linkSync = function (from, to) {
|
|
1746
|
+
const result = originalLinkSync.call(fs, from, to);
|
|
1747
|
+
if (point === "after-evidence" && path.resolve(to) === path.resolve(evidence)) pauseAndExit();
|
|
1748
|
+
return result;
|
|
1749
|
+
};
|
|
1750
|
+
const claimed = claimWakerEvent(outDir);
|
|
1751
|
+
if (!claimed?.invalid) throw new Error("invalid evidence was not returned");
|
|
1752
|
+
quarantineInvalidEvent(outDir, claimed.invalid, { now: 1 });
|
|
1753
|
+
throw new Error("crash point was not reached");
|
|
1754
|
+
`;
|
|
1755
|
+
const crashed = spawnBounded(t, [
|
|
1756
|
+
"--input-type=module", "-e", script,
|
|
1757
|
+
outDir, point, invalidPath, evidence, entered, release, String(crashCode),
|
|
1758
|
+
]);
|
|
1759
|
+
t.after(() => { if (fs.existsSync(outDir) && !fs.existsSync(release)) fs.writeFileSync(release, "cleanup"); });
|
|
1760
|
+
await waitForFile(entered);
|
|
1761
|
+
const holdings = fs.readdirSync(outDir).filter(name => name.startsWith("waker.quarantining."));
|
|
1762
|
+
assert.equal(holdings.length, 1, point);
|
|
1763
|
+
assert.deepEqual(fs.readFileSync(path.join(outDir, holdings[0])), invalidBytes, point);
|
|
1764
|
+
assert.equal(fs.existsSync(invalidPath), false, point);
|
|
1765
|
+
assert.equal(fs.existsSync(evidence), point === "after-evidence", point);
|
|
1766
|
+
if (point === "after-evidence") assert.deepEqual(fs.readFileSync(evidence), invalidBytes, point);
|
|
1767
|
+
assert.deepEqual(readJson(path.join(outDir, "waker.stop")), {
|
|
1768
|
+
plan_version: PLAN_VERSION,
|
|
1769
|
+
at: new Date(1).toISOString(),
|
|
1770
|
+
reason: "invalid-event",
|
|
1771
|
+
evidence_id: evidenceId,
|
|
1772
|
+
}, point);
|
|
1773
|
+
fs.writeFileSync(release, "go");
|
|
1774
|
+
const crashResult = await crashed;
|
|
1775
|
+
assert.equal(crashResult.code, crashCode, crashResult.stderr);
|
|
1776
|
+
|
|
1777
|
+
const recoveryScript = `
|
|
1778
|
+
import { claimWakerEvent, quarantineInvalidEvent } from ${JSON.stringify(moduleUrl)};
|
|
1779
|
+
const claimed = claimWakerEvent(process.argv[1]);
|
|
1780
|
+
if (!claimed?.invalid) throw new Error("quarantining recovery did not return invalid evidence");
|
|
1781
|
+
const outcome = quarantineInvalidEvent(process.argv[1], claimed.invalid, { now: 2 });
|
|
1782
|
+
process.stdout.write(JSON.stringify({
|
|
1783
|
+
location: claimed.invalid.location,
|
|
1784
|
+
evidenceId: claimed.invalid.evidenceId,
|
|
1785
|
+
outcome,
|
|
1786
|
+
}));
|
|
1787
|
+
`;
|
|
1788
|
+
const recovered = await spawnBounded(t, ["--input-type=module", "-e", recoveryScript, outDir]);
|
|
1789
|
+
assert.equal(recovered.code, 0, recovered.stderr);
|
|
1790
|
+
const recovery = JSON.parse(recovered.stdout);
|
|
1791
|
+
assert.equal(recovery.location, "quarantining", point);
|
|
1792
|
+
assert.equal(recovery.evidenceId, evidenceId, point);
|
|
1793
|
+
assert.equal(recovery.outcome.action, "hard-block", point);
|
|
1794
|
+
assert.equal(recovery.outcome.path, evidence, point);
|
|
1795
|
+
assert.deepEqual(fs.readFileSync(evidence), invalidBytes, point);
|
|
1796
|
+
assert.deepEqual(fs.readdirSync(path.join(outDir, "waker.errors")), [`invalid-${evidenceId}.json`], point);
|
|
1797
|
+
assert.equal(claimWakerEvent(outDir), null, point);
|
|
1798
|
+
assertQueueEmpty(outDir);
|
|
1799
|
+
}
|
|
1800
|
+
});
|
|
1801
|
+
|