@buaa_smat/hometrans 26.0.2 → 26.0.4-devecocli.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (1496) hide show
  1. package/agents/code-reviewer.md +111 -154
  2. package/devecocli-plugin/common.ts +2271 -0
  3. package/devecocli-plugin/content-resolver.ts +363 -0
  4. package/devecocli-plugin/install.ts +72 -0
  5. package/devecocli-plugin/uninstall.ts +26 -0
  6. package/devecocli-plugin/update.ts +77 -0
  7. package/i18n/FILE-NAMES.md +9 -0
  8. package/i18n/agents/code-reviewer.md +436 -0
  9. package/i18n/agents/model-render-worker.md +38 -0
  10. package/i18n/agents/specgen-worker.md +18 -0
  11. package/i18n/commands/hometrans.md +17 -0
  12. package/i18n/skills/a2h-app-migrate/SKILL.md +206 -0
  13. package/i18n/skills/a2h-app-migrate/references/config.example.json +28 -0
  14. package/i18n/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  15. package/i18n/skills/a2h-app-migrate/references/specs.example.json +19 -0
  16. package/i18n/skills/a2h-app-migrate/references/stage-map.md +50 -0
  17. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +2007 -0
  18. package/i18n/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +187 -0
  19. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1656 -0
  20. package/i18n/skills/a2h-app-migrate/scripts/human_review_gate.mjs +728 -0
  21. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +541 -0
  22. package/i18n/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  23. package/i18n/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  24. package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  25. package/i18n/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  26. package/i18n/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  27. package/i18n/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  28. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  29. package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  30. package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  31. package/i18n/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  32. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  33. package/i18n/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  34. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  35. package/i18n/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  36. package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  37. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  38. package/i18n/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  39. package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  40. package/i18n/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  41. package/i18n/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  42. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +207 -0
  43. package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  44. package/i18n/skills/a2h-arch-generate/SKILL.md +378 -0
  45. package/i18n/skills/a2h-arch-generate/examples/reconcile-existing-project.md +107 -0
  46. package/i18n/skills/a2h-arch-generate/examples/simple-conversion-backend.md +70 -0
  47. package/i18n/skills/a2h-arch-generate/references/arkts-mvvm-v2.md +1407 -0
  48. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.generate.md +120 -0
  49. package/i18n/skills/a2h-arch-generate/references/artifact-contracts.reconcile.md +123 -0
  50. package/i18n/skills/a2h-arch-generate/references/bpta-layered-architecture-design.md +88 -0
  51. package/i18n/skills/a2h-arch-generate/references/database-schema-recovery.md +107 -0
  52. package/i18n/skills/a2h-arch-generate/references/existing-target-annotation.md +68 -0
  53. package/i18n/skills/a2h-arch-generate/references/harmony-project-inspection.md +150 -0
  54. package/i18n/skills/a2h-arch-generate/references/harmony-target-architecture.md +94 -0
  55. package/i18n/skills/a2h-arch-generate/references/homegraph-workflow.md +131 -0
  56. package/i18n/skills/a2h-arch-generate/references/source-baseline.md +93 -0
  57. package/i18n/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +360 -0
  58. package/i18n/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +798 -0
  59. package/i18n/skills/a2h-arch-generate/scripts/lib/contract_terms.mjs +40 -0
  60. package/i18n/skills/a2h-arch-generate/scripts/module_create/generate.mjs +639 -0
  61. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/reconcile-layer-PROJECT_DESIGN.md +47 -0
  62. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/single-entry-PROJECT_DESIGN.md +15 -0
  63. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/three-layer-PROJECT_DESIGN.md +36 -0
  64. package/i18n/skills/a2h-arch-generate/scripts/module_create/testdata/verification-report.md +150 -0
  65. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  66. package/i18n/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  67. package/i18n/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1261 -0
  68. package/i18n/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  69. package/i18n/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +851 -0
  70. package/i18n/skills/a2h-arch-generate/scripts/validate_data_docs.mjs +982 -0
  71. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +304 -0
  72. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +10 -0
  73. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +249 -0
  74. package/i18n/skills/a2h-arkts-logic-coder/references/spec-design.md +344 -0
  75. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/move_spec_technical_reference.mjs +162 -0
  76. package/i18n/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +298 -0
  77. package/i18n/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +877 -0
  78. package/i18n/skills/a2h-arkts-logic-coder/scripts/test_check_units.ts +149 -0
  79. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  80. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  81. package/i18n/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  82. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  83. package/i18n/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  84. package/i18n/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  85. package/i18n/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +597 -0
  86. package/i18n/skills/a2h-batch-ui-align/SKILL.md +372 -0
  87. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +35 -0
  88. package/i18n/skills/a2h-batch-ui-align/references/cards/build.md +13 -0
  89. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +17 -0
  90. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +27 -0
  91. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +85 -0
  92. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +23 -0
  93. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +89 -0
  94. package/i18n/skills/a2h-batch-ui-align/references/cards/state-v1.md +29 -0
  95. package/i18n/skills/a2h-batch-ui-align/references/cards/state.md +14 -0
  96. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +62 -0
  97. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +30 -0
  98. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +930 -0
  99. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +420 -0
  100. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +158 -0
  101. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +43 -0
  102. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +2552 -0
  103. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +560 -0
  104. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +175 -0
  105. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_decorator-quickref.md +251 -0
  106. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +28 -0
  107. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +232 -0
  108. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +206 -0
  109. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +232 -0
  110. package/i18n/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +2005 -0
  111. package/i18n/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  112. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +2118 -0
  113. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +79 -0
  114. package/i18n/skills/a2h-batch-ui-align/scripts/detect_paradigm.mjs +245 -0
  115. package/i18n/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  116. package/i18n/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +1805 -0
  117. package/i18n/skills/a2h-batch-ui-align/scripts/gen_rule_docs.mjs +100 -0
  118. package/i18n/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +612 -0
  119. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +1959 -0
  120. package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  121. package/i18n/skills/a2h-batch-ui-align/scripts/image_probe.mjs +405 -0
  122. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +1632 -0
  123. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +1300 -0
  124. package/i18n/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +1234 -0
  125. package/i18n/skills/a2h-batch-ui-align/scripts/state_doc.mjs +417 -0
  126. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/cli.ts +134 -0
  127. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +18 -0
  128. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +216 -0
  129. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +615 -0
  130. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +125 -0
  131. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +49 -0
  132. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/block_comment_break.ts +64 -0
  133. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +134 -0
  134. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_call_sites.ts +242 -0
  135. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +136 -0
  136. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/canvas.ts +255 -0
  137. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +109 -0
  138. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/column_shrink.ts +154 -0
  139. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +39 -0
  140. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/container_align.ts +140 -0
  141. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  142. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_root_builtin.ts +69 -0
  143. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/entry_route.ts +114 -0
  144. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  145. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/fixed_size_safe_area.ts +103 -0
  146. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/format_string.ts +157 -0
  147. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  148. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +115 -0
  149. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  150. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  151. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  152. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +780 -0
  153. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  154. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +138 -0
  155. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +408 -0
  156. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/offset_in_scroll.ts +163 -0
  157. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/orphan_component.ts +119 -0
  158. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  159. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  160. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  161. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/page_reachability.ts +94 -0
  162. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/path_commands_vp.ts +50 -0
  163. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +81 -0
  164. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +137 -0
  165. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/r_template_string.ts +37 -0
  166. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  167. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/request_permission.ts +98 -0
  168. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/resource_as_string.ts +68 -0
  169. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +147 -0
  170. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  171. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/safe_area_clipping.ts +168 -0
  172. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +127 -0
  173. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  174. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sdk_api.ts +195 -0
  175. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shared_chrome.ts +73 -0
  176. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_blur.ts +95 -0
  177. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/shell_content.ts +198 -0
  178. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/stack_occluding.ts +118 -0
  179. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_decorators.ts +73 -0
  180. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/state_name_shadows.ts +93 -0
  181. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/string_quote_leak.ts +73 -0
  182. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/surface_stroke.ts +50 -0
  183. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  184. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  185. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/track_getter.ts +132 -0
  186. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  187. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +53 -0
  188. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +67 -0
  189. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  190. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  191. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  192. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  193. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  194. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  195. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  196. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  197. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  198. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  199. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  200. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  201. package/i18n/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  202. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  203. package/i18n/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +245 -0
  204. package/i18n/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  205. package/i18n/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  206. package/i18n/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  207. package/i18n/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  208. package/i18n/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  209. package/i18n/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  210. package/i18n/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  211. package/i18n/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  212. package/i18n/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  213. package/i18n/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  214. package/i18n/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  215. package/i18n/skills/a2h-batch-ui-align/scripts/text_color_diff.mjs +470 -0
  216. package/i18n/skills/a2h-coldstart-smoke-gate/SKILL.md +62 -0
  217. package/i18n/skills/a2h-dashboard-render/SKILL.md +73 -0
  218. package/i18n/skills/a2h-dashboard-render/references/artifact-contract.jsonc +117 -0
  219. package/i18n/skills/a2h-dashboard-render/references/artifact-registry-spec.md +67 -0
  220. package/i18n/skills/a2h-dashboard-render/references/dashboard-guide.md +91 -0
  221. package/i18n/skills/a2h-dashboard-render/references/dashboard.config.example.json +19 -0
  222. package/i18n/skills/a2h-dashboard-render/scripts/dashboard.mjs +3245 -0
  223. package/i18n/skills/a2h-dashboard-render/scripts/device_capture.mjs +2050 -0
  224. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  225. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  226. package/i18n/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  227. package/i18n/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  228. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  229. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  230. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +154 -0
  231. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  232. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  233. package/i18n/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  234. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  235. package/i18n/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  236. package/i18n/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  237. package/i18n/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  238. package/i18n/skills/a2h-fix-build-errors/SKILL.md +304 -0
  239. package/i18n/skills/a2h-fix-build-errors/references/arkts-strict-patterns.md +219 -0
  240. package/i18n/skills/a2h-fix-build-errors/references/rdb-entity-pattern.md +131 -0
  241. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +265 -0
  242. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  243. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  244. package/i18n/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  245. package/i18n/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  246. package/i18n/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  247. package/i18n/skills/a2h-page-specgen/SKILL.md +239 -0
  248. package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +1174 -0
  249. package/i18n/skills/a2h-page-specgen/references/body-language.md +179 -0
  250. package/i18n/skills/a2h-page-specgen/references/gates.md +329 -0
  251. package/i18n/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  252. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +274 -0
  253. package/i18n/skills/a2h-page-specgen/references/spec-example.md +312 -0
  254. package/i18n/skills/a2h-page-specgen/references/spec-template.md +210 -0
  255. package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  256. package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  257. package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  258. package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  259. package/i18n/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  260. package/i18n/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  261. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  262. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +864 -0
  263. package/i18n/skills/a2h-page-specgen/scripts/interactions.mjs +346 -0
  264. package/i18n/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  265. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  266. package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  267. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +684 -0
  268. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  269. package/i18n/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  270. package/i18n/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  271. package/i18n/skills/a2h-page-specgen/scripts/lib/prose.mjs +252 -0
  272. package/i18n/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  273. package/i18n/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  274. package/i18n/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  275. package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  276. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +864 -0
  277. package/i18n/skills/a2h-page-specgen/scripts/render.mjs +276 -0
  278. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +897 -0
  279. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +25 -0
  280. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +373 -0
  281. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +300 -0
  282. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +47 -0
  283. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +373 -0
  284. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +300 -0
  285. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  286. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  287. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  288. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +373 -0
  289. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  290. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +267 -0
  291. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +57 -0
  292. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +373 -0
  293. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +300 -0
  294. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  295. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  296. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  297. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  298. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  299. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +553 -0
  300. package/i18n/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  301. package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  302. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +546 -0
  303. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +655 -0
  304. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1234 -0
  305. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +520 -0
  306. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1516 -0
  307. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +759 -0
  308. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +630 -0
  309. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +118 -0
  310. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +798 -0
  311. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +886 -0
  312. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  313. package/i18n/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  314. package/i18n/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1205 -0
  315. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +271 -0
  316. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +8 -0
  317. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +7 -0
  318. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +8 -0
  319. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  320. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  321. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  322. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  323. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  324. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  325. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  326. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  327. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  328. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  329. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  330. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  331. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  332. package/i18n/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  333. package/i18n/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  334. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1121 -0
  335. package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  336. package/i18n/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  337. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  338. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  339. package/i18n/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  340. package/i18n/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  341. package/i18n/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +348 -0
  342. package/i18n/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  343. package/i18n/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  344. package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  345. package/i18n/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  346. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  347. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  348. package/i18n/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  349. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +240 -0
  350. package/i18n/skills/a2h-page-specgen/scripts/test/prose.test.mjs +427 -0
  351. package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  352. package/i18n/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  353. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  354. package/i18n/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  355. package/i18n/skills/a2h-page-specgen/scripts/test/render.test.mjs +536 -0
  356. package/i18n/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  357. package/i18n/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  358. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1239 -0
  359. package/i18n/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  360. package/i18n/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  361. package/i18n/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  362. package/i18n/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  363. package/i18n/skills/a2h-resource-convert/SKILL.md +375 -0
  364. package/i18n/skills/a2h-resource-convert/references/code-vector-icon-rules.md +336 -0
  365. package/i18n/skills/a2h-resource-convert/references/incremental-page-migration.md +272 -0
  366. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +226 -0
  367. package/i18n/skills/a2h-resource-convert/references/resource-mapping-rules.md +493 -0
  368. package/i18n/skills/a2h-resource-convert/references/step4-resource-types.md +251 -0
  369. package/i18n/skills/a2h-resource-convert/references/step7-report-template.md +217 -0
  370. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +2596 -0
  371. package/i18n/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  372. package/i18n/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  373. package/i18n/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  374. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +238 -0
  375. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +358 -0
  376. package/i18n/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +307 -0
  377. package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +103 -0
  378. package/i18n/skills/a2h-spec-design-pipeline/references/merge-queue.md +266 -0
  379. package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  380. package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +71 -0
  381. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +55 -0
  382. package/i18n/skills/a2h-spec-design-pipeline/references/specs.example.json +19 -0
  383. package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +246 -0
  384. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +752 -0
  385. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +661 -0
  386. package/i18n/skills/a2h-spec-generate/SKILL.md +375 -0
  387. package/i18n/skills/a2h-spec-generate/references/batch-mode.md +215 -0
  388. package/i18n/skills/a2h-spec-generate/references/delete-blast-radius.md +3 -0
  389. package/i18n/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  390. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +184 -0
  391. package/i18n/skills/a2h-spec-generate/references/input-formats.md +27 -0
  392. package/i18n/skills/a2h-spec-generate/references/library-evidence.md +3 -0
  393. package/i18n/skills/a2h-spec-generate/references/method-discipline.md +64 -0
  394. package/i18n/skills/a2h-spec-generate/references/optional-gates.json +45 -0
  395. package/i18n/skills/a2h-spec-generate/references/recall-guide.md +84 -0
  396. package/i18n/skills/a2h-spec-generate/references/recall-terse.md +3 -0
  397. package/i18n/skills/a2h-spec-generate/references/recall-uniapp.md +10 -0
  398. package/i18n/skills/a2h-spec-generate/references/requirement-scope.md +122 -0
  399. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +22 -0
  400. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +80 -0
  401. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +43 -0
  402. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +65 -0
  403. package/i18n/skills/a2h-spec-generate/references/specs.schema.json +85 -0
  404. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +145 -0
  405. package/i18n/skills/a2h-spec-generate/references/transfer-file.md +5 -0
  406. package/i18n/skills/a2h-spec-generate/references/transfer-socket.md +5 -0
  407. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +129 -0
  408. package/i18n/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +702 -0
  409. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +515 -0
  410. package/i18n/skills/a2h-spec-generate/scripts/collect-specs.mjs +727 -0
  411. package/i18n/skills/a2h-spec-generate/scripts/feature-stem.mjs +151 -0
  412. package/i18n/skills/a2h-spec-generate/scripts/parse_requirements.ts +515 -0
  413. package/i18n/skills/a2h-spec-generate/scripts/prepare-facts.mjs +313 -0
  414. package/i18n/skills/a2h-spec-generate/scripts/publish-specs.mjs +354 -0
  415. package/i18n/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +669 -0
  416. package/i18n/skills/a2h-spec-generate/scripts/render-tasks.mjs +385 -0
  417. package/i18n/skills/a2h-spec-generate/scripts/report.mjs +136 -0
  418. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +2217 -0
  419. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +845 -0
  420. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +572 -0
  421. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +580 -0
  422. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +1265 -0
  423. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +1057 -0
  424. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +565 -0
  425. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +544 -0
  426. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  427. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/schema.ts +317 -0
  428. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/selfcheck.ts +707 -0
  429. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/spec-bindings.ts +436 -0
  430. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +608 -0
  431. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +650 -0
  432. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +178 -0
  433. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +923 -0
  434. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +912 -0
  435. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +279 -0
  436. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +163 -0
  437. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1039 -0
  438. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +256 -0
  439. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  440. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +576 -0
  441. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  442. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  443. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  444. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  445. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +340 -0
  446. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1857 -0
  447. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +262 -0
  448. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +722 -0
  449. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  450. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  451. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  452. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  453. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  454. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  455. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  456. package/i18n/skills/a2h-spec-generate/template/REQ.txt +22 -0
  457. package/i18n/skills/a2h-spec-generate/template/REQ.xlsx +0 -0
  458. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +847 -0
  459. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +415 -0
  460. package/i18n/skills/a2h-spec-generate/test/collect-specs.test.mjs +808 -0
  461. package/i18n/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  462. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  463. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  464. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  465. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  466. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  467. package/i18n/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  468. package/i18n/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  469. package/i18n/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  470. package/i18n/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  471. package/i18n/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  472. package/i18n/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  473. package/i18n/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  474. package/i18n/skills/a2h-utg-explorer/SKILL.md +126 -0
  475. package/i18n/skills/a2h-utg-explorer/references/architecture.md +282 -0
  476. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +908 -0
  477. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +446 -0
  478. package/i18n/skills/a2h-utg-explorer/scripts/hint_check.mjs +147 -0
  479. package/i18n/skills/a2h-utg-explorer/scripts/hint_source.mjs +119 -0
  480. package/i18n/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  481. package/i18n/skills/a2h-utg-explorer/scripts/recover_b.mjs +550 -0
  482. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +647 -0
  483. package/i18n/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  484. package/i18n/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  485. package/i18n/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  486. package/i18n/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  487. package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +252 -0
  488. package/i18n/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  489. package/i18n/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  490. package/i18n/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  491. package/i18n/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  492. package/i18n/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  493. package/i18n/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  494. package/i18n/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  495. package/i18n/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  496. package/i18n/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  497. package/i18n/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  498. package/i18n/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  499. package/i18n/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  500. package/i18n/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  501. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  502. package/i18n/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  503. package/i18n/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  504. package/i18n/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  505. package/i18n/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  506. package/i18n/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  507. package/i18n/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  508. package/i18n/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  509. package/i18n/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  510. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  511. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  512. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +1562 -0
  513. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  514. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +2714 -0
  515. package/i18n/skills/a2h-utg-static/SKILL.md +372 -0
  516. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +248 -0
  517. package/i18n/skills/a2h-utg-static/references/view-interactions.md +215 -0
  518. package/i18n/skills/a2h-utg-static/scripts/assemble.mjs +2190 -0
  519. package/i18n/skills/a2h-utg-static/scripts/audit.mjs +268 -0
  520. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +720 -0
  521. package/i18n/skills/a2h-utg-static/scripts/compose_body_text.mjs +250 -0
  522. package/i18n/skills/a2h-utg-static/scripts/compose_titles.mjs +374 -0
  523. package/i18n/skills/a2h-utg-static/scripts/compose_widgets.mjs +498 -0
  524. package/i18n/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  525. package/i18n/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  526. package/i18n/skills/a2h-utg-static/scripts/fragment_nav.mjs +1137 -0
  527. package/i18n/skills/a2h-utg-static/scripts/hybrid_scope.mjs +705 -0
  528. package/i18n/skills/a2h-utg-static/scripts/interaction_sites.mjs +267 -0
  529. package/i18n/skills/a2h-utg-static/scripts/label_resolve.mjs +958 -0
  530. package/i18n/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  531. package/i18n/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  532. package/i18n/skills/a2h-utg-static/scripts/nl_hints.mjs +545 -0
  533. package/i18n/skills/a2h-utg-static/scripts/presenter_nav.mjs +490 -0
  534. package/i18n/skills/a2h-utg-static/scripts/static_prior.mjs +956 -0
  535. package/i18n/skills/a2h-utg-static/scripts/tests/regression_matrix.mjs +1261 -0
  536. package/i18n/skills/a2h-utg-static/scripts/tests/test_callee_string_default.mjs +30 -0
  537. package/i18n/skills/a2h-utg-static/scripts/tests/test_chrome_tokens.mjs +60 -0
  538. package/i18n/skills/a2h-utg-static/scripts/tests/test_commented_out_trigger.mjs +111 -0
  539. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +125 -0
  540. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_vm_nav.mjs +289 -0
  541. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  542. package/i18n/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +113 -0
  543. package/i18n/skills/a2h-utg-static/scripts/tests/test_disabled_guard.mjs +42 -0
  544. package/i18n/skills/a2h-utg-static/scripts/tests/test_drawer_panel_gesture.mjs +140 -0
  545. package/i18n/skills/a2h-utg-static/scripts/tests/test_fresh_branch_guard.mjs +49 -0
  546. package/i18n/skills/a2h-utg-static/scripts/tests/test_hint_language.mjs +136 -0
  547. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundle_attribution.mjs +74 -0
  548. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_bundled_pages.mjs +181 -0
  549. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  550. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +457 -0
  551. package/i18n/skills/a2h-utg-static/scripts/tests/test_hybrid_title_renders.mjs +118 -0
  552. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_accessor_forms.mjs +187 -0
  553. package/i18n/skills/a2h-utg-static/scripts/tests/test_label_source.mjs +70 -0
  554. package/i18n/skills/a2h-utg-static/scripts/tests/test_launch_intent_guard.mjs +67 -0
  555. package/i18n/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +368 -0
  556. package/i18n/skills/a2h-utg-static/scripts/tests/test_mode_and_cb_param.mjs +172 -0
  557. package/i18n/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +78 -0
  558. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hint_grammar.mjs +42 -0
  559. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_gate.mjs +85 -0
  560. package/i18n/skills/a2h-utg-static/scripts/tests/test_nl_hints_off_path.mjs +67 -0
  561. package/i18n/skills/a2h-utg-static/scripts/tests/test_non_gesture_step_flag.mjs +62 -0
  562. package/i18n/skills/a2h-utg-static/scripts/tests/test_preference_widgets.mjs +48 -0
  563. package/i18n/skills/a2h-utg-static/scripts/tests/test_read_text_crlf.mjs +41 -0
  564. package/i18n/skills/a2h-utg-static/scripts/tests/test_sealed_dialog_state.mjs +148 -0
  565. package/i18n/skills/a2h-utg-static/scripts/tests/test_state_specific_hop.mjs +130 -0
  566. package/i18n/skills/a2h-utg-static/scripts/tests/test_synthetic_label_identity.mjs +51 -0
  567. package/i18n/skills/a2h-utg-static/scripts/tests/test_template_title.mjs +61 -0
  568. package/i18n/skills/a2h-utg-static/scripts/tests/test_ui_elements_flow_filter.mjs +110 -0
  569. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_data_table.mjs +340 -0
  570. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_relative_url.mjs +125 -0
  571. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  572. package/i18n/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +330 -0
  573. package/i18n/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  574. package/i18n/skills/a2h-utg-static/scripts/tests/test_viewpage_nav.mjs +340 -0
  575. package/i18n/skills/a2h-utg-static/scripts/uniapp_nav.mjs +1394 -0
  576. package/i18n/skills/a2h-utg-static/scripts/uniapp_widgets.mjs +244 -0
  577. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +769 -0
  578. package/index.js +1643 -0
  579. package/package.json +18 -168
  580. package/platforms/deveco/agents/code-reviewer.frontmatter.md +1 -1
  581. package/platforms/opencode/agents/code-reviewer.frontmatter.md +1 -1
  582. package/plugin.jsonc +12 -0
  583. package/skills/a2h-app-migrate/SKILL.md +31 -12
  584. package/skills/a2h-app-migrate/references/config.example.json +1 -0
  585. package/skills/a2h-app-migrate/references/feature-scope.md +121 -0
  586. package/skills/a2h-app-migrate/references/stage-map.md +4 -2
  587. package/skills/a2h-app-migrate/references/workflow.yaml +427 -103
  588. package/skills/a2h-app-migrate/scripts/android_index.mjs +35 -8
  589. package/skills/a2h-app-migrate/scripts/check_module_docs_done.mjs +39 -1
  590. package/skills/a2h-app-migrate/scripts/check_spec_gen_done.mjs +78 -6
  591. package/skills/a2h-app-migrate/scripts/check_spec_pipeline_done.mjs +144 -9
  592. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +14 -1
  593. package/skills/a2h-app-migrate/scripts/check_utg_static_done.mjs +46 -5
  594. package/skills/a2h-app-migrate/scripts/diagnose.mjs +162 -0
  595. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +178 -44
  596. package/skills/a2h-app-migrate/scripts/feature_scope.mjs +347 -0
  597. package/skills/a2h-app-migrate/scripts/human_review_gate.mjs +81 -11
  598. package/skills/a2h-app-migrate/scripts/infer_android_root.mjs +17 -1
  599. package/skills/a2h-app-migrate/scripts/ledger.mjs +80 -10
  600. package/skills/a2h-app-migrate/scripts/migration_manifest.mjs +351 -0
  601. package/skills/a2h-app-migrate/scripts/paths_preflight.mjs +9 -23
  602. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +72 -12
  603. package/skills/a2h-app-migrate/scripts/reuse_static_utg.mjs +33 -1
  604. package/skills/a2h-app-migrate/scripts/run_dir.mjs +137 -41
  605. package/skills/a2h-app-migrate/scripts/scope_model.mjs +255 -0
  606. package/skills/a2h-app-migrate/scripts/scope_report.mjs +128 -0
  607. package/skills/a2h-app-migrate/scripts/source_fp.mjs +120 -0
  608. package/skills/a2h-app-migrate/scripts/spec_layout.mjs +2 -0
  609. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +38 -0
  610. package/skills/a2h-app-migrate/test/test_android_index.mjs +143 -0
  611. package/skills/a2h-app-migrate/test/test_apk_preflight.mjs +63 -0
  612. package/skills/a2h-app-migrate/test/test_arch_done.mjs +54 -0
  613. package/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +98 -0
  614. package/skills/a2h-app-migrate/test/test_config_example.mjs +42 -0
  615. package/skills/a2h-app-migrate/test/test_devecocli_docs_preflight.mjs +32 -0
  616. package/skills/a2h-app-migrate/test/test_ensure_utg_snapshot.mjs +147 -0
  617. package/skills/a2h-app-migrate/test/test_entry_guards.mjs +102 -0
  618. package/skills/a2h-app-migrate/test/test_env_requirements.mjs +713 -0
  619. package/skills/a2h-app-migrate/test/test_feature_scope.mjs +217 -0
  620. package/skills/a2h-app-migrate/test/test_finalize.mjs +117 -0
  621. package/skills/a2h-app-migrate/test/test_gate_checkpoint.mjs +146 -0
  622. package/skills/a2h-app-migrate/test/test_hmos_fingerprint.mjs +68 -0
  623. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +51 -0
  624. package/skills/a2h-app-migrate/test/test_image_probe.mjs +120 -0
  625. package/skills/a2h-app-migrate/test/test_incremental_acceptance.mjs +145 -0
  626. package/skills/a2h-app-migrate/test/test_incremental_phase2.mjs +223 -0
  627. package/skills/a2h-app-migrate/test/test_incremental_phase2_acceptance.mjs +157 -0
  628. package/skills/a2h-app-migrate/test/test_incremental_profile.mjs +84 -0
  629. package/skills/a2h-app-migrate/test/test_infer_android_root.mjs +101 -0
  630. package/skills/a2h-app-migrate/test/test_interaction.mjs +122 -0
  631. package/skills/a2h-app-migrate/test/test_json_io.mjs +32 -0
  632. package/skills/a2h-app-migrate/test/test_leaf_questions.mjs +150 -0
  633. package/skills/a2h-app-migrate/test/test_migration_manifest.mjs +225 -0
  634. package/skills/a2h-app-migrate/test/test_module_docs_done.mjs +86 -0
  635. package/skills/a2h-app-migrate/test/test_parse_args.mjs +69 -0
  636. package/skills/a2h-app-migrate/test/test_preflight_report.mjs +93 -0
  637. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +271 -0
  638. package/skills/a2h-app-migrate/test/test_resume_summary.mjs +222 -0
  639. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +136 -0
  640. package/skills/a2h-app-migrate/test/test_run_dir.mjs +552 -0
  641. package/skills/a2h-app-migrate/test/test_scope_model.mjs +172 -0
  642. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +144 -0
  643. package/skills/a2h-app-migrate/test/test_spec_engine_acceptance.mjs +94 -0
  644. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +155 -0
  645. package/skills/a2h-app-migrate/test/test_spec_gen_done.mjs +263 -0
  646. package/skills/a2h-app-migrate/test/test_spec_gen_gate.mjs +165 -0
  647. package/skills/a2h-app-migrate/test/test_spec_pipeline_done.mjs +511 -0
  648. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +76 -0
  649. package/skills/a2h-app-migrate/test/test_ui_batch_capture_audit.mjs +106 -0
  650. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +65 -0
  651. package/skills/a2h-app-migrate/test/test_ui_batch_gate.mjs +226 -0
  652. package/skills/a2h-app-migrate/test/test_uniapp_preflight.mjs +83 -0
  653. package/skills/a2h-app-migrate/test/test_user_facing_progress.mjs +43 -0
  654. package/skills/a2h-app-migrate/test/test_utg_dirs.mjs +41 -0
  655. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +214 -0
  656. package/skills/a2h-app-migrate/test/test_validate_races.mjs +50 -0
  657. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +87 -0
  658. package/skills/a2h-arch-generate/SKILL.md +20 -17
  659. package/skills/a2h-arch-generate/references/database-schema-recovery.md +2 -2
  660. package/skills/a2h-arch-generate/references/harmony-project-inspection.md +8 -8
  661. package/skills/a2h-arch-generate/references/homegraph-workflow.md +25 -14
  662. package/skills/a2h-arch-generate/references/module-evidence-subagent.md +2 -2
  663. package/skills/a2h-arch-generate/references/source-baseline.md +4 -4
  664. package/skills/a2h-arch-generate/scripts/cleanup_intermediates.mjs +34 -3
  665. package/skills/a2h-arch-generate/scripts/create_project.mjs +24 -1
  666. package/skills/a2h-arch-generate/scripts/generate_source_baseline.mjs +35 -46
  667. package/skills/a2h-arch-generate/scripts/inspect_and_route.mjs +29 -5
  668. package/skills/a2h-arch-generate/scripts/inspect_harmony_target.mjs +33 -40
  669. package/skills/a2h-arch-generate/scripts/module_create/generate.mjs +2 -3
  670. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/build.gradle +11 -0
  671. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/AndroidManifest.xml +12 -0
  672. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/MainActivity.kt +8 -0
  673. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/app/src/main/java/com/example/notes/NotesStore.kt +17 -0
  674. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/build.gradle +3 -0
  675. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/android_source/settings.gradle +1 -0
  676. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/AppScope/app.json5 +8 -0
  677. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/build-profile.json5 +14 -0
  678. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/build-profile.json5 +7 -0
  679. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/oh-package.json5 +1 -0
  680. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/common/utils/src/main/ets/utils/Format.ets +3 -0
  681. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/build-profile.json5 +7 -0
  682. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/oh-package.json5 +1 -0
  683. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/home/src/main/ets/pages/Home.ets +3 -0
  684. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/build-profile.json5 +7 -0
  685. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/oh-package.json5 +1 -0
  686. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/features/sync/src/main/ets/engine/SyncEngine.ets +3 -0
  687. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/hvigorfile.ts +1 -0
  688. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/oh-package.json5 +1 -0
  689. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/build-profile.json5 +7 -0
  690. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/oh-package.json5 +9 -0
  691. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/harmony_target/products/app/src/main/ets/pages/Index.ets +7 -0
  692. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/App.vue +10 -0
  693. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/manifest.json +6 -0
  694. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages/index/index.vue +16 -0
  695. package/skills/a2h-arch-generate/scripts/tests/e2e/fixtures/uniapp_source/pages.json +5 -0
  696. package/skills/a2h-arch-generate/scripts/tests/e2e/run_e2e.mjs +548 -0
  697. package/skills/a2h-arch-generate/scripts/tests/run_tests.mjs +1260 -0
  698. package/skills/a2h-arch-generate/scripts/tests/test_cleanup.mjs +208 -0
  699. package/skills/a2h-arch-generate/scripts/tests/test_console_encoding.mjs +52 -0
  700. package/skills/a2h-arch-generate/scripts/tests/test_git_root.mjs +34 -0
  701. package/skills/a2h-arch-generate/scripts/tests/test_module_templates.mjs +70 -0
  702. package/skills/a2h-arch-generate/scripts/tests/test_router.mjs +164 -0
  703. package/skills/a2h-arch-generate/scripts/validate_architecture_docs.mjs +2 -5
  704. package/skills/a2h-arch-generate/scripts/validate_incremental_docs.mjs +4 -2
  705. package/skills/a2h-arkts-logic-coder/SKILL.md +163 -15
  706. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +3 -1
  707. package/skills/a2h-arkts-logic-coder/references/code-generation.md +120 -1
  708. package/skills/a2h-arkts-logic-coder/references/spec-design.md +46 -11
  709. package/skills/a2h-arkts-logic-coder/scripts/design/validate_spec_design_output.mjs +22 -25
  710. package/skills/a2h-arkts-logic-coder/scripts/state_doc.mjs +873 -0
  711. package/skills/a2h-arkts-logic-coder/test/golden/inspect_happy.json +20 -0
  712. package/skills/a2h-arkts-logic-coder/test/golden/move_design.md +18 -0
  713. package/skills/a2h-arkts-logic-coder/test/golden/move_design_crlf.md +18 -0
  714. package/skills/a2h-arkts-logic-coder/test/golden/move_spec.md +7 -0
  715. package/skills/a2h-arkts-logic-coder/test/golden/resolve_cases.json +36 -0
  716. package/skills/a2h-arkts-logic-coder/test/golden/validate_issue_file.md +12 -0
  717. package/skills/a2h-arkts-logic-coder/test/golden/validate_issues.json +57 -0
  718. package/skills/a2h-arkts-logic-coder/test/test_spec_design_scripts.mjs +547 -0
  719. package/skills/a2h-arkts-logic-coder/test/test_state_doc.mjs +596 -0
  720. package/skills/a2h-batch-ui-align/SKILL.md +78 -26
  721. package/skills/a2h-batch-ui-align/assets/ColorUtils.ets +16 -2
  722. package/skills/a2h-batch-ui-align/references/cards/alignment.md +5 -1
  723. package/skills/a2h-batch-ui-align/references/cards/geometry.md +6 -1
  724. package/skills/a2h-batch-ui-align/references/cards/interaction.md +2 -1
  725. package/skills/a2h-batch-ui-align/references/cards/resources.md +9 -3
  726. package/skills/a2h-batch-ui-align/references/cards/widgets.md +27 -3
  727. package/skills/a2h-batch-ui-align/references/cards/window.md +2 -1
  728. package/skills/a2h-batch-ui-align/references/checker-rules.md +301 -13
  729. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +53 -13
  730. package/skills/a2h-batch-ui-align/references/host-dispatch.md +2 -0
  731. package/skills/a2h-batch-ui-align/references/incremental-scope.md +28 -9
  732. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +14 -9
  733. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +2 -2
  734. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +28 -1
  735. 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
  736. package/skills/a2h-batch-ui-align/references/step3-capture.md +25 -6
  737. package/skills/a2h-batch-ui-align/references/step4-prepare.md +7 -2
  738. package/skills/a2h-batch-ui-align/references/step5-convert.md +33 -9
  739. package/skills/a2h-batch-ui-align/scripts/android_parse_fast.ts +6 -7
  740. package/skills/a2h-batch-ui-align/scripts/branch_coverage.mjs +155 -0
  741. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +463 -22
  742. package/skills/a2h-batch-ui-align/scripts/capture_audit.mjs +474 -0
  743. package/skills/a2h-batch-ui-align/scripts/capture_fast.mjs +665 -0
  744. package/skills/a2h-batch-ui-align/scripts/capture_verify.mjs +552 -0
  745. package/skills/a2h-batch-ui-align/scripts/detach.mjs +5 -2
  746. package/skills/a2h-batch-ui-align/scripts/draw_coverage.mjs +264 -0
  747. package/skills/a2h-batch-ui-align/scripts/evidence_gate.mjs +263 -0
  748. package/skills/a2h-batch-ui-align/scripts/export_ui_info.mjs +20 -3
  749. package/skills/a2h-batch-ui-align/scripts/generate_pages_json.mjs +4 -5
  750. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +220 -35
  751. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +517 -41
  752. package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +147 -0
  753. package/skills/a2h-batch-ui-align/scripts/image_probe.mjs +231 -54
  754. package/skills/a2h-batch-ui-align/scripts/list_existing.mjs +141 -0
  755. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +239 -14
  756. package/skills/a2h-batch-ui-align/scripts/page_gap.mjs +210 -0
  757. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +98 -11
  758. package/skills/a2h-batch-ui-align/scripts/progress_identity.mjs +208 -0
  759. package/skills/a2h-batch-ui-align/scripts/scroll_verdict.mjs +62 -0
  760. package/skills/a2h-batch-ui-align/scripts/shell_contract.mjs +118 -4
  761. package/skills/a2h-batch-ui-align/scripts/shell_requests.mjs +273 -0
  762. package/skills/a2h-batch-ui-align/scripts/state_doc.mjs +9 -4
  763. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +231 -0
  764. package/skills/a2h-batch-ui-align/scripts/static_check/core/baseline.ts +79 -0
  765. package/skills/a2h-batch-ui-align/scripts/static_check/core/i18n.ts +1 -5
  766. package/skills/a2h-batch-ui-align/scripts/static_check/core/parse.ts +90 -2
  767. package/skills/a2h-batch-ui-align/scripts/static_check/core/scan.ts +44 -0
  768. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +61 -12
  769. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +32 -0
  770. package/skills/a2h-batch-ui-align/scripts/static_check/rules/a11y.ts +3 -17
  771. package/skills/a2h-batch-ui-align/scripts/static_check/rules/android_immersive.ts +3 -3
  772. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +1 -19
  773. package/skills/a2h-batch-ui-align/scripts/static_check/rules/blur_mirrored.ts +2 -2
  774. package/skills/a2h-batch-ui-align/scripts/static_check/rules/builder_invokes_callback.ts +84 -19
  775. package/skills/a2h-batch-ui-align/scripts/static_check/rules/color_string.ts +11 -4
  776. package/skills/a2h-batch-ui-align/scripts/static_check/rules/constant_coordinate.ts +2 -2
  777. package/skills/a2h-batch-ui-align/scripts/static_check/rules/dialog_backboard.ts +91 -0
  778. package/skills/a2h-batch-ui-align/scripts/static_check/rules/event_default_click.ts +179 -0
  779. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_dialog.ts +110 -0
  780. package/skills/a2h-batch-ui-align/scripts/static_check/rules/framework_picker.ts +5 -5
  781. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +339 -0
  782. package/skills/a2h-batch-ui-align/scripts/static_check/rules/image_source.ts +84 -0
  783. package/skills/a2h-batch-ui-align/scripts/static_check/rules/input_traps.ts +249 -0
  784. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +234 -5
  785. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_host.ts +145 -0
  786. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_content.ts +2 -2
  787. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +110 -12
  788. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_binds.ts +56 -0
  789. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_string.ts +96 -0
  790. package/skills/a2h-batch-ui-align/scripts/static_check/rules/padding_in_size.ts +179 -0
  791. package/skills/a2h-batch-ui-align/scripts/static_check/rules/percent_height_in_scroll.ts +3 -2
  792. package/skills/a2h-batch-ui-align/scripts/static_check/rules/popup_menu.ts +81 -8
  793. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +102 -0
  794. package/skills/a2h-batch-ui-align/scripts/static_check/rules/root_weight.ts +54 -4
  795. package/skills/a2h-batch-ui-align/scripts/static_check/rules/runtime_traps.ts +440 -0
  796. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_align.ts +75 -23
  797. package/skills/a2h-batch-ui-align/scripts/static_check/rules/scroll_delta.ts +178 -0
  798. package/skills/a2h-batch-ui-align/scripts/static_check/rules/swiper_index.ts +65 -0
  799. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +184 -0
  800. package/skills/a2h-batch-ui-align/scripts/static_check/rules/waterflow_sections.ts +231 -0
  801. package/skills/a2h-batch-ui-align/scripts/static_check/rules/wide_constant_width.ts +4 -4
  802. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_mode.ts +2 -3
  803. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +30 -2
  804. package/skills/a2h-batch-ui-align/scripts/tests/agent_cli.test.mjs +231 -0
  805. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_a11y.test.mjs +598 -0
  806. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_align_tint.test.mjs +312 -0
  807. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_baseline.test.mjs +129 -0
  808. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_blur.test.mjs +217 -0
  809. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_builder_calls.test.mjs +323 -0
  810. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_canvas_pct.test.mjs +312 -0
  811. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_runtime2.test.mjs +697 -0
  812. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_fidelity.test.mjs +507 -0
  813. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +298 -0
  814. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_input_runtime.test.mjs +514 -0
  815. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +651 -0
  816. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_occlusion_offset_format.test.mjs +372 -0
  817. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_lottie.test.mjs +199 -0
  818. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_review_fixes.test.mjs +298 -0
  819. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +269 -0
  820. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rules.test.mjs +365 -0
  821. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +346 -0
  822. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_padding_raster.test.mjs +262 -0
  823. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_scroll_safearea.test.mjs +742 -0
  824. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_shell.test.mjs +91 -0
  825. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +86 -0
  826. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme_runtime.test.mjs +95 -0
  827. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_weight_color.test.mjs +473 -0
  828. package/skills/a2h-batch-ui-align/scripts/tests/branch_coverage.test.mjs +116 -0
  829. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +693 -0
  830. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_scope.test.mjs +291 -0
  831. package/skills/a2h-batch-ui-align/scripts/tests/capture_audit.test.mjs +179 -0
  832. package/skills/a2h-batch-ui-align/scripts/tests/capture_fast.test.mjs +56 -0
  833. package/skills/a2h-batch-ui-align/scripts/tests/capture_gate.test.mjs +197 -0
  834. package/skills/a2h-batch-ui-align/scripts/tests/capture_review_fixes.test.mjs +322 -0
  835. package/skills/a2h-batch-ui-align/scripts/tests/color_utils_asset.test.mjs +93 -0
  836. package/skills/a2h-batch-ui-align/scripts/tests/detect_paradigm.test.mjs +260 -0
  837. package/skills/a2h-batch-ui-align/scripts/tests/draw_coverage.test.mjs +244 -0
  838. package/skills/a2h-batch-ui-align/scripts/tests/evidence_gate.test.mjs +435 -0
  839. package/skills/a2h-batch-ui-align/scripts/tests/export_scroll_states.test.mjs +31 -0
  840. package/skills/a2h-batch-ui-align/scripts/tests/export_ui_info.test.mjs +742 -0
  841. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/SearchMenuDialog.buggy.ets +95 -0
  842. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/meta.json +21 -0
  843. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/screenshot.png +0 -0
  844. package/skills/a2h-batch-ui-align/scripts/tests/fixtures/icon_drift_search_sheet/page_0002_SearchMenuFragment/view.xml +35 -0
  845. package/skills/a2h-batch-ui-align/scripts/tests/generate_pages_json.test.mjs +123 -0
  846. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +126 -0
  847. package/skills/a2h-batch-ui-align/scripts/tests/group_pack.test.mjs +363 -0
  848. package/skills/a2h-batch-ui-align/scripts/tests/group_pack_evidence.test.mjs +95 -0
  849. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +1782 -0
  850. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +215 -0
  851. package/skills/a2h-batch-ui-align/scripts/tests/harmony_index.test.mjs +95 -0
  852. package/skills/a2h-batch-ui-align/scripts/tests/host_env.test.mjs +115 -0
  853. package/skills/a2h-batch-ui-align/scripts/tests/icon_coverage.test.mjs +314 -0
  854. package/skills/a2h-batch-ui-align/scripts/tests/image_probe.test.mjs +243 -0
  855. package/skills/a2h-batch-ui-align/scripts/tests/list_existing.test.mjs +157 -0
  856. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack.test.mjs +326 -0
  857. package/skills/a2h-batch-ui-align/scripts/tests/occlusion.test.mjs +102 -0
  858. package/skills/a2h-batch-ui-align/scripts/tests/page_gap.test.mjs +115 -0
  859. package/skills/a2h-batch-ui-align/scripts/tests/phase5_check.test.mjs +356 -0
  860. package/skills/a2h-batch-ui-align/scripts/tests/progress_identity.test.mjs +174 -0
  861. package/skills/a2h-batch-ui-align/scripts/tests/shell_contract.test.mjs +302 -0
  862. package/skills/a2h-batch-ui-align/scripts/tests/shell_requests.test.mjs +158 -0
  863. package/skills/a2h-batch-ui-align/scripts/tests/skill_doc_contract.test.mjs +60 -0
  864. package/skills/a2h-batch-ui-align/scripts/tests/state_doc.test.mjs +395 -0
  865. package/skills/a2h-batch-ui-align/scripts/tests/static_check_registry.test.mjs +122 -0
  866. package/skills/a2h-batch-ui-align/scripts/tests/test_bfs_exit.ts +49 -0
  867. package/skills/a2h-batch-ui-align/scripts/tests/text_color_diff.test.mjs +250 -0
  868. package/skills/a2h-coldstart-smoke-gate/SKILL.md +7 -4
  869. package/skills/a2h-dashboard-render/scripts/dashboard.mjs +12 -14
  870. package/skills/a2h-dashboard-render/scripts/device_capture.mjs +29 -30
  871. package/skills/a2h-dashboard-render/test/fixtures/page_capture/broken.xml +1 -0
  872. package/skills/a2h-dashboard-render/test/fixtures/page_capture/expected.json +156 -0
  873. package/skills/a2h-dashboard-render/test/fixtures/page_capture/hmos.json +1 -0
  874. package/skills/a2h-dashboard-render/test/fixtures/page_capture/list.xml +1 -0
  875. package/skills/a2h-dashboard-render/test/fixtures/page_capture/nested_scroll.xml +1 -0
  876. package/skills/a2h-dashboard-render/test/test_artifact_contract.mjs +168 -0
  877. package/skills/a2h-dashboard-render/test/test_cli_check_registry.mjs +99 -0
  878. package/skills/a2h-dashboard-render/test/test_dashboard_architecture.mjs +118 -0
  879. package/skills/a2h-dashboard-render/test/test_dashboard_build.mjs +93 -0
  880. package/skills/a2h-dashboard-render/test/test_dashboard_i18n.mjs +203 -0
  881. package/skills/a2h-dashboard-render/test/test_dashboard_node.mjs +1369 -0
  882. package/skills/a2h-dashboard-render/test/test_dashboard_spec_pipeline.mjs +318 -0
  883. package/skills/a2h-dashboard-render/test/test_dashboard_ui_pipeline.mjs +81 -0
  884. package/skills/a2h-dashboard-render/test/test_device_capture_env.mjs +115 -0
  885. package/skills/a2h-dashboard-render/test/test_device_capture_policy.mjs +411 -0
  886. package/skills/a2h-dashboard-render/test/test_device_locale_dialogs.mjs +17 -0
  887. package/skills/a2h-dashboard-render/test/test_page_capture.mjs +147 -0
  888. package/skills/a2h-dashboard-render/test/test_usage_readers.mjs +512 -0
  889. package/skills/a2h-module-semantic-docs/SKILL.md +51 -13
  890. package/skills/a2h-module-semantic-docs/scripts/scan_modules.mjs +66 -11
  891. package/skills/a2h-module-semantic-docs/test/golden/module_structure.json +187 -0
  892. package/skills/a2h-module-semantic-docs/test/golden/module_understanding.json +351 -0
  893. package/skills/a2h-module-semantic-docs/test/golden/module_update_plan.json +495 -0
  894. package/skills/a2h-module-semantic-docs/test/golden/project_directory_structure.json +157 -0
  895. package/skills/a2h-module-semantic-docs/test/test_incremental_fingerprint.mjs +94 -0
  896. package/skills/a2h-module-semantic-docs/test/test_scan_and_commit.mjs +388 -0
  897. package/skills/a2h-page-specgen/SKILL.md +240 -0
  898. package/skills/a2h-page-specgen/references/behavior-ledger.md +1170 -0
  899. package/skills/a2h-page-specgen/references/body-language.md +179 -0
  900. package/skills/a2h-page-specgen/references/evidence.md +105 -0
  901. package/skills/a2h-page-specgen/references/execution-model.md +364 -0
  902. package/skills/a2h-page-specgen/references/footprint-and-grouping.md +255 -0
  903. package/skills/a2h-page-specgen/references/gates.md +323 -0
  904. package/skills/a2h-page-specgen/references/page-inventory.md +220 -0
  905. package/skills/a2h-page-specgen/references/scenario-authoring.md +272 -0
  906. package/skills/a2h-page-specgen/references/spec-example.md +312 -0
  907. package/skills/a2h-page-specgen/references/spec-template.md +210 -0
  908. package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +2436 -0
  909. package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +1833 -0
  910. package/skills/a2h-page-specgen/scripts/behavior-model.mjs +181 -0
  911. package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +1205 -0
  912. package/skills/a2h-page-specgen/scripts/dispatch.mjs +212 -0
  913. package/skills/a2h-page-specgen/scripts/entry-evidence.mjs +1123 -0
  914. package/skills/a2h-page-specgen/scripts/facts-build.mjs +1613 -0
  915. package/skills/a2h-page-specgen/scripts/finalize.mjs +825 -0
  916. package/skills/a2h-page-specgen/scripts/footprint.mjs +1650 -0
  917. package/skills/a2h-page-specgen/scripts/gate.mjs +848 -0
  918. package/skills/a2h-page-specgen/scripts/interactions.mjs +344 -0
  919. package/skills/a2h-page-specgen/scripts/inventory.mjs +371 -0
  920. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +155 -0
  921. package/skills/a2h-page-specgen/scripts/lib/deps-source.mjs +399 -0
  922. package/skills/a2h-page-specgen/scripts/lib/draft-store.mjs +229 -0
  923. package/skills/a2h-page-specgen/scripts/lib/footprint-roles.mjs +278 -0
  924. package/skills/a2h-page-specgen/scripts/lib/fsx.mjs +79 -0
  925. package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +235 -0
  926. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +683 -0
  927. package/skills/a2h-page-specgen/scripts/lib/homegraph-process.mjs +102 -0
  928. package/skills/a2h-page-specgen/scripts/lib/homegraph-query.mjs +161 -0
  929. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +478 -0
  930. package/skills/a2h-page-specgen/scripts/lib/main-module.mjs +24 -0
  931. package/skills/a2h-page-specgen/scripts/lib/operation-reviews.mjs +913 -0
  932. package/skills/a2h-page-specgen/scripts/lib/prose.mjs +238 -0
  933. package/skills/a2h-page-specgen/scripts/lib/reach.mjs +53 -0
  934. package/skills/a2h-page-specgen/scripts/lib/recovery-policy.mjs +28 -0
  935. package/skills/a2h-page-specgen/scripts/lib/scope.mjs +355 -0
  936. package/skills/a2h-page-specgen/scripts/lib/semantic-detail.mjs +353 -0
  937. package/skills/a2h-page-specgen/scripts/lib/source-text.mjs +497 -0
  938. package/skills/a2h-page-specgen/scripts/lib/symbols.mjs +125 -0
  939. package/skills/a2h-page-specgen/scripts/lib/utg-io.mjs +110 -0
  940. package/skills/a2h-page-specgen/scripts/lib/waker-event-store.mjs +658 -0
  941. package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +1542 -0
  942. package/skills/a2h-page-specgen/scripts/prepare.mjs +840 -0
  943. package/skills/a2h-page-specgen/scripts/render.mjs +294 -0
  944. package/skills/a2h-page-specgen/scripts/report.mjs +340 -0
  945. package/skills/a2h-page-specgen/scripts/submission.mjs +697 -0
  946. package/skills/a2h-page-specgen/scripts/submit.mjs +85 -0
  947. package/skills/a2h-page-specgen/scripts/test/acceptance/README.md +77 -0
  948. package/skills/a2h-page-specgen/scripts/test/acceptance/acceptance.mjs +871 -0
  949. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.java +15 -0
  950. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.json +26 -0
  951. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +347 -0
  952. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +298 -0
  953. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.java +36 -0
  954. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.json +43 -0
  955. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +347 -0
  956. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +298 -0
  957. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +2694 -0
  958. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +726 -0
  959. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +108 -0
  960. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +347 -0
  961. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.review.md +65 -0
  962. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +265 -0
  963. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.java +47 -0
  964. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.json +54 -0
  965. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +347 -0
  966. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +298 -0
  967. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/branch-checklist.md +32 -0
  968. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/gate-results.json +22 -0
  969. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/manifest.json +111 -0
  970. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/portability.test.mjs +141 -0
  971. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/review.md +22 -0
  972. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +515 -0
  973. package/skills/a2h-page-specgen/scripts/test/acceptance/cases.example.json +57 -0
  974. package/skills/a2h-page-specgen/scripts/test/android-entry-evidence.test.mjs +585 -0
  975. package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +755 -0
  976. package/skills/a2h-page-specgen/scripts/test/behavior-audit-group.test.mjs +543 -0
  977. package/skills/a2h-page-specgen/scripts/test/behavior-audit-post.test.mjs +652 -0
  978. package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +1231 -0
  979. package/skills/a2h-page-specgen/scripts/test/behavior-component-gate.test.mjs +494 -0
  980. package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +1513 -0
  981. package/skills/a2h-page-specgen/scripts/test/behavior-finalize.test.mjs +758 -0
  982. package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +623 -0
  983. package/skills/a2h-page-specgen/scripts/test/behavior-model.test.mjs +116 -0
  984. package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +795 -0
  985. package/skills/a2h-page-specgen/scripts/test/behavior-regression.test.mjs +883 -0
  986. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +205 -0
  987. package/skills/a2h-page-specgen/scripts/test/dispatch.test.mjs +258 -0
  988. package/skills/a2h-page-specgen/scripts/test/entry-evidence.test.mjs +475 -0
  989. package/skills/a2h-page-specgen/scripts/test/facts.test.mjs +1203 -0
  990. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +243 -0
  991. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Api.kt +20 -0
  992. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/BothAnnotations.kt +28 -0
  993. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Cache.kt +7 -0
  994. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Comments.kt +26 -0
  995. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Mmkv.kt +7 -0
  996. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Models.kt +19 -0
  997. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Pair.kt +7 -0
  998. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Prefs.kt +9 -0
  999. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Room.kt +11 -0
  1000. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Sample.kt +43 -0
  1001. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Templates.kt +34 -0
  1002. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/Timeouts.kt +8 -0
  1003. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/androidTest/Helper.kt +5 -0
  1004. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/build.gradle.kts +16 -0
  1005. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/en.js.txt +5 -0
  1006. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/i18n/zh.js.txt +4 -0
  1007. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/libs.versions.toml +14 -0
  1008. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/package.json +10 -0
  1009. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values/strings.xml +10 -0
  1010. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-b+zh+Hans/strings.xml +4 -0
  1011. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-land/strings.xml +5 -0
  1012. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-night/strings.xml +5 -0
  1013. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-v21/strings.xml +4 -0
  1014. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/res/values-zh/strings.xml +4 -0
  1015. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/test/Legacy.kt +4 -0
  1016. package/skills/a2h-page-specgen/scripts/test/fixtures/facts/weather.proto +11 -0
  1017. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/AppPreferences.kt +13 -0
  1018. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-container/src/SettingsViewModel.kt +16 -0
  1019. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-dao/src/UserDao.kt +28 -0
  1020. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/base/strings.xml +6 -0
  1021. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-moko/i18n/src/commonMain/moko-resources/fil/strings.xml +6 -0
  1022. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/arrays.xml +25 -0
  1023. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/values/strings.xml +10 -0
  1024. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/res/xml/prefs.xml +27 -0
  1025. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Api.java +19 -0
  1026. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Datastore.kt +12 -0
  1027. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/Settings.java +13 -0
  1028. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/forecast.js +14 -0
  1029. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-pref/src/store.js +14 -0
  1030. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/BasePreferences.kt +13 -0
  1031. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/Screen.kt +14 -0
  1032. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-receiver/src/UiPreferences.kt +8 -0
  1033. package/skills/a2h-page-specgen/scripts/test/fixtures/facts-retrofit/src/AuthAPI.kt +26 -0
  1034. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/AndroidManifest.xml +20 -0
  1035. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/feature/auth/navigation/ScreenRoute.kt +8 -0
  1036. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/pages.json +19 -0
  1037. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/components/Widget.vue +11 -0
  1038. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/detail/detail.vue +14 -0
  1039. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/pages/index/index.vue +24 -0
  1040. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/store/userStore.js +11 -0
  1041. package/skills/a2h-page-specgen/scripts/test/fixtures/fp/src/uni_modules/uview-ui/components/u-thing.js +5 -0
  1042. package/skills/a2h-page-specgen/scripts/test/fixtures/fp.mkdb.mjs +144 -0
  1043. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +112 -0
  1044. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.java +14 -0
  1045. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanels.kt +14 -0
  1046. package/skills/a2h-page-specgen/scripts/test/fixtures/src/BottomPanelsKotlinForms.kt +12 -0
  1047. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ChildContent.java +6 -0
  1048. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ComposeLifecycle.kt +26 -0
  1049. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleCallAndOverride.java +10 -0
  1050. package/skills/a2h-page-specgen/scripts/test/fixtures/src/LifecycleHooks.kt +31 -0
  1051. package/skills/a2h-page-specgen/scripts/test/fixtures/src/MainFragment.java +6 -0
  1052. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyLifecycleHooks.kt +12 -0
  1053. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ManyListeners.java +12 -0
  1054. package/skills/a2h-page-specgen/scripts/test/fixtures/src/PlainActivity.java +3 -0
  1055. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshOnResume.java +7 -0
  1056. package/skills/a2h-page-specgen/scripts/test/fixtures/src/RefreshResultNoise.kt +36 -0
  1057. package/skills/a2h-page-specgen/scripts/test/fixtures/src/SelectionView.java +5 -0
  1058. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ShowPage.vue +12 -0
  1059. package/skills/a2h-page-specgen/scripts/test/fixtures/src/ThirdPartyLifecycle.kt +25 -0
  1060. package/skills/a2h-page-specgen/scripts/test/fixtures/src/fragment_detail.xml +1 -0
  1061. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/App.vue +1 -0
  1062. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-conflict-record.json +17 -0
  1063. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/bundle-record.json +17 -0
  1064. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/manifest.json +3 -0
  1065. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages/list/index.vue +80 -0
  1066. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/pages.json +14 -0
  1067. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/source-record.json +15 -0
  1068. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/components/RefreshPanel.vue +15 -0
  1069. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/composables/useRefresh.ts +50 -0
  1070. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/pages/help/index.vue +9 -0
  1071. package/skills/a2h-page-specgen/scripts/test/fixtures/uniapp-source/src/state/store.ts +4 -0
  1072. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/click_paths.json +28 -0
  1073. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/fold-chain/utg.json +12 -0
  1074. package/skills/a2h-page-specgen/scripts/test/fixtures/utg/utg.json +34 -0
  1075. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +1029 -0
  1076. package/skills/a2h-page-specgen/scripts/test/footprint-roles.test.mjs +172 -0
  1077. package/skills/a2h-page-specgen/scripts/test/fsx.test.mjs +32 -0
  1078. package/skills/a2h-page-specgen/scripts/test/gate-partial.test.mjs +143 -0
  1079. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +1078 -0
  1080. package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +332 -0
  1081. package/skills/a2h-page-specgen/scripts/test/helpers.mjs +188 -0
  1082. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +549 -0
  1083. package/skills/a2h-page-specgen/scripts/test/homegraph-process-fixture.mjs +130 -0
  1084. package/skills/a2h-page-specgen/scripts/test/homegraph-query.test.mjs +288 -0
  1085. package/skills/a2h-page-specgen/scripts/test/integration.test.mjs +368 -0
  1086. package/skills/a2h-page-specgen/scripts/test/interactions.test.mjs +310 -0
  1087. package/skills/a2h-page-specgen/scripts/test/inventory.test.mjs +250 -0
  1088. package/skills/a2h-page-specgen/scripts/test/keys.test.mjs +776 -0
  1089. package/skills/a2h-page-specgen/scripts/test/ledger-lock.test.mjs +77 -0
  1090. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +464 -0
  1091. package/skills/a2h-page-specgen/scripts/test/main-module.test.mjs +43 -0
  1092. package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +1002 -0
  1093. package/skills/a2h-page-specgen/scripts/test/plan-build.test.mjs +1103 -0
  1094. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph-reproduction.mjs +365 -0
  1095. package/skills/a2h-page-specgen/scripts/test/prepare-homegraph.test.mjs +569 -0
  1096. package/skills/a2h-page-specgen/scripts/test/prepare-index.test.mjs +160 -0
  1097. package/skills/a2h-page-specgen/scripts/test/prepare-pipeline.test.mjs +326 -0
  1098. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +236 -0
  1099. package/skills/a2h-page-specgen/scripts/test/prose.test.mjs +398 -0
  1100. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +531 -0
  1101. package/skills/a2h-page-specgen/scripts/test/reach.test.mjs +93 -0
  1102. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +418 -0
  1103. package/skills/a2h-page-specgen/scripts/test/recovery-policy.test.mjs +14 -0
  1104. package/skills/a2h-page-specgen/scripts/test/recovery.test.mjs +1782 -0
  1105. package/skills/a2h-page-specgen/scripts/test/render.test.mjs +546 -0
  1106. package/skills/a2h-page-specgen/scripts/test/report.test.mjs +296 -0
  1107. package/skills/a2h-page-specgen/scripts/test/review-followup.test.mjs +467 -0
  1108. package/skills/a2h-page-specgen/scripts/test/scope.test.mjs +292 -0
  1109. package/skills/a2h-page-specgen/scripts/test/semantic-detail.test.mjs +949 -0
  1110. package/skills/a2h-page-specgen/scripts/test/source-text.test.mjs +181 -0
  1111. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +1231 -0
  1112. package/skills/a2h-page-specgen/scripts/test/uniapp-operation-evidence.test.mjs +639 -0
  1113. package/skills/a2h-page-specgen/scripts/test/utg-footprint-contract.test.mjs +274 -0
  1114. package/skills/a2h-page-specgen/scripts/test/utg-io.test.mjs +90 -0
  1115. package/skills/a2h-page-specgen/scripts/test/waker-event-store.test.mjs +1365 -0
  1116. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +1801 -0
  1117. package/skills/a2h-page-specgen/scripts/test/waker.test.mjs +1993 -0
  1118. package/skills/a2h-page-specgen/scripts/test/watchdog.test.mjs +342 -0
  1119. package/skills/a2h-page-specgen/scripts/waker.mjs +1301 -0
  1120. package/skills/a2h-page-specgen/scripts/watchdog.mjs +299 -0
  1121. package/skills/a2h-resource-convert/SKILL.md +9 -1
  1122. package/skills/a2h-resource-convert/references/code-vector-icon-rules.md +2 -1
  1123. package/skills/a2h-resource-convert/references/incremental-page-migration.md +23 -2
  1124. package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +7 -0
  1125. package/skills/a2h-resource-convert/references/step4-resource-types.md +2 -0
  1126. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +115 -53
  1127. package/skills/a2h-resource-convert/scripts/a2h_resource_incremental.ts +68 -0
  1128. package/skills/a2h-resource-convert/scripts/code_vector_icons.ts +45 -3
  1129. package/skills/a2h-resource-convert/scripts/extract_page_resources.ts +42 -5
  1130. package/skills/a2h-resource-convert/scripts/lottie_hosts.ts +415 -0
  1131. package/skills/a2h-resource-convert/scripts/lottie_refs.ts +398 -0
  1132. package/skills/a2h-resource-convert/scripts/merge_mapping.ts +316 -0
  1133. package/skills/a2h-resource-convert/scripts/svg_fidelity_check.ts +2 -1
  1134. package/skills/a2h-resource-convert/scripts/tests/adaptive_icon.test.mjs +182 -0
  1135. package/skills/a2h-resource-convert/scripts/tests/app_identity.test.mjs +206 -0
  1136. package/skills/a2h-resource-convert/scripts/tests/code_vector_guard.test.mjs +75 -0
  1137. package/skills/a2h-resource-convert/scripts/tests/docs_only_i18n.test.mjs +44 -0
  1138. package/skills/a2h-resource-convert/scripts/tests/lottie_hosts.test.mjs +222 -0
  1139. package/skills/a2h-resource-convert/scripts/tests/lottie_incremental.test.mjs +178 -0
  1140. package/skills/a2h-resource-convert/scripts/tests/merge_mapping.test.mjs +201 -0
  1141. package/skills/a2h-spec-design-pipeline/SKILL.md +98 -121
  1142. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +170 -45
  1143. package/skills/a2h-spec-design-pipeline/references/execution-model.md +62 -12
  1144. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -4
  1145. package/skills/a2h-spec-design-pipeline/references/homegraph-cli.md +229 -0
  1146. package/skills/a2h-spec-design-pipeline/references/initialization.md +49 -6
  1147. package/skills/a2h-spec-design-pipeline/references/merge-queue.md +198 -54
  1148. package/skills/a2h-spec-design-pipeline/references/permission-index.json +206 -0
  1149. package/skills/a2h-spec-design-pipeline/references/post-loop.md +23 -0
  1150. package/skills/a2h-spec-design-pipeline/references/resolver-prompt.md +67 -0
  1151. package/skills/a2h-spec-design-pipeline/references/review-loop.md +46 -0
  1152. package/skills/a2h-spec-design-pipeline/references/scripts.md +47 -14
  1153. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +390 -0
  1154. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +148 -29
  1155. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +104 -24
  1156. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +18 -0
  1157. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +16 -0
  1158. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +47 -0
  1159. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +31 -0
  1160. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +698 -0
  1161. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +96 -0
  1162. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +103 -0
  1163. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +124 -0
  1164. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +138 -0
  1165. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +106 -0
  1166. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +113 -0
  1167. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +705 -0
  1168. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +1063 -0
  1169. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +473 -0
  1170. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/platform/ExtraDataSubCheck.js +485 -0
  1171. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +13 -0
  1172. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +18 -0
  1173. package/skills/a2h-spec-design-pipeline/scripts/branch_landed.ts +12 -38
  1174. package/skills/a2h-spec-design-pipeline/scripts/check_design_map.ts +108 -0
  1175. package/skills/a2h-spec-design-pipeline/scripts/check_permissions.ts +420 -0
  1176. package/skills/a2h-spec-design-pipeline/scripts/check_review_evidence.ts +45 -0
  1177. package/skills/a2h-spec-design-pipeline/scripts/dispatch/evidence.mjs +95 -7
  1178. package/skills/a2h-spec-design-pipeline/scripts/dispatch/fold.mjs +156 -7
  1179. package/skills/a2h-spec-design-pipeline/scripts/dispatch/landing.mjs +71 -0
  1180. package/skills/a2h-spec-design-pipeline/scripts/dispatch/progress.mjs +22 -3
  1181. package/skills/a2h-spec-design-pipeline/scripts/dispatch/reconcile.mjs +63 -4
  1182. package/skills/a2h-spec-design-pipeline/scripts/dispatch/wait.mjs +33 -3
  1183. package/skills/a2h-spec-design-pipeline/scripts/dispatch/worktree.mjs +2 -2
  1184. package/skills/a2h-spec-design-pipeline/scripts/dispatch.mjs +232 -13
  1185. package/skills/a2h-spec-design-pipeline/scripts/ensure_index.ts +866 -0
  1186. package/skills/a2h-spec-design-pipeline/scripts/fixtures/homecheck-stub.cjs +47 -0
  1187. package/skills/a2h-spec-design-pipeline/scripts/homecheck_scan.ts +220 -44
  1188. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_classes.ts +113 -0
  1189. package/skills/a2h-spec-design-pipeline/scripts/lib/shared_docs.ts +202 -0
  1190. package/skills/a2h-spec-design-pipeline/scripts/lib/wiring.ts +58 -0
  1191. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +178 -14
  1192. package/skills/a2h-spec-design-pipeline/scripts/resolve_wiring.ts +3 -0
  1193. package/skills/a2h-spec-design-pipeline/scripts/resolver_prompt.ts +368 -0
  1194. package/skills/a2h-spec-design-pipeline/scripts/scan_shared.ts +642 -0
  1195. package/skills/a2h-spec-design-pipeline/scripts/sync_permission_index.ts +340 -0
  1196. package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +281 -0
  1197. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +690 -0
  1198. package/skills/a2h-spec-design-pipeline/scripts/test_check_design_map.ts +46 -0
  1199. package/skills/a2h-spec-design-pipeline/scripts/test_check_permissions.ts +201 -0
  1200. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_commands.mjs +42 -8
  1201. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_e2e.mjs +27 -9
  1202. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_evidence.mjs +242 -9
  1203. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_fold.mjs +192 -7
  1204. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_landing.mjs +531 -0
  1205. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_progress.mjs +49 -1
  1206. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_reconcile.mjs +92 -4
  1207. package/skills/a2h-spec-design-pipeline/scripts/test_dispatch_wait.mjs +51 -0
  1208. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index.ts +572 -0
  1209. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_index_real.ts +56 -0
  1210. package/skills/a2h-spec-design-pipeline/scripts/test_homecheck_scan.ts +17 -10
  1211. package/skills/a2h-spec-design-pipeline/scripts/test_homegraph_docs.ts +217 -0
  1212. package/skills/a2h-spec-design-pipeline/scripts/test_permission_index.ts +214 -0
  1213. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +155 -0
  1214. package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +308 -0
  1215. package/skills/a2h-spec-design-pipeline/scripts/test_resolve_wiring.ts +14 -0
  1216. package/skills/a2h-spec-design-pipeline/scripts/test_resolver_prompt.ts +401 -0
  1217. package/skills/a2h-spec-design-pipeline/scripts/test_scan_shared.ts +996 -0
  1218. package/skills/a2h-spec-design-pipeline/scripts/test_shared_classes.ts +80 -0
  1219. package/skills/a2h-spec-design-pipeline/scripts/test_shared_docs.ts +205 -0
  1220. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +165 -0
  1221. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_e2e.ts +85 -0
  1222. package/skills/a2h-spec-design-pipeline/scripts/test_validate_shared_manifest.ts +720 -0
  1223. package/skills/a2h-spec-design-pipeline/scripts/test_wiring.ts +40 -0
  1224. package/skills/a2h-spec-design-pipeline/scripts/validate_shared_manifest.ts +566 -0
  1225. package/skills/a2h-spec-generate/SKILL.md +89 -23
  1226. package/skills/a2h-spec-generate/references/batch-mode.md +78 -17
  1227. package/skills/a2h-spec-generate/references/dispatch-watchdog.md +150 -0
  1228. package/skills/a2h-spec-generate/references/fusion-task-contract.md +7 -0
  1229. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  1230. package/skills/a2h-spec-generate/references/specs.schema.json +24 -11
  1231. package/skills/a2h-spec-generate/references/synthesis-rules.md +4 -2
  1232. package/skills/a2h-spec-generate/references/worker-rules.md +6 -3
  1233. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +4 -5
  1234. package/skills/a2h-spec-generate/scripts/check_spec.ts +145 -14
  1235. package/skills/a2h-spec-generate/scripts/collect-specs.mjs +261 -19
  1236. package/skills/a2h-spec-generate/scripts/dispatch-watch.mjs +1168 -0
  1237. package/skills/a2h-spec-generate/scripts/ensure-index.mjs +1 -2
  1238. package/skills/a2h-spec-generate/scripts/feature-stem.mjs +1 -2
  1239. package/skills/a2h-spec-generate/scripts/publish-specs.mjs +1 -2
  1240. package/skills/a2h-spec-generate/scripts/regroup-by-page.mjs +1 -2
  1241. package/skills/a2h-spec-generate/scripts/render-tasks.mjs +25 -46
  1242. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/build.ts +26 -27
  1243. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/graph/component-variants.ts +3 -6
  1244. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/policy.ts +31 -32
  1245. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/names/traceability.ts +2 -3
  1246. package/skills/a2h-spec-generate/scripts/reqgen/src/analysis/req-model/build.ts +15 -26
  1247. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/area-facts.ts +102 -81
  1248. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/behavior-seed.ts +39 -19
  1249. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/library-evidence.ts +12 -13
  1250. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/navigation-guard.ts +363 -0
  1251. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +35 -196
  1252. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/contracts.ts +3 -1
  1253. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/task-contract.ts +22 -96
  1254. package/skills/a2h-spec-generate/scripts/reqgen/src/interaction-analysis/tree-sitter-adapter.ts +3 -4
  1255. package/skills/a2h-spec-generate/scripts/reqgen/src/model/contracts.ts +1 -1
  1256. package/skills/a2h-spec-generate/scripts/reqgen/src/model/finalize.ts +74 -7
  1257. package/skills/a2h-spec-generate/scripts/reqgen/src/model/prepare.ts +51 -7
  1258. package/skills/a2h-spec-generate/scripts/reqgen/src/model/task.ts +42 -111
  1259. package/skills/a2h-spec-generate/scripts/reqgen/src/requirement-scope.ts +1 -20
  1260. package/skills/a2h-spec-generate/scripts/reqgen/src/source-index/homegraph.ts +1 -2
  1261. package/skills/a2h-spec-generate/scripts/reqgen/src/validation/req-text.ts +3 -4
  1262. package/skills/a2h-spec-generate/scripts/reqgen/test/control-fact-join.test.ts +50 -0
  1263. package/skills/a2h-spec-generate/scripts/reqgen/test/control-name-uniapp.test.ts +75 -0
  1264. package/skills/a2h-spec-generate/scripts/reqgen/test/cross-area-anchor.test.ts +256 -0
  1265. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/fusion-run.ts +243 -0
  1266. package/skills/a2h-spec-generate/scripts/reqgen/test/fixtures/zip.ts +63 -0
  1267. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-area-facts.test.ts +650 -0
  1268. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-detectors.test.ts +176 -0
  1269. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +103 -0
  1270. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-schema.test.ts +111 -0
  1271. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-seed.test.ts +195 -0
  1272. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-selfcheck.test.ts +307 -0
  1273. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-contract.test.ts +347 -0
  1274. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-finalize.test.ts +1948 -0
  1275. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-library-evidence.test.ts +239 -0
  1276. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-navigation-guard.test.ts +277 -0
  1277. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-prepare.test.ts +844 -0
  1278. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-scope.test.ts +339 -0
  1279. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-selfcheck.test.ts +1253 -0
  1280. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +608 -0
  1281. package/skills/a2h-spec-generate/scripts/reqgen/test/model-cli-blockers.test.ts +117 -0
  1282. package/skills/a2h-spec-generate/scripts/reqgen/test/model-scope.test.ts +411 -0
  1283. package/skills/a2h-spec-generate/scripts/reqgen/test/model-seeds.test.ts +175 -0
  1284. package/skills/a2h-spec-generate/scripts/reqgen/test/model-task-contract.test.ts +300 -0
  1285. package/skills/a2h-spec-generate/scripts/reqgen/test/model-v4.test.ts +1061 -0
  1286. package/skills/a2h-spec-generate/scripts/reqgen/test/specgen-completeness.test.ts +286 -0
  1287. package/skills/a2h-spec-generate/scripts/reqgen/test/stagem-stored-path.test.ts +25 -0
  1288. package/skills/a2h-spec-generate/scripts/reqgen/test/uniapp-scanner.test.ts +159 -0
  1289. package/skills/a2h-spec-generate/scripts/reqgen/test/zip.test.ts +61 -0
  1290. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +879 -0
  1291. package/skills/a2h-spec-generate/test/check-spec.test.ts +430 -0
  1292. package/skills/a2h-spec-generate/test/collect-specs.test.mjs +811 -0
  1293. package/skills/a2h-spec-generate/test/detect-project.test.mjs +37 -0
  1294. package/skills/a2h-spec-generate/test/dispatch-watch.test.mjs +606 -0
  1295. package/skills/a2h-spec-generate/test/ensure-index.test.mjs +229 -0
  1296. package/skills/a2h-spec-generate/test/feature-stem.test.mjs +157 -0
  1297. package/skills/a2h-spec-generate/test/fixtures/android/app/src/main/AndroidManifest.xml +3 -0
  1298. package/skills/a2h-spec-generate/test/fixtures/android/build.gradle +3 -0
  1299. package/skills/a2h-spec-generate/test/fixtures/android/settings.gradle +3 -0
  1300. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/package.json +9 -0
  1301. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/App.vue +8 -0
  1302. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/components/MyCard.vue +9 -0
  1303. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/feature/editor/index.vue +1 -0
  1304. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/main.ts +6 -0
  1305. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/manifest.json +4 -0
  1306. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/detail/index.vue +1 -0
  1307. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/home/index.vue +33 -0
  1308. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages/settings/index.vue +1 -0
  1309. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/pages.json +23 -0
  1310. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/src/services/items.ts +3 -0
  1311. package/skills/a2h-spec-generate/test/fixtures/uniapp-src/tsconfig.json +8 -0
  1312. package/skills/a2h-spec-generate/test/fixtures/unknown/README.txt +1 -0
  1313. package/skills/a2h-spec-generate/test/inspect-uniapp.test.mjs +54 -0
  1314. package/skills/a2h-spec-generate/test/prepare-facts.test.mjs +41 -0
  1315. package/skills/a2h-spec-generate/test/publication-verdict.test.mjs +182 -0
  1316. package/skills/a2h-spec-generate/test/publish-specs.test.mjs +295 -0
  1317. package/skills/a2h-spec-generate/test/regroup-by-page.test.mjs +354 -0
  1318. package/skills/a2h-spec-generate/test/render-tasks.test.mjs +596 -0
  1319. package/skills/a2h-spec-generate/test/report.test.mjs +47 -0
  1320. package/skills/a2h-utg-explorer/SKILL.md +9 -3
  1321. package/skills/a2h-utg-explorer/references/architecture.md +7 -0
  1322. package/skills/a2h-utg-explorer/scripts/audit.mjs +8 -2
  1323. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +120 -85
  1324. package/skills/a2h-utg-explorer/scripts/direct_launch.mjs +47 -2
  1325. package/skills/a2h-utg-explorer/scripts/hint_check.mjs +1 -2
  1326. package/skills/a2h-utg-explorer/scripts/hybrid_route_cdp.mjs +376 -0
  1327. package/skills/a2h-utg-explorer/scripts/plan.mjs +8 -0
  1328. package/skills/a2h-utg-explorer/scripts/recover.mjs +1 -1
  1329. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +288 -21
  1330. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +5 -3
  1331. package/skills/a2h-utg-explorer/scripts/report.mjs +89 -0
  1332. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +67 -10
  1333. package/skills/a2h-utg-explorer/scripts/run_device.mjs +10 -2
  1334. package/skills/a2h-utg-explorer/scripts/seed_recipes.mjs +426 -0
  1335. package/skills/a2h-utg-explorer/scripts/tests/attest.test.mjs +66 -0
  1336. package/skills/a2h-utg-explorer/scripts/tests/blank_wait.test.mjs +126 -0
  1337. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +244 -0
  1338. package/skills/a2h-utg-explorer/scripts/tests/chain.test.mjs +45 -0
  1339. package/skills/a2h-utg-explorer/scripts/tests/compose_identity.test.mjs +302 -0
  1340. package/skills/a2h-utg-explorer/scripts/tests/content_wait.test.mjs +207 -0
  1341. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +104 -0
  1342. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +231 -0
  1343. package/skills/a2h-utg-explorer/scripts/tests/default_override.test.mjs +109 -0
  1344. package/skills/a2h-utg-explorer/scripts/tests/device_health.test.mjs +160 -0
  1345. package/skills/a2h-utg-explorer/scripts/tests/device_locale_dialogs.test.mjs +29 -0
  1346. package/skills/a2h-utg-explorer/scripts/tests/device_locale_identity.test.mjs +77 -0
  1347. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +187 -0
  1348. package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +254 -0
  1349. package/skills/a2h-utg-explorer/scripts/tests/direct_launch.test.mjs +130 -0
  1350. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +137 -0
  1351. package/skills/a2h-utg-explorer/scripts/tests/final_utg.test.mjs +135 -0
  1352. package/skills/a2h-utg-explorer/scripts/tests/first_round_phases.test.mjs +16 -0
  1353. package/skills/a2h-utg-explorer/scripts/tests/foreground_spelling.test.mjs +155 -0
  1354. package/skills/a2h-utg-explorer/scripts/tests/fresh_state_plan.test.mjs +78 -0
  1355. package/skills/a2h-utg-explorer/scripts/tests/generalization_fixes.test.mjs +252 -0
  1356. package/skills/a2h-utg-explorer/scripts/tests/hint_check.test.mjs +129 -0
  1357. package/skills/a2h-utg-explorer/scripts/tests/holds_without_data_parity.test.mjs +26 -0
  1358. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +120 -0
  1359. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route_identity.test.mjs +146 -0
  1360. package/skills/a2h-utg-explorer/scripts/tests/interruptions.test.mjs +614 -0
  1361. package/skills/a2h-utg-explorer/scripts/tests/launch_bridge.test.mjs +214 -0
  1362. package/skills/a2h-utg-explorer/scripts/tests/launch_failure.test.mjs +40 -0
  1363. package/skills/a2h-utg-explorer/scripts/tests/node_coverage.test.mjs +193 -0
  1364. package/skills/a2h-utg-explorer/scripts/tests/overflow_prefix.test.mjs +327 -0
  1365. package/skills/a2h-utg-explorer/scripts/tests/overlay_identity.test.mjs +204 -0
  1366. package/skills/a2h-utg-explorer/scripts/tests/page_identity_tiers.test.mjs +393 -0
  1367. package/skills/a2h-utg-explorer/scripts/tests/pager_navigation.test.mjs +119 -0
  1368. package/skills/a2h-utg-explorer/scripts/tests/panel_routes.test.mjs +208 -0
  1369. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +240 -0
  1370. package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +218 -0
  1371. package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +292 -0
  1372. package/skills/a2h-utg-explorer/scripts/tests/recover.test.mjs +212 -0
  1373. package/skills/a2h-utg-explorer/scripts/tests/recover_b.test.mjs +173 -0
  1374. package/skills/a2h-utg-explorer/scripts/tests/recover_d.test.mjs +280 -0
  1375. package/skills/a2h-utg-explorer/scripts/tests/recover_d_grounding.test.mjs +164 -0
  1376. package/skills/a2h-utg-explorer/scripts/tests/replay_reroute.test.mjs +143 -0
  1377. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +213 -0
  1378. package/skills/a2h-utg-explorer/scripts/tests/robustness_fixes.test.mjs +345 -0
  1379. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +458 -0
  1380. package/skills/a2h-utg-explorer/scripts/tests/run_cycle_follow.test.mjs +35 -0
  1381. package/skills/a2h-utg-explorer/scripts/tests/runner_capabilities.test.mjs +194 -0
  1382. package/skills/a2h-utg-explorer/scripts/tests/scope.test.mjs +229 -0
  1383. package/skills/a2h-utg-explorer/scripts/tests/scroll_sweep.test.mjs +336 -0
  1384. package/skills/a2h-utg-explorer/scripts/tests/seed_recipes.test.mjs +261 -0
  1385. package/skills/a2h-utg-explorer/scripts/tests/semantics.test.mjs +102 -0
  1386. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +142 -0
  1387. package/skills/a2h-utg-explorer/scripts/tests/state_ambiguity.test.mjs +92 -0
  1388. package/skills/a2h-utg-explorer/scripts/tests/string_tables_twin_ties.test.mjs +83 -0
  1389. package/skills/a2h-utg-explorer/scripts/tests/tar_fixture.mjs +12 -0
  1390. package/skills/a2h-utg-explorer/scripts/tests/twin_opener.test.mjs +119 -0
  1391. package/skills/a2h-utg-explorer/scripts/tests/u2_backend.test.mjs +346 -0
  1392. package/skills/a2h-utg-explorer/scripts/tests/ui_state_anchors.test.mjs +112 -0
  1393. package/skills/a2h-utg-explorer/scripts/tests/variant_strings.test.mjs +63 -0
  1394. package/skills/a2h-utg-explorer/scripts/tests/worklist_parts.test.mjs +24 -0
  1395. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +135 -7
  1396. package/skills/a2h-utg-explorer/scripts/utg_explorer/diagnostics.mjs +196 -0
  1397. package/skills/a2h-utg-explorer/scripts/utg_explorer/hybrid_route.mjs +140 -0
  1398. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +245 -69
  1399. package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +47 -0
  1400. package/skills/a2h-utg-explorer/scripts/utg_explorer/strings.mjs +164 -0
  1401. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +718 -42
  1402. package/skills/a2h-utg-explorer/scripts/variant.mjs +57 -11
  1403. package/skills/a2h-utg-static/SKILL.md +6 -2
  1404. package/skills/a2h-utg-static/scripts/assemble.mjs +93 -3
  1405. package/skills/a2h-utg-static/scripts/click_paths.mjs +135 -25
  1406. package/skills/a2h-utg-static/scripts/compose_body_text.mjs +3 -3
  1407. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +110 -3
  1408. package/skills/a2h-utg-static/scripts/compose_titles.mjs +5 -5
  1409. package/skills/a2h-utg-static/scripts/compose_widgets.mjs +4 -4
  1410. package/skills/a2h-utg-static/scripts/data_model.mjs +590 -0
  1411. package/skills/a2h-utg-static/scripts/data_producers.mjs +431 -0
  1412. package/skills/a2h-utg-static/scripts/fragment_nav.mjs +2 -3
  1413. package/skills/a2h-utg-static/scripts/hybrid_scope.mjs +46 -1
  1414. package/skills/a2h-utg-static/scripts/label_resolve.mjs +49 -4
  1415. package/skills/a2h-utg-static/scripts/lib/hybrid-provenance.mjs +201 -0
  1416. package/skills/a2h-utg-static/scripts/lib/uniapp-routes.mjs +195 -0
  1417. package/skills/a2h-utg-static/scripts/menu_nav.mjs +1 -1
  1418. package/skills/a2h-utg-static/scripts/nl_hints.mjs +34 -7
  1419. package/skills/a2h-utg-static/scripts/presenter_nav.mjs +1 -2
  1420. package/skills/a2h-utg-static/scripts/route_interceptor.mjs +21 -7
  1421. package/skills/a2h-utg-static/scripts/run_pipeline.mjs +86 -4
  1422. package/skills/a2h-utg-static/scripts/static_prior.mjs +26 -29
  1423. package/skills/a2h-utg-static/scripts/tests/test_activity_gates.mjs +84 -0
  1424. package/skills/a2h-utg-static/scripts/tests/test_carry_answers.mjs +30 -0
  1425. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +18 -0
  1426. package/skills/a2h-utg-static/scripts/tests/test_data_model.mjs +120 -0
  1427. package/skills/a2h-utg-static/scripts/tests/test_data_producers.mjs +114 -0
  1428. package/skills/a2h-utg-static/scripts/tests/test_guard_kinds_locale.mjs +12 -0
  1429. package/skills/a2h-utg-static/scripts/tests/test_hybrid_provenance.mjs +150 -0
  1430. package/skills/a2h-utg-static/scripts/tests/test_hybrid_scope.mjs +165 -1
  1431. package/skills/a2h-utg-static/scripts/tests/test_library_activity.mjs +45 -0
  1432. package/skills/a2h-utg-static/scripts/tests/test_login_interceptor.mjs +38 -0
  1433. package/skills/a2h-utg-static/scripts/tests/test_module_strings.mjs +35 -1
  1434. package/skills/a2h-utg-static/scripts/tests/test_nl_hints_default_override.mjs +50 -0
  1435. package/skills/a2h-utg-static/scripts/tests/test_pipeline_llm_phases.mjs +21 -0
  1436. package/skills/a2h-utg-static/scripts/tests/test_pr169_review_fixes.mjs +172 -0
  1437. package/skills/a2h-utg-static/scripts/tests/test_redirect_path_cost.mjs +136 -0
  1438. package/skills/a2h-utg-static/scripts/tests/test_route_token_words.mjs +29 -1
  1439. package/skills/a2h-utg-static/scripts/tests/test_uniapp_route_jump.mjs +175 -0
  1440. package/skills/a2h-utg-static/scripts/tests/test_uniapp_routes.mjs +161 -0
  1441. package/skills/a2h-utg-static/scripts/tests/test_uniapp_source.mjs +99 -0
  1442. package/skills/a2h-utg-static/scripts/tests/test_utg_specgen_boundary.mjs +45 -0
  1443. package/skills/a2h-utg-static/scripts/tests/test_vm_nav_helper_navigate.mjs +21 -0
  1444. package/skills/a2h-utg-static/scripts/uniapp_nav.mjs +112 -69
  1445. package/skills/a2h-utg-static/scripts/vm_nav.mjs +9 -1
  1446. package/README.md +0 -439
  1447. package/dist/cli/config-store.js +0 -128
  1448. package/dist/cli/config.js +0 -48
  1449. package/dist/cli/editors.json +0 -114
  1450. package/dist/cli/env-vars.js +0 -127
  1451. package/dist/cli/index.js +0 -73
  1452. package/dist/cli/init.js +0 -2513
  1453. package/dist/cli/uninstall.js +0 -406
  1454. package/dist/platform/compose.js +0 -228
  1455. package/dist/platform/frontmatter.js +0 -151
  1456. package/dist/platform/installer.js +0 -417
  1457. package/dist/platform/registry.js +0 -337
  1458. package/dist/platform/transform.js +0 -363
  1459. package/dist/platform/types.js +0 -9
  1460. package/dist/platform/validate.js +0 -152
  1461. package/dist/utils/regex.js +0 -7
  1462. package/env-requirements.json +0 -511
  1463. package/resource/choose_editor.png +0 -0
  1464. package/resource/convert_pipeline_process.svg +0 -114
  1465. package/resource/project_architecture.svg +0 -120
  1466. package/resource/set_environment.png +0 -0
  1467. package/resource/set_multimodel.png +0 -0
  1468. package/resource/set_sdk.png +0 -0
  1469. package/resource/title_dark.png +0 -0
  1470. package/skills/a2h-app-migrate/scripts/i18n-term.d.mts +0 -5
  1471. package/skills/a2h-app-migrate/scripts/i18n-term.mjs +0 -54
  1472. package/skills/a2h-arch-generate/scripts/i18n-term.d.mts +0 -5
  1473. package/skills/a2h-arch-generate/scripts/i18n-term.mjs +0 -54
  1474. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.d.mts +0 -5
  1475. package/skills/a2h-arkts-logic-coder/scripts/design/i18n-term.mjs +0 -54
  1476. package/skills/a2h-batch-ui-align/references/source-only-tier.md +0 -38
  1477. package/skills/a2h-batch-ui-align/scripts/i18n-term.d.mts +0 -5
  1478. package/skills/a2h-batch-ui-align/scripts/i18n-term.mjs +0 -54
  1479. package/skills/a2h-dashboard-render/scripts/i18n-term.d.mts +0 -5
  1480. package/skills/a2h-dashboard-render/scripts/i18n-term.mjs +0 -54
  1481. package/skills/a2h-resource-convert/scripts/i18n-term.d.mts +0 -5
  1482. package/skills/a2h-resource-convert/scripts/i18n-term.mjs +0 -54
  1483. package/skills/a2h-spec-design-pipeline/scripts/ensure_wt_index.ts +0 -885
  1484. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.d.mts +0 -5
  1485. package/skills/a2h-spec-design-pipeline/scripts/i18n-term.mjs +0 -54
  1486. package/skills/a2h-spec-design-pipeline/scripts/test_ensure_wt_index.ts +0 -856
  1487. package/skills/a2h-spec-design-pipeline/scripts/test_i18n_term.ts +0 -70
  1488. package/skills/a2h-spec-generate/scripts/i18n-term.d.mts +0 -5
  1489. package/skills/a2h-spec-generate/scripts/i18n-term.mjs +0 -54
  1490. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.d.mts +0 -5
  1491. package/skills/a2h-spec-generate/scripts/reqgen/src/i18n-term.mjs +0 -54
  1492. package/skills/a2h-utg-explorer/scripts/i18n-term.d.mts +0 -5
  1493. package/skills/a2h-utg-explorer/scripts/i18n-term.mjs +0 -54
  1494. package/skills/a2h-utg-static/scripts/i18n-term.d.mts +0 -5
  1495. package/skills/a2h-utg-static/scripts/i18n-term.mjs +0 -54
  1496. package/skills/a2h-utg-static/scripts/tests/test_i18n_term.mjs +0 -155
@@ -0,0 +1,2436 @@
1
+ // behavior-audit.mjs — pre-authoring behavior audit and its CLI.
2
+ //
3
+ // Two independent verdicts are produced here:
4
+ // - audit status: completed | incomplete | failed
5
+ // - coverage status: complete | partial
6
+ // A completed audit may still deliver partial coverage; that is the point of
7
+ // separating the two.
8
+
9
+ import crypto from "node:crypto";
10
+ import fs from "node:fs";
11
+ import path from "node:path";
12
+ import {
13
+ evidenceSnapshotDigest,
14
+ stableDigest,
15
+ validateEvidenceReference,
16
+ OUT_OF_SCOPE_RULES,
17
+ } from "./behavior-model.mjs";
18
+ import { isInteractionScanSourceUnit, isNavigationAxis } from "./behavior-discovery.mjs";
19
+ import { interactionDispositionMap, reconcileDiscovery } from "./behavior-reconcile.mjs";
20
+ import { assertGraphFreshness, loadEvidenceFromDisk as loadPersistedEvidence } from "./lib/graph-evidence.mjs";
21
+ import { assertPlanContentVersion } from "./footprint.mjs";
22
+ import { fold } from "./lib/ledger.mjs";
23
+ import { listFilesRecursively, readJson, writeJsonAtomic } from "./lib/fsx.mjs";
24
+ import { stemOf } from "./render.mjs";
25
+ import { isMainModule } from "./lib/main-module.mjs";
26
+ import { evaluateOperationReviews } from "./lib/operation-reviews.mjs";
27
+ import { evaluateSemanticDetail } from "./lib/semantic-detail.mjs";
28
+
29
+ const TERMINAL_SOURCE_REVIEWS = new Set(["reviewed"]);
30
+ const TERMINAL_EVIDENCE_REVIEWS = new Set(["supported", "refuted", "insufficient"]);
31
+ const TERMINAL_CANDIDATE_REVIEWS = new Set(["supported", "refuted", "insufficient"]);
32
+
33
+ const asArray = value => (Array.isArray(value) ? value : []);
34
+ const objectEntries = value => asArray(value).filter(entry => entry && typeof entry === "object");
35
+ const nonEmpty = value => typeof value === "string" && value.trim() !== "";
36
+ const same = (a, b) => stableDigest(a) === stableDigest(b);
37
+ const fail = (code, message, extra = {}) => ({ code, message, ...extra });
38
+
39
+ export { evidenceSnapshotDigest } from "./behavior-model.mjs";
40
+
41
+ /**
42
+ * Prove that page evidence is still the evidence the plan was built from.
43
+ *
44
+ * Plan self-consistency is necessary but never ledger authentication: disk
45
+ * callers also compare `fold(outDir).plan_version` with `plan.plan_version`.
46
+ *
47
+ * @throws when the evidence or plan content no longer matches its anchors
48
+ */
49
+ export function assertBehaviorEvidenceAnchor({ plan, pageId, evidence } = {}) {
50
+ if (!plan || typeof plan !== "object") throw new Error("behavior anchor: plan is required");
51
+ const page = asArray(plan.pages).find(candidate => candidate?.page_id === pageId);
52
+ if (!page) throw new Error(`behavior anchor: plan has no page ${pageId}`);
53
+ const anchor = page.behavior;
54
+ if (!anchor) throw new Error(`behavior anchor: plan page ${pageId} has no behavior`);
55
+
56
+ const recomputed = evidenceSnapshotDigest(evidence);
57
+ if (evidence?.snapshot_digest !== recomputed) {
58
+ throw new Error(`evidence snapshot digest mismatch for ${pageId}`);
59
+ }
60
+ if (evidence?.schema_version !== anchor.schema_version) {
61
+ throw new Error(`behavior schema mismatch with plan anchor for ${pageId}`);
62
+ }
63
+ if (!same(evidence?.profile, anchor.profile)) {
64
+ throw new Error(`behavior profile mismatch with plan anchor for ${pageId}`);
65
+ }
66
+ if (evidence?.snapshot_digest !== anchor.snapshot_digest) {
67
+ throw new Error(`evidence snapshot mismatch with plan anchor for ${pageId}`);
68
+ }
69
+ if (!same(asArray(evidence?.source_units), asArray(evidence?.current_snapshot?.source_units))) {
70
+ throw new Error(`source_units snapshot mismatch for ${pageId}`);
71
+ }
72
+ const snapshots = [evidence?.current_snapshot, ...asArray(evidence?.snapshot_history)].filter(Boolean);
73
+ if (snapshots.length === 0) {
74
+ throw new Error(`behavior anchor: evidence has no recorded snapshot for ${pageId}`);
75
+ }
76
+ for (const snapshot of snapshots) {
77
+ const expected = stableDigest({
78
+ profile_id: snapshot.profile_id,
79
+ source_units: asArray(snapshot.source_units),
80
+ });
81
+ if (snapshot.snapshot_digest !== expected) {
82
+ throw new Error(`snapshot digest mismatch in recorded history for ${pageId}`);
83
+ }
84
+ }
85
+ assertPlanContentVersion(plan);
86
+ }
87
+
88
+ /**
89
+ * Observe the live bytes of every readable SourceUnit.
90
+ *
91
+ * The recorded Evidence is immutable and is never rewritten here. Drift is an
92
+ * audit-generated unknown: a missing file is `source-unread` and changed bytes
93
+ * are `source-changed`, so a zero-assertion or zero-candidate page is still
94
+ * checked. Unit-wide means every readable unit participates, not only the units
95
+ * some assertion happens to cite.
96
+ *
97
+ * @param {object} args
98
+ * @param {object} args.evidence immutable page evidence
99
+ * @param {string|null} args.sourceProject source project root
100
+ * @returns {object[]} audit-generated drift unknowns
101
+ */
102
+ export function sourceUnitDrift({ evidence, sourceProject } = {}) {
103
+ const unknowns = [];
104
+ const hasSourceRoot = typeof sourceProject === "string" && sourceProject !== "";
105
+ for (const unit of asArray(evidence?.source_units).filter(unit => unit?.read_status === "read")) {
106
+ // Without a source root no live bytes can be observed. Fail closed: every
107
+ // readable unit stays source-unread so delivery can never claim complete.
108
+ if (!hasSourceRoot) {
109
+ unknowns.push({ id: `source-unread:${unit.id}`, scope: "source-unit",
110
+ source_unit_id: unit.id, locator: unit.locator, reason: "source-unread" });
111
+ continue;
112
+ }
113
+ let bytes;
114
+ try {
115
+ bytes = fs.readFileSync(path.join(sourceProject, unit.locator));
116
+ } catch {
117
+ unknowns.push({ id: `source-unread:${unit.id}`, scope: "source-unit",
118
+ source_unit_id: unit.id, locator: unit.locator, reason: "source-unread" });
119
+ continue;
120
+ }
121
+ const digest = crypto.createHash("sha256").update(bytes).digest("hex");
122
+ if (digest !== unit.content_digest) {
123
+ unknowns.push({ id: `source-changed:${unit.id}`, scope: "source-unit",
124
+ source_unit_id: unit.id, locator: unit.locator, reason: "source-changed" });
125
+ }
126
+ }
127
+ return unknowns;
128
+ }
129
+
130
+ const SCAN_STATUSES = new Set(["ok", "skipped", "no_source"]);
131
+
132
+ function locatorOfAt(at) {
133
+ if (typeof at !== "string") return null;
134
+ const colon = at.lastIndexOf(":");
135
+ return colon > 0 ? at.slice(0, colon) : null;
136
+ }
137
+
138
+ /**
139
+ * Validate the persisted interaction scan closure for one page.
140
+ *
141
+ * Every readable UI-scannable SourceUnit owns exactly one record whose locator and
142
+ * aggregate signal count match the plan. Producer-only required-evidence units
143
+ * are reviewed but do not owe a target-page UI scan. A missing record is unfinished work;
144
+ * duplicate/unknown/locator-conflict/count/truncation contradictions are hard
145
+ * failures. A `truncated` record is legal only when the discovery pipeline
146
+ * recorded the matching truncation unknown — closure itself is decided by the
147
+ * resolution contract in `behavior-reconcile.mjs`.
148
+ */
149
+ function checkInteractionScans({ plan, evidence, discovery, pageId }) {
150
+ const failures = [];
151
+ const page = asArray(plan?.pages).find(candidate => candidate?.page_id === pageId);
152
+ const hasPlanInteractions = Array.isArray(page?.interactions);
153
+ if (!hasPlanInteractions) {
154
+ failures.push(fail("interaction-scan-plan",
155
+ `plan has no interaction aggregate for behavior page ${pageId ?? "unknown"}`));
156
+ }
157
+ const countsByLocator = new Map();
158
+ for (const interaction of hasPlanInteractions ? page.interactions : []) {
159
+ const locator = locatorOfAt(interaction?.at);
160
+ if (locator === null) continue;
161
+ countsByLocator.set(locator, (countsByLocator.get(locator) ?? 0) + 1);
162
+ }
163
+
164
+ const units = asArray(evidence?.source_units).filter(unit => unit && typeof unit === "object");
165
+ const unitById = new Map(units.filter(unit => nonEmpty(unit.id)).map(unit => [unit.id, unit]));
166
+ const required = units.filter(unit =>
167
+ unit.read_status === "read" && isInteractionScanSourceUnit(unit));
168
+ const truncatedUnknowns = [
169
+ ...asArray(evidence?.unknowns),
170
+ ...asArray(discovery?.unknowns),
171
+ ].filter(unknown => unknown?.cause === "truncated" && unknown?.reason === "review-incomplete");
172
+ const declaresTruncation = unit => truncatedUnknowns.some(unknown =>
173
+ unknown.source_unit_id === unit.id
174
+ || (unknown.locator !== undefined && unknown.locator === unit.locator));
175
+
176
+ const seen = new Set();
177
+ const records = [];
178
+ const failed = [];
179
+ const truncated = [];
180
+ for (const [index, record] of asArray(evidence?.interaction_scans).entries()) {
181
+ if (!record || typeof record !== "object" || !nonEmpty(record.source_unit_id)) {
182
+ failures.push(fail("interaction-scan-shape",
183
+ `interaction_scans[${index}] has no source_unit_id`));
184
+ continue;
185
+ }
186
+ if (seen.has(record.source_unit_id)) {
187
+ failures.push(fail("interaction-scan-duplicate",
188
+ `duplicate interaction scan for ${record.source_unit_id}`));
189
+ continue;
190
+ }
191
+ const unit = unitById.get(record.source_unit_id);
192
+ if (!unit) {
193
+ failures.push(fail("interaction-scan-unknown",
194
+ `interaction scan names unknown SourceUnit ${record.source_unit_id}`));
195
+ continue;
196
+ }
197
+ seen.add(record.source_unit_id);
198
+ if (record.locator !== unit.locator) {
199
+ failures.push(fail("interaction-scan-locator",
200
+ `interaction scan for ${record.source_unit_id} names locator ${record.locator} instead of ${unit.locator}`));
201
+ continue;
202
+ }
203
+ if (!SCAN_STATUSES.has(record.status)) {
204
+ failures.push(fail("interaction-scan-status",
205
+ `interaction scan for ${record.source_unit_id} has invalid status ${record.status}`));
206
+ continue;
207
+ }
208
+ const expected = countsByLocator.get(unit.locator) ?? 0;
209
+ if (hasPlanInteractions && record.signal_count !== expected) {
210
+ failures.push(fail("interaction-scan-count",
211
+ `interaction scan for ${record.source_unit_id} claims ${record.signal_count} signals but the plan records ${expected}`));
212
+ continue;
213
+ }
214
+ if (typeof record.truncated !== "boolean") {
215
+ failures.push(fail("interaction-scan-truncated",
216
+ `interaction scan for ${record.source_unit_id} has a malformed truncated flag`));
217
+ continue;
218
+ }
219
+ records.push(record);
220
+ if (record.status !== "ok") failed.push(unit);
221
+ if (!record.truncated) continue;
222
+ if (!declaresTruncation(unit)) {
223
+ failures.push(fail("interaction-scan-truncated",
224
+ `interaction scan for ${record.source_unit_id} claims truncation with no recorded truncation unknown`));
225
+ continue;
226
+ }
227
+ truncated.push(unit);
228
+ }
229
+
230
+ const missing = required.filter(unit => !seen.has(unit.id));
231
+ const unknowns = missing.map(unit => ({
232
+ id: `interaction-scan-missing:${unit.id}`,
233
+ code: "interaction-scan-missing",
234
+ scope: "interaction",
235
+ reason: "review-incomplete",
236
+ cause: "scan-missing",
237
+ source_unit_id: unit.id,
238
+ locator: unit.locator,
239
+ next_action: "Rescan the SourceUnit and persist its interaction scan record",
240
+ }));
241
+ return { failures, unknowns, records, missing, failed, truncated };
242
+ }
243
+
244
+ /**
245
+ * Validate the persisted lifecycle scan closure for one page — the mirror of
246
+ * `checkInteractionScans` without the plan cross-check, because lifecycle hits
247
+ * are per-unit candidates (deduplicated per signal), never a plan aggregate.
248
+ *
249
+ * Every readable UI-scannable SourceUnit owns exactly one record. A missing
250
+ * record means the lifecycle scan was never persisted and is unfinished work;
251
+ * duplicate/unknown/locator-conflict/malformed records are hard failures. A
252
+ * `truncated` record is legal only when the pipeline recorded the matching
253
+ * `lifecycle-review-incomplete` unknown — lifecycle truncation unknowns must
254
+ * not satisfy the interaction scan's truncation declaration, and vice versa.
255
+ */
256
+ function checkLifecycleScans({ evidence, discovery, pageId }) {
257
+ const failures = [];
258
+ const units = asArray(evidence?.source_units).filter(unit => unit && typeof unit === "object");
259
+ const unitById = new Map(units.filter(unit => nonEmpty(unit.id)).map(unit => [unit.id, unit]));
260
+ const required = units.filter(unit =>
261
+ unit.read_status === "read" && isInteractionScanSourceUnit(unit));
262
+ const truncatedUnknowns = [
263
+ ...asArray(evidence?.unknowns),
264
+ ...asArray(discovery?.unknowns),
265
+ ].filter(unknown => unknown?.cause === "truncated"
266
+ && unknown?.reason === "lifecycle-review-incomplete");
267
+ const declaresLifecycleTruncation = unit => truncatedUnknowns.some(unknown =>
268
+ unknown.source_unit_id === unit.id
269
+ || (unknown.locator !== undefined && unknown.locator === unit.locator));
270
+
271
+ const seen = new Set();
272
+ const records = [];
273
+ const failed = [];
274
+ const truncated = [];
275
+ for (const [index, record] of asArray(evidence?.lifecycle_scans).entries()) {
276
+ if (!record || typeof record !== "object" || !nonEmpty(record.source_unit_id)) {
277
+ failures.push(fail("lifecycle-scan-shape",
278
+ `lifecycle_scans[${index}] has no source_unit_id`));
279
+ continue;
280
+ }
281
+ if (seen.has(record.source_unit_id)) {
282
+ failures.push(fail("lifecycle-scan-duplicate",
283
+ `duplicate lifecycle scan for ${record.source_unit_id}`));
284
+ continue;
285
+ }
286
+ const unit = unitById.get(record.source_unit_id);
287
+ if (!unit) {
288
+ failures.push(fail("lifecycle-scan-unknown",
289
+ `lifecycle scan names unknown SourceUnit ${record.source_unit_id}`));
290
+ continue;
291
+ }
292
+ seen.add(record.source_unit_id);
293
+ if (record.locator !== unit.locator) {
294
+ failures.push(fail("lifecycle-scan-locator",
295
+ `lifecycle scan for ${record.source_unit_id} names locator ${record.locator} instead of ${unit.locator}`));
296
+ continue;
297
+ }
298
+ if (!SCAN_STATUSES.has(record.status)) {
299
+ failures.push(fail("lifecycle-scan-status",
300
+ `lifecycle scan for ${record.source_unit_id} has invalid status ${record.status}`));
301
+ continue;
302
+ }
303
+ if (typeof record.truncated !== "boolean") {
304
+ failures.push(fail("lifecycle-scan-truncated",
305
+ `lifecycle scan for ${record.source_unit_id} has a malformed truncated flag`));
306
+ continue;
307
+ }
308
+ records.push(record);
309
+ if (record.status !== "ok") failed.push(unit);
310
+ if (!record.truncated) continue;
311
+ if (!declaresLifecycleTruncation(unit)) {
312
+ failures.push(fail("lifecycle-scan-truncated",
313
+ `lifecycle scan for ${record.source_unit_id} claims truncation with no recorded truncation unknown`));
314
+ continue;
315
+ }
316
+ truncated.push(unit);
317
+ }
318
+
319
+ const missing = required.filter(unit => !seen.has(unit.id));
320
+ const unknowns = missing.map(unit => ({
321
+ id: `lifecycle-scan-missing:${unit.id}`,
322
+ code: "lifecycle-scan-missing",
323
+ scope: "lifecycle",
324
+ reason: "lifecycle-review-incomplete",
325
+ cause: "scan-missing",
326
+ source_unit_id: unit.id,
327
+ locator: unit.locator,
328
+ next_action: "Rescan the SourceUnit and persist its lifecycle scan record",
329
+ }));
330
+ return { failures, unknowns, records, missing, failed, truncated };
331
+ }
332
+
333
+ /**
334
+ * A missing/failed scan record, or a truncated record whose explicit
335
+ * resolution is still unresolved, means the scan closure is unfinished.
336
+ */
337
+ function scanStateIncomplete({ scanCheck, lifecycleCheck, unresolvedUnknowns }) {
338
+ if (scanCheck.missing.length > 0 || scanCheck.failed.length > 0) return true;
339
+ if (lifecycleCheck
340
+ && (lifecycleCheck.missing.length > 0 || lifecycleCheck.failed.length > 0)) return true;
341
+ const unresolvedTruncatedUnits = new Set(unresolvedUnknowns
342
+ .filter(unknown => unknown?.cause === "truncated")
343
+ .flatMap(unknown => [unknown.source_unit_id, ...asArray(unknown.source_unit_ids)]));
344
+ if (scanCheck.truncated.some(unit => unresolvedTruncatedUnits.has(unit.id))) return true;
345
+ return Boolean(lifecycleCheck
346
+ && lifecycleCheck.truncated.some(unit => unresolvedTruncatedUnits.has(unit.id)));
347
+ }
348
+
349
+ function referenceState({ reference, evidence, sourceProject }) {
350
+ try {
351
+ return validateEvidenceReference({
352
+ reference,
353
+ currentSnapshot: evidence?.current_snapshot,
354
+ snapshotHistory: asArray(evidence?.snapshot_history),
355
+ sourceProject,
356
+ });
357
+ } catch (error) {
358
+ return { status: "invalid", reason: "evidence-validation-error", message: error.message };
359
+ }
360
+ }
361
+
362
+ function assertableRefs(value) {
363
+ return asArray(value).filter(reference => reference && typeof reference === "object");
364
+ }
365
+
366
+ /**
367
+ * Validate references and derive stale assertion IDs and their accounting.
368
+ * Returns failures, the set of stale IDs that are legally accounted for, and
369
+ * how many IDs are stale but unaccounted.
370
+ */
371
+ function checkEvidenceReferences({ evidence, discovery, sourceProject, reconciled }) {
372
+ const failures = [];
373
+ const staleIds = new Set();
374
+
375
+ const checkAssertion = (assertionId, references) => {
376
+ const refs = assertableRefs(references);
377
+ if (refs.length === 0) {
378
+ failures.push(fail("evidence-missing", `assertion ${assertionId} has no evidence reference`));
379
+ return;
380
+ }
381
+ for (const reference of refs) {
382
+ const state = referenceState({ reference, evidence, sourceProject });
383
+ if (state.status === "invalid") {
384
+ failures.push(fail("evidence-invalid",
385
+ `assertion ${assertionId} evidence is invalid: ${state.reason}`));
386
+ } else if (state.status === "stale" || state.status === "unknown") {
387
+ staleIds.add(assertionId);
388
+ }
389
+ }
390
+ };
391
+
392
+ for (const assertion of asArray(discovery.assertions)) {
393
+ if (!assertion || typeof assertion !== "object") continue;
394
+ checkAssertion(assertion.id, assertion.evidence_refs);
395
+ }
396
+ for (const assertion of asArray(evidence.assertions)) {
397
+ if (!assertion || typeof assertion !== "object") continue;
398
+ checkAssertion(assertion.id, assertion.evidence_refs);
399
+ }
400
+
401
+ const dispositions = new Map(objectEntries(discovery.planned).map(entry => [entry.assertion_id, entry]));
402
+ const reviews = new Map(objectEntries(discovery.evidence_reviews).map(entry => [entry.assertion_id, entry]));
403
+ const resolutions = asArray(discovery.resolutions);
404
+ const resolutionAccounts = assertionId => resolutions.some(resolution => {
405
+ if (resolution?.status !== "resolved") return false;
406
+ if (!asArray(resolution.assertion_ids).includes(assertionId)) return false;
407
+ const refs = assertableRefs(resolution.evidence_refs);
408
+ if (refs.length === 0) return false;
409
+ return refs.every(reference => referenceState({ reference, evidence, sourceProject }).status === "valid");
410
+ });
411
+
412
+ const unaccounted = new Set();
413
+ for (const assertionId of staleIds) {
414
+ const disposition = dispositions.get(assertionId);
415
+ const review = reviews.get(assertionId);
416
+ const fieldUnknown = reconciled.unresolved_unknowns
417
+ .some(unknown => unknown.affected_assertion_id === assertionId);
418
+ const unknownAccount = fieldUnknown
419
+ && disposition?.status === "unknown"
420
+ && review?.status === "insufficient";
421
+ if (!unknownAccount && !resolutionAccounts(assertionId)) unaccounted.add(assertionId);
422
+ }
423
+ for (const assertionId of unaccounted) {
424
+ failures.push(fail("stale-assertion",
425
+ `assertion ${assertionId} has stale or unread evidence and must be rediscovered or recorded as unknown`));
426
+ }
427
+
428
+ return { failures, unaccounted };
429
+ }
430
+
431
+ function checkUnknownReferences({ evidence, discovery, sourceProject }) {
432
+ const failures = [];
433
+ const seen = new Set();
434
+ for (const unknown of [...asArray(evidence.unknowns), ...asArray(discovery.unknowns)]) {
435
+ if (!unknown || typeof unknown !== "object" || seen.has(unknown.id)) continue;
436
+ seen.add(unknown.id);
437
+ for (const reference of assertableRefs(unknown.evidence_refs)) {
438
+ const state = referenceState({ reference, evidence, sourceProject });
439
+ if (state.status === "invalid") {
440
+ failures.push(fail("unknown-evidence-invalid",
441
+ `unknown ${unknown.id} cites invalid evidence: ${state.reason}`));
442
+ }
443
+ }
444
+ }
445
+ for (const resolution of asArray(discovery.resolutions)) {
446
+ for (const reference of assertableRefs(resolution?.evidence_refs)) {
447
+ const state = referenceState({ reference, evidence, sourceProject });
448
+ if (state.status !== "valid") {
449
+ failures.push(fail("resolution-evidence-invalid",
450
+ `resolution for ${resolution.unknown_id} does not cite current evidence: ${state.reason ?? state.status}`));
451
+ }
452
+ }
453
+ }
454
+ return failures;
455
+ }
456
+
457
+ function checkWaiverReferences({ evidence, discovery, sourceProject }) {
458
+ const failures = [];
459
+ const requireValid = (references, label) => {
460
+ for (const reference of assertableRefs(references)) {
461
+ const state = referenceState({ reference, evidence, sourceProject });
462
+ // A waiver is a positive semantic conclusion. Stale, unread, changed, and
463
+ // invalid evidence all hard-fail: only a current valid reference supports it.
464
+ if (state.status !== "valid") {
465
+ failures.push(fail("waiver-evidence-invalid",
466
+ `${label} cites ${state.status} evidence${state.reason ? `: ${state.reason}` : ""}`));
467
+ }
468
+ }
469
+ };
470
+ for (const disposition of asArray(discovery.candidate_dispositions)) {
471
+ requireValid(disposition?.evidence_refs,
472
+ `candidate waiver ${disposition?.candidate_id}`);
473
+ }
474
+ for (const disposition of asArray(discovery.planned)) {
475
+ if (!["no-user-observable", "duplicate-assertion", "out-of-scope"].includes(disposition?.status)) continue;
476
+ requireValid(disposition?.evidence_refs,
477
+ `planned waiver ${disposition?.assertion_id}`);
478
+ }
479
+ return failures;
480
+ }
481
+
482
+ function hasIncompleteReviews({ evidence, discovery }) {
483
+ const sourceReviews = asArray(discovery.source_unit_reviews);
484
+ if (sourceReviews.some(review => !TERMINAL_SOURCE_REVIEWS.has(review?.status))) return true;
485
+
486
+ const dispositions = new Map(objectEntries(discovery.planned).map(entry => [entry.assertion_id, entry]));
487
+ const reviews = new Map(objectEntries(discovery.evidence_reviews).map(entry => [entry.assertion_id, entry]));
488
+ const assertionIds = new Set([
489
+ ...asArray(discovery.assertions).map(assertion => assertion?.id).filter(Boolean),
490
+ ...asArray(evidence.assertions).map(assertion => assertion?.id).filter(Boolean),
491
+ ]);
492
+ for (const assertionId of assertionIds) {
493
+ const review = reviews.get(assertionId);
494
+ if (!review || !TERMINAL_EVIDENCE_REVIEWS.has(review.status)) return true;
495
+ const disposition = dispositions.get(assertionId);
496
+ if (!disposition || disposition.review_status !== "reviewed") return true;
497
+ }
498
+
499
+ const candidateReviews = new Map(
500
+ objectEntries(discovery.candidate_reviews).map(entry => [entry.candidate_id, entry]),
501
+ );
502
+ for (const candidate of asArray(evidence.candidates)) {
503
+ const review = candidateReviews.get(candidate.candidate_id);
504
+ if (!review || !TERMINAL_CANDIDATE_REVIEWS.has(review.status)) return true;
505
+ }
506
+ for (const disposition of asArray(discovery.candidate_dispositions)) {
507
+ if (disposition?.review_status !== undefined && disposition.review_status !== "reviewed") return true;
508
+ }
509
+ for (const resolution of asArray(discovery.resolutions)) {
510
+ if (resolution?.review_status === "incomplete") return true;
511
+ }
512
+ return false;
513
+ }
514
+
515
+ function hasPartialCoverage({ evidence, unresolvedUnknowns, staleUnaccounted }) {
516
+ if (unresolvedUnknowns.length > 0) return true;
517
+ // `unresolved_references` and `inventory_status` are immutable producer facts.
518
+ // They stay in the evidence as diagnostics; closure is decided by whether any
519
+ // composition unknown is still unresolved, because only that is resolvable.
520
+ if (asArray(evidence.source_units).some(unit => unit.read_status !== "read")) return true;
521
+ if (staleUnaccounted.size > 0) return true;
522
+ return false;
523
+ }
524
+
525
+ /**
526
+ * Evaluate one page's pre-authoring audit.
527
+ *
528
+ * @returns {{status:"completed"|"incomplete"|"failed", failures:object[], unknowns:object[], dispositions:object[], discovery_digest:string, coverage_status:"complete"|"partial", attempt:number|null}}
529
+ */
530
+ export function evaluatePreAudit({ plan, evidence, discovery, sourceProject, includeLiveDrift = false } = {}) {
531
+ if (!evidence || typeof evidence !== "object") {
532
+ throw new TypeError("evaluatePreAudit: evidence must be an object");
533
+ }
534
+ const pageId = evidence.page_id ?? discovery?.page_id ?? null;
535
+ const doc = discovery && typeof discovery === "object" ? discovery : {};
536
+ const failures = [];
537
+
538
+ try {
539
+ assertBehaviorEvidenceAnchor({ plan, pageId, evidence });
540
+ } catch (error) {
541
+ failures.push(fail("evidence-anchor", error.message));
542
+ }
543
+
544
+ const reconciled = reconcileDiscovery({ evidence, discovery: doc, sourceProject });
545
+ failures.push(...reconciled.failures);
546
+
547
+ const scanCheck = checkInteractionScans({ plan, evidence, discovery: doc, pageId });
548
+ failures.push(...scanCheck.failures);
549
+
550
+ const lifecycleCheck = checkLifecycleScans({ evidence, discovery: doc, pageId });
551
+ failures.push(...lifecycleCheck.failures);
552
+
553
+ const referenceCheck = checkEvidenceReferences({
554
+ evidence, discovery: doc, sourceProject, reconciled,
555
+ });
556
+ failures.push(...referenceCheck.failures);
557
+ failures.push(...checkUnknownReferences({ evidence, discovery: doc, sourceProject }));
558
+ failures.push(...checkWaiverReferences({ evidence, discovery: doc, sourceProject }));
559
+ const operationReview = evaluateOperationReviews({
560
+ evidence, discovery: doc, drafts: [], sourceProject, partial: true,
561
+ });
562
+ failures.push(...operationReview.failures);
563
+
564
+ const unresolvedUnknowns = [
565
+ ...reconciled.unresolved_unknowns,
566
+ ...scanCheck.unknowns,
567
+ ...lifecycleCheck.unknowns,
568
+ ...operationReview.unknowns,
569
+ ...(includeLiveDrift ? sourceUnitDrift({ evidence, sourceProject }) : []),
570
+ ];
571
+ const incomplete = reconciled.source_review_incomplete
572
+ || scanStateIncomplete({ scanCheck, lifecycleCheck, unresolvedUnknowns })
573
+ || hasIncompleteReviews({ evidence, discovery: doc })
574
+ || operationReview.deferred > 0;
575
+ const status = failures.length > 0 ? "failed" : incomplete ? "incomplete" : "completed";
576
+ // Coverage is a claim about delivery: an unfinished or failed audit can never
577
+ // claim complete coverage, even when nothing unresolved was named.
578
+ const coverageStatus = status !== "completed"
579
+ ? "partial"
580
+ : hasPartialCoverage({
581
+ evidence,
582
+ unresolvedUnknowns,
583
+ staleUnaccounted: referenceCheck.unaccounted,
584
+ }) ? "partial" : "complete";
585
+
586
+ return {
587
+ status,
588
+ failures,
589
+ unknowns: unresolvedUnknowns,
590
+ dispositions: asArray(doc.planned),
591
+ discovery_digest: stableDigest(doc),
592
+ coverage_status: coverageStatus,
593
+ attempt: doc.attempt ?? null,
594
+ };
595
+ }
596
+
597
+ const POST_EVIDENCE_STATUSES = new Set(["supported", "refuted", "insufficient", "unsupported", "incomplete"]);
598
+ const POST_COVERAGE_STATUSES = new Set(["covered", "mismatch", "not-required", "incomplete"]);
599
+ const TERMINAL_POST_EVIDENCE = new Set(["supported", "refuted", "insufficient", "unsupported"]);
600
+ const TERMINAL_POST_COVERAGE = new Set(["covered", "mismatch", "not-required"]);
601
+ const WAIVABLE_DISPOSITIONS = new Set(["no-user-observable", "duplicate-assertion", "out-of-scope"]);
602
+ const TERMINAL_ASSERTION_DISPOSITIONS = new Set(["specified", ...WAIVABLE_DISPOSITIONS]);
603
+ const COUNT_BUCKETS = Object.freeze({
604
+ specified: "specified",
605
+ waived: "waived",
606
+ "no-user-observable": "waived",
607
+ "duplicate-assertion": "waived",
608
+ "out-of-scope": "waived",
609
+ unknown: "unknown",
610
+ conflicted: "conflicted",
611
+ });
612
+ const EVIDENCE_RANK = Object.freeze({ valid: 0, stale: 1, unknown: 2, invalid: 3 });
613
+
614
+ function postFailure(code, message, extra = {}) {
615
+ return { gate: "G4", code, message, ...extra };
616
+ }
617
+
618
+ /**
619
+ * The canonical group discovery digest is taken over the full
620
+ * `{schema_version, attempt, pages}` document, not a reduced page-digest
621
+ * projection. Per-page discovery digests remain distinct and bind drafts.
622
+ */
623
+ export function canonicalGroupDiscoveryDigest(document) {
624
+ return stableDigest({
625
+ schema_version: document?.schema_version ?? null,
626
+ attempt: document?.attempt ?? null,
627
+ pages: asArray(document?.pages),
628
+ });
629
+ }
630
+
631
+ function draftsOf(value) {
632
+ if (value instanceof Map) return [...value.values()];
633
+ return Array.isArray(value) ? [...value] : [];
634
+ }
635
+
636
+ /**
637
+ * Check the group-wide drafts digest exactly once.
638
+ *
639
+ * A single-page evaluator must never recompute this from its filtered drafts:
640
+ * the post-review digest covers every canonical group draft sorted by spec_id.
641
+ */
642
+ export function evaluateGroupDraftDigest({ drafts, postReview } = {}) {
643
+ const canonical = draftsOf(drafts).sort((a, b) => a.spec_id.localeCompare(b.spec_id));
644
+ const expected = stableDigest(canonical);
645
+ const actual = postReview?.drafts_digest;
646
+ if (actual === expected) return null;
647
+ return postFailure(
648
+ "drafts-digest",
649
+ `post-review drafts_digest ${actual === undefined ? "is missing" : "does not match the group drafts"} (expected ${expected})`,
650
+ );
651
+ }
652
+
653
+ function derivePageState({
654
+ evidence,
655
+ dispositions,
656
+ candidateDispositions = [],
657
+ preAudit,
658
+ postAuditStatus,
659
+ unresolvedUnknowns,
660
+ evidenceStatuses,
661
+ sourceReviewIncomplete = false,
662
+ scanIncomplete = false,
663
+ driftUnknowns = [],
664
+ sourceUnitReviews = [],
665
+ interactionScans = [],
666
+ lifecycleScans = [],
667
+ semanticDetailIncomplete = false,
668
+ failures,
669
+ }) {
670
+ const allDispositions = [...objectEntries(dispositions), ...objectEntries(candidateDispositions)];
671
+ const sourceUnits = asArray(evidence.current_snapshot?.source_units ?? evidence.source_units);
672
+ const complete = failures.length === 0
673
+ && unresolvedUnknowns.length === 0
674
+ && evidenceStatuses.every(status => status === "valid")
675
+ && sourceUnits.every(unit => unit.read_status === "read")
676
+ && !sourceReviewIncomplete
677
+ && !scanIncomplete
678
+ && !semanticDetailIncomplete
679
+ && driftUnknowns.length === 0
680
+ && preAudit.status === "completed"
681
+ && postAuditStatus === "completed"
682
+ && objectEntries(dispositions).every(item => TERMINAL_ASSERTION_DISPOSITIONS.has(item.status))
683
+ && objectEntries(candidateDispositions).every(item => item.status === "promoted" || item.status === "waived");
684
+ const counts = Object.fromEntries(["specified", "waived", "unknown", "conflicted"].map(status => [status, 0]));
685
+ for (const item of allDispositions) {
686
+ const bucket = COUNT_BUCKETS[item.status];
687
+ if (bucket !== undefined) counts[bucket] += 1;
688
+ }
689
+ return {
690
+ coverage_status: complete ? "complete" : "partial",
691
+ authoring_status: failures.length > 0
692
+ ? "failed"
693
+ : preAudit.status === "completed" && postAuditStatus === "completed" ? "passed" : "partial",
694
+ delivery_status: failures.length > 0 ? "failed" : complete ? "delivered-complete" : "delivered-partial",
695
+ counts,
696
+ dispositions: allDispositions,
697
+ unknowns: unresolvedUnknowns,
698
+ source_units: sourceUnits,
699
+ source_unit_reviews: sourceUnitReviews,
700
+ interaction_scans: interactionScans,
701
+ lifecycle_scans: lifecycleScans,
702
+ composition_roots: asArray(evidence.composition_roots),
703
+ inventory_status: evidence.inventory_status,
704
+ unresolved_references: asArray(evidence.unresolved_references),
705
+ pre_audit_status: preAudit.status,
706
+ post_audit_status: postAuditStatus,
707
+ };
708
+ }
709
+
710
+ function placeholderPageState({ preAudit, failures }) {
711
+ return {
712
+ coverage_status: "partial",
713
+ authoring_status: failures.length > 0 ? "failed" : "partial",
714
+ delivery_status: failures.length > 0 ? "failed" : "delivered-partial",
715
+ counts: { specified: 0, waived: 0, unknown: 0, conflicted: 0 },
716
+ dispositions: [],
717
+ unknowns: [],
718
+ source_units: [],
719
+ source_unit_reviews: [],
720
+ interaction_scans: [],
721
+ lifecycle_scans: [],
722
+ composition_roots: [],
723
+ inventory_status: null,
724
+ unresolved_references: [],
725
+ pre_audit_status: preAudit?.status ?? "incomplete",
726
+ post_audit_status: "incomplete",
727
+ };
728
+ }
729
+
730
+ function resolutionAccounts({ assertionId, discovery, evidence, sourceProject }) {
731
+ return asArray(discovery.resolutions).some(resolution => {
732
+ if (resolution?.status !== "resolved") return false;
733
+ if (!asArray(resolution.assertion_ids).includes(assertionId)) return false;
734
+ const refs = assertableRefs(resolution.evidence_refs);
735
+ if (refs.length === 0) return false;
736
+ return refs.every(reference =>
737
+ referenceState({ reference, evidence, sourceProject }).status === "valid");
738
+ });
739
+ }
740
+
741
+ /**
742
+ * Re-check every assertion reference and account for stale evidence exactly as
743
+ * the pre-audit does, but with the post-authoring consequence: a stale
744
+ * assertion left `specified` must fail rather than pass silently.
745
+ */
746
+ function evaluatePostEvidence({ evidence, discovery, sourceProject, reconciled }) {
747
+ const failures = [];
748
+ const statusById = new Map();
749
+ const bump = (assertionId, status) => {
750
+ const previous = statusById.get(assertionId);
751
+ if (previous === undefined || EVIDENCE_RANK[status] > EVIDENCE_RANK[previous]) {
752
+ statusById.set(assertionId, status);
753
+ }
754
+ };
755
+ const checkAssertion = (assertionId, references) => {
756
+ const refs = assertableRefs(references);
757
+ if (refs.length === 0) {
758
+ failures.push(postFailure("evidence-missing", `assertion ${assertionId} has no evidence reference`));
759
+ bump(assertionId, "invalid");
760
+ return;
761
+ }
762
+ for (const reference of refs) {
763
+ const state = referenceState({ reference, evidence, sourceProject });
764
+ if (state.status === "invalid") {
765
+ failures.push(postFailure("evidence-invalid",
766
+ `assertion ${assertionId} evidence is invalid: ${state.reason}`));
767
+ }
768
+ bump(assertionId, state.status);
769
+ }
770
+ };
771
+
772
+ for (const assertion of asArray(discovery.assertions)) {
773
+ if (!assertion || typeof assertion !== "object") continue;
774
+ checkAssertion(assertion.id, assertion.evidence_refs);
775
+ }
776
+ for (const assertion of asArray(evidence.assertions)) {
777
+ if (!assertion || typeof assertion !== "object") continue;
778
+ checkAssertion(assertion.id, assertion.evidence_refs);
779
+ }
780
+
781
+ const dispositions = new Map(objectEntries(discovery.planned).map(entry => [entry.assertion_id, entry]));
782
+ const reviews = new Map(objectEntries(discovery.evidence_reviews).map(entry => [entry.assertion_id, entry]));
783
+ for (const [assertionId, status] of statusById) {
784
+ if (status === "valid" || status === "invalid") continue;
785
+ const fieldUnknown = reconciled.unresolved_unknowns
786
+ .some(unknown => unknown.affected_assertion_id === assertionId);
787
+ const disposition = dispositions.get(assertionId);
788
+ const review = reviews.get(assertionId);
789
+ const unknownAccount = fieldUnknown
790
+ && disposition?.status === "unknown"
791
+ && review?.status === "insufficient";
792
+ const accounted = unknownAccount
793
+ || resolutionAccounts({ assertionId, discovery, evidence, sourceProject });
794
+ if (!accounted) {
795
+ failures.push(postFailure("stale-assertion",
796
+ `assertion ${assertionId} has stale or unread evidence and must be rediscovered or recorded as unknown`));
797
+ }
798
+ }
799
+
800
+ for (const failure of checkUnknownReferences({ evidence, discovery, sourceProject })) {
801
+ failures.push(postFailure(failure.code, failure.message));
802
+ }
803
+ for (const failure of checkWaiverReferences({ evidence, discovery, sourceProject })) {
804
+ failures.push(postFailure(failure.code, failure.message));
805
+ }
806
+
807
+ return { failures, statuses: [...statusById.values()] };
808
+ }
809
+
810
+ /**
811
+ * Validate semantic evidence/coverage reviews and require a terminal review for
812
+ * every assertion. An unsupported verdict or a coverage mismatch is a hard
813
+ * failure; `incomplete` or a missing review is partial.
814
+ */
815
+ function evaluateSemanticReviews({ discovery, evidence, postReview }) {
816
+ const failures = [];
817
+ const incomplete = new Set();
818
+ const assertionIds = new Set([
819
+ ...asArray(discovery.assertions).map(assertion => assertion?.id).filter(Boolean),
820
+ ...asArray(evidence.assertions).map(assertion => assertion?.id).filter(Boolean),
821
+ ]);
822
+ const byId = new Map();
823
+
824
+ for (const review of asArray(postReview?.reviews)) {
825
+ if (!review || typeof review !== "object" || !nonEmpty(review.assertion_id)) {
826
+ failures.push(postFailure("review-shape", "post-review reviews entries need an assertion_id"));
827
+ continue;
828
+ }
829
+ if (byId.has(review.assertion_id)) {
830
+ failures.push(postFailure("review-duplicate",
831
+ `duplicate post-review entry for ${review.assertion_id}`));
832
+ continue;
833
+ }
834
+ if (!assertionIds.has(review.assertion_id)) {
835
+ failures.push(postFailure("review-extra",
836
+ `post-review names unknown assertion ${review.assertion_id}`));
837
+ continue;
838
+ }
839
+ if (!POST_EVIDENCE_STATUSES.has(review.evidence_status)) {
840
+ failures.push(postFailure("review-evidence-status",
841
+ `post-review ${review.assertion_id} has invalid evidence_status ${review.evidence_status}`));
842
+ continue;
843
+ }
844
+ if (!POST_COVERAGE_STATUSES.has(review.coverage_status)) {
845
+ failures.push(postFailure("review-coverage-status",
846
+ `post-review ${review.assertion_id} has invalid coverage_status ${review.coverage_status}`));
847
+ continue;
848
+ }
849
+ byId.set(review.assertion_id, review);
850
+ }
851
+
852
+ const planned = new Map(objectEntries(discovery.planned).map(entry => [entry.assertion_id, entry]));
853
+ for (const assertionId of assertionIds) {
854
+ const review = byId.get(assertionId);
855
+ if (!review) {
856
+ incomplete.add(assertionId);
857
+ continue;
858
+ }
859
+ if (review.evidence_status === "unsupported") {
860
+ failures.push(postFailure("evidence-unsupported",
861
+ `assertion ${assertionId} evidence is unsupported`));
862
+ continue;
863
+ }
864
+ if (review.coverage_status === "mismatch") {
865
+ failures.push(postFailure("coverage-mismatch",
866
+ `assertion ${assertionId} scenario coverage does not match the behavior`));
867
+ continue;
868
+ }
869
+ if (!TERMINAL_POST_EVIDENCE.has(review.evidence_status)
870
+ || !TERMINAL_POST_COVERAGE.has(review.coverage_status)) {
871
+ incomplete.add(assertionId);
872
+ continue;
873
+ }
874
+ const disposition = planned.get(assertionId);
875
+ if (!disposition) continue;
876
+ const mismatch = (expectedEvidence, expectedCoverage) => {
877
+ if (review.evidence_status !== expectedEvidence) {
878
+ failures.push(postFailure("review-mismatch",
879
+ `assertion ${assertionId} is ${disposition.status} but its review is ${review.evidence_status}`));
880
+ }
881
+ if (review.coverage_status !== expectedCoverage) {
882
+ failures.push(postFailure("review-mismatch",
883
+ `assertion ${assertionId} is ${disposition.status} but its coverage is ${review.coverage_status}`));
884
+ }
885
+ };
886
+ switch (disposition.status) {
887
+ case "specified":
888
+ mismatch("supported", "covered");
889
+ break;
890
+ case "unknown":
891
+ mismatch("insufficient", "not-required");
892
+ break;
893
+ case "no-user-observable":
894
+ mismatch("refuted", "not-required");
895
+ break;
896
+ case "duplicate-assertion":
897
+ case "out-of-scope":
898
+ mismatch("supported", "not-required");
899
+ break;
900
+ default:
901
+ break;
902
+ }
903
+ }
904
+ return { failures, incomplete: [...incomplete] };
905
+ }
906
+
907
+ // Navigation gate axes that a scenario must restate when the source page does
908
+ // not already require them at entry. The utgs/discovery layer emits the axis
909
+ // name and its interceptor/redirect details as separate precondition rows
910
+ // (`login`, `login: interceptor:…`, `redirect_when_unmet: …`); only the axis
911
+ // row is checked against the draft. Only frozen axes are enforced, so a prose
912
+ // guard or an unrecognized axis can never invent a language rule.
913
+ const GATE_AXIS_TOKENS = Object.freeze({
914
+ login: Object.freeze(["login", "log in", "log-in", "sign in", "sign-in", "logged in"]),
915
+ pay: Object.freeze(["pay", "payment", "checkout", "purchase", "cashier"]),
916
+ });
917
+
918
+ // An ASCII gate token matches only as a whole word: `pay` must not be found
919
+ // inside "payload", "repayment", or "paypal", and `login` must not match a
920
+ // longer identifier. CJK has no word-delimiter convention, so those tokens
921
+ // stay substring matches.
922
+ const ASCII_GATE_TOKEN = /^[A-Za-z][A-Za-z ._-]*$/;
923
+
924
+ function mentionedIn(text, token) {
925
+ if (!ASCII_GATE_TOKEN.test(token)) return text.includes(token);
926
+ const escaped = token.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
927
+ return new RegExp(`\\b${escaped}\\b`, "iu").test(text);
928
+ }
929
+
930
+ /**
931
+ * The frozen navigation axis a precondition row belongs to, or `null` when the
932
+ * row is a detail of another row (`polarity:`, `redirect_when_unmet:`), a
933
+ * non-navigation data axis (`data-state:`, `content`, …), or a prose guard.
934
+ */
935
+ function gateAxisOf(precondition) {
936
+ if (typeof precondition !== "string") return null;
937
+ const text = precondition.trim();
938
+ if (text === "") return null;
939
+ const colon = text.indexOf(":");
940
+ const head = (colon === -1 ? text : text.slice(0, colon)).trim();
941
+ if (!Object.hasOwn(GATE_AXIS_TOKENS, head)) return null;
942
+ return isNavigationAxis(head) ? head : null;
943
+ }
944
+
945
+ /** Axes the page itself already requires before it can be entered at all. */
946
+ function pageEntryAxes(page) {
947
+ const axes = new Set();
948
+ for (const axis of asArray(page?.required_state)) {
949
+ if (typeof axis === "string" && axis.trim() !== "") axes.add(axis.trim());
950
+ }
951
+ for (const axis of Object.keys(page?.interceptors ?? {})) {
952
+ if (axis.trim() !== "") axes.add(axis.trim());
953
+ }
954
+ return axes;
955
+ }
956
+
957
+ /**
958
+ * Gate axes an assertion demands that the source page does not already demand
959
+ * at entry, paired with the tokens a scenario must contain to state them.
960
+ *
961
+ * A page that is itself login-gated cannot be reached without login, so its
962
+ * action scenarios legitimately omit the branch; a page that is not gated (the
963
+ * cart is the canonical case) must state the gate where the gated action is
964
+ * specified, otherwise the SPEC silently drops the unmet path.
965
+ */
966
+ function requiredGateTokens(assertion, page) {
967
+ const entryAxes = pageEntryAxes(page);
968
+ const required = [];
969
+ const seen = new Set();
970
+ for (const precondition of asArray(assertion?.preconditions)) {
971
+ const axis = gateAxisOf(precondition);
972
+ if (axis === null || seen.has(axis) || entryAxes.has(axis)) continue;
973
+ seen.add(axis);
974
+ required.push({ axis, tokens: GATE_AXIS_TOKENS[axis] });
975
+ }
976
+ return required;
977
+ }
978
+
979
+ /**
980
+ * Validate draft `coverage.behaviors[]` links against assertions, scenarios,
981
+ * steps, planned dispositions, waivers, and unresolved unknowns.
982
+ */
983
+ function auditResponseIdentity(value, role = null) {
984
+ if (!value || typeof value !== "object") return null;
985
+ const uri = value.uri ?? value.locator ?? null;
986
+ const start = value.span?.start ?? value.start ?? null;
987
+ const end = value.span?.end ?? value.end ?? start;
988
+ if (!nonEmpty(uri) || !Number.isInteger(start) || !Number.isInteger(end) || start < 1 || end < start) {
989
+ return null;
990
+ }
991
+ const normalizedUri = uri.replace(/\\/g, "/");
992
+ return {
993
+ key: `${normalizedUri}:${start}:${end}:${role ?? ""}`,
994
+ spanKey: `${normalizedUri}:${start}:${end}`,
995
+ };
996
+ }
997
+
998
+ function auditReviewScenario(review) {
999
+ if (Number.isInteger(review?.scenario)) return review.scenario;
1000
+ const scenario = review?.scenario;
1001
+ const value = scenario?.index ?? scenario?.scenario ?? scenario?.number;
1002
+ return Number.isInteger(value) ? value : null;
1003
+ }
1004
+
1005
+ function evaluateBehaviorLinks({
1006
+ discovery,
1007
+ evidence,
1008
+ drafts,
1009
+ page,
1010
+ partial,
1011
+ unresolvedUnknowns,
1012
+ sourceProject,
1013
+ }) {
1014
+ const failures = [];
1015
+ const assertions = new Map();
1016
+ for (const assertion of [...asArray(discovery.assertions), ...asArray(evidence.assertions)]) {
1017
+ if (assertion && typeof assertion === "object" && nonEmpty(assertion.id)) {
1018
+ assertions.set(assertion.id, assertion);
1019
+ }
1020
+ }
1021
+ const planned = new Map(objectEntries(discovery.planned).map(entry => [entry.assertion_id, entry]));
1022
+ const unknowns = new Map(objectEntries(discovery.unknowns).map(entry => [entry.id, entry]));
1023
+ const unresolved = new Set(unresolvedUnknowns.map(unknown => unknown.id));
1024
+ const linked = new Set();
1025
+ const canonicalTargets = new Set();
1026
+ let deferred = 0;
1027
+
1028
+ const responseIdentityForLink = link => {
1029
+ if (link?.status !== "specified" || link.response_span === undefined
1030
+ || link.response_role === undefined || !nonEmpty(link.response_role)) return null;
1031
+ return auditResponseIdentity(link.response_span, link.response_role);
1032
+ };
1033
+ const validResponseBranch = (link, identity) => {
1034
+ if (identity === null || !nonEmpty(link?.operation_id)) return false;
1035
+ const operation = asArray(evidence.operation_candidates)
1036
+ .find(candidate => candidate?.operation_id === link.operation_id);
1037
+ const role = asArray(operation?.response_spans).find(candidate =>
1038
+ auditResponseIdentity(candidate, candidate?.role)?.key === identity.key);
1039
+ if (!role) return false;
1040
+ if (nonEmpty(role.assertion_id)) {
1041
+ if (role.assertion_id !== link.assertion_id) return false;
1042
+ } else {
1043
+ const assertion = assertions.get(link.assertion_id);
1044
+ if (!asArray(assertion?.evidence_refs).some(reference =>
1045
+ auditResponseIdentity(reference)?.spanKey === identity.spanKey)) return false;
1046
+ }
1047
+ return asArray(discovery.operation_reviews).some(review => {
1048
+ if (review?.operation_id !== link.operation_id
1049
+ || auditReviewScenario(review) !== link.scenario) return false;
1050
+ return !Array.isArray(review.steps)
1051
+ || asArray(link.steps).every(step => review.steps.includes(step));
1052
+ });
1053
+ };
1054
+
1055
+ const checkWaiverEvidence = (link, specId) => {
1056
+ const refs = assertableRefs(link.evidence_refs);
1057
+ if (refs.length === 0) {
1058
+ failures.push(postFailure("waiver-evidence",
1059
+ `waiver for ${link.assertion_id} requires supporting evidence`, { spec_id: specId }));
1060
+ return;
1061
+ }
1062
+ for (const reference of refs) {
1063
+ const state = referenceState({ reference, evidence, sourceProject });
1064
+ // A waiver is a positive semantic conclusion. Stale, unread, changed, and
1065
+ // invalid evidence all fail: only a current valid reference can support it.
1066
+ if (state.status !== "valid") {
1067
+ failures.push(postFailure("waiver-evidence-invalid",
1068
+ `waiver for ${link.assertion_id} cites ${state.status} evidence${state.reason ? `: ${state.reason}` : ""}`,
1069
+ { spec_id: specId }));
1070
+ }
1071
+ }
1072
+ };
1073
+
1074
+ for (const draft of drafts) {
1075
+ const specId = draft?.spec_id ?? null;
1076
+ if (!Array.isArray(draft?.coverage?.behaviors)) {
1077
+ failures.push(postFailure("behaviors-shape",
1078
+ `draft ${specId} coverage.behaviors must be an array`, { spec_id: specId }));
1079
+ continue;
1080
+ }
1081
+ const seen = new Map();
1082
+ for (const link of draft.coverage.behaviors) {
1083
+ if (!link || typeof link !== "object" || !nonEmpty(link.assertion_id)) {
1084
+ failures.push(postFailure("link-shape",
1085
+ `draft ${specId} has a behavior link without an assertion_id`, { spec_id: specId }));
1086
+ continue;
1087
+ }
1088
+ const assertionId = link.assertion_id;
1089
+ const identity = responseIdentityForLink(link);
1090
+ const validIdentity = validResponseBranch(link, identity);
1091
+ const previous = seen.get(assertionId) ?? [];
1092
+ const sameIdentity = identity === null
1093
+ ? previous.some(item => item.identity === null)
1094
+ : previous.some(item => item.identity?.key === identity.key);
1095
+ const ambiguousSharing = previous.length > 0
1096
+ && (!validIdentity || previous.some(item => !item.valid));
1097
+ if (sameIdentity || ambiguousSharing) {
1098
+ failures.push(postFailure("link-duplicate",
1099
+ `draft ${specId} links assertion ${assertionId} more than once`, { spec_id: specId }));
1100
+ continue;
1101
+ }
1102
+ seen.set(assertionId, [...previous, { identity, valid: validIdentity }]);
1103
+ linked.add(assertionId);
1104
+
1105
+ if (!assertions.has(assertionId)) {
1106
+ failures.push(postFailure("link-assertion",
1107
+ `link names unknown assertion ${assertionId}`, { spec_id: specId }));
1108
+ }
1109
+ const disposition = planned.get(assertionId);
1110
+ if (!disposition) {
1111
+ failures.push(postFailure("link-disposition",
1112
+ `link for assertion ${assertionId} has no planned disposition`, { spec_id: specId }));
1113
+ continue;
1114
+ }
1115
+ if (!["specified", "waived", "unknown"].includes(link.status)) {
1116
+ failures.push(postFailure("link-status",
1117
+ `link for assertion ${assertionId} has invalid status ${link.status}`, { spec_id: specId }));
1118
+ continue;
1119
+ }
1120
+
1121
+ if (link.status === "specified") {
1122
+ if (disposition.status !== "specified") {
1123
+ failures.push(postFailure("link-conflict",
1124
+ `assertion ${assertionId} is planned ${disposition.status} but linked specified`, { spec_id: specId }));
1125
+ }
1126
+ const plannedSteps = asArray(disposition.steps);
1127
+ if (link.scenario !== disposition.scenario || plannedSteps.length === 0
1128
+ || !plannedSteps.every(step => asArray(link.steps).includes(step))) {
1129
+ failures.push(postFailure("link-plan",
1130
+ `specified link for ${assertionId} must use the pre-reviewed scenario and include every planned step`,
1131
+ { spec_id: specId }));
1132
+ }
1133
+ const scenarioNumber = link.scenario;
1134
+ if (!Number.isInteger(scenarioNumber) || scenarioNumber < 1
1135
+ || scenarioNumber > asArray(draft.scenarios).length) {
1136
+ failures.push(postFailure("link-scenario",
1137
+ `specified link for ${assertionId} references scenario ${scenarioNumber}, but draft ${specId} has ${asArray(draft.scenarios).length} scenarios`,
1138
+ { spec_id: specId }));
1139
+ } else {
1140
+ const scenarioSteps = draft.scenarios[scenarioNumber - 1]?.steps;
1141
+ const steps = asArray(link.steps);
1142
+ if (!Array.isArray(scenarioSteps) || steps.length === 0) {
1143
+ failures.push(postFailure("link-steps",
1144
+ `specified link for ${assertionId} must name steps of scenario ${scenarioNumber}`,
1145
+ { spec_id: specId }));
1146
+ } else {
1147
+ for (const step of steps) {
1148
+ if (!Number.isInteger(step) || step < 1 || step > scenarioSteps.length) {
1149
+ failures.push(postFailure("link-step",
1150
+ `specified link for ${assertionId} references step ${step}, but scenario ${scenarioNumber} has ${scenarioSteps.length} steps`,
1151
+ { spec_id: specId }));
1152
+ }
1153
+ }
1154
+ }
1155
+ // A scenario may reuse a path but never drop its precondition. Gate
1156
+ // axes the page does not already enforce at entry must be stated
1157
+ // where the gated behavior is specified.
1158
+ if (Array.isArray(scenarioSteps)) {
1159
+ const scenarioText = scenarioSteps.map(step => String(step ?? "")).join("\n");
1160
+ for (const gate of requiredGateTokens(assertions.get(assertionId), page)) {
1161
+ if (gate.tokens.some(token => mentionedIn(scenarioText, token))) continue;
1162
+ failures.push(postFailure("link-precondition",
1163
+ `specified link for ${assertionId} omits precondition "${gate.axis}": scenario ${scenarioNumber} steps do not mention ${gate.tokens.join(" / ")}`,
1164
+ { spec_id: specId }));
1165
+ }
1166
+ }
1167
+ }
1168
+ } else if (link.status === "waived") {
1169
+ const reason = link.reason;
1170
+ if (disposition.status !== reason) {
1171
+ failures.push(postFailure("link-conflict",
1172
+ `assertion ${assertionId} is planned ${disposition.status} but waived as ${reason}`,
1173
+ { spec_id: specId }));
1174
+ }
1175
+ if (reason === "duplicate-assertion") {
1176
+ const target = link.canonical_assertion_id;
1177
+ const plannedTarget = disposition.canonical_assertion_id ?? disposition.duplicate_of ?? null;
1178
+ if (!nonEmpty(target)) {
1179
+ failures.push(postFailure("waiver-canonical",
1180
+ `duplicate waiver for ${assertionId} must name a canonical assertion`, { spec_id: specId }));
1181
+ } else if (!nonEmpty(plannedTarget)) {
1182
+ failures.push(postFailure("waiver-canonical",
1183
+ `duplicate waiver for ${assertionId} has no planned canonical assertion`, { spec_id: specId }));
1184
+ } else if (target !== plannedTarget) {
1185
+ // A merely specified assertion is not enough: the draft link must
1186
+ // name the exact reviewed canonical the plan selected.
1187
+ failures.push(postFailure("waiver-canonical",
1188
+ `duplicate waiver for ${assertionId} names canonical ${target}, but the planned canonical is ${plannedTarget}`,
1189
+ { spec_id: specId }));
1190
+ } else if (!assertions.has(target)) {
1191
+ failures.push(postFailure("waiver-canonical",
1192
+ `duplicate waiver for ${assertionId} names unknown canonical assertion ${target}`,
1193
+ { spec_id: specId }));
1194
+ } else if (planned.get(target)?.status !== "specified") {
1195
+ failures.push(postFailure("waiver-canonical",
1196
+ `duplicate waiver for ${assertionId} needs a specified canonical target`, { spec_id: specId }));
1197
+ } else {
1198
+ canonicalTargets.add(target);
1199
+ }
1200
+ } else if (reason === "no-user-observable") {
1201
+ checkWaiverEvidence(link, specId);
1202
+ } else if (reason === "out-of-scope") {
1203
+ checkWaiverEvidence(link, specId);
1204
+ if (!OUT_OF_SCOPE_RULES.has(link.scope_rule) || link.scope_rule !== disposition.scope_rule) {
1205
+ failures.push(postFailure("waiver-scope",
1206
+ `out-of-scope waiver for ${assertionId} must repeat a supported planned scope_rule`, { spec_id: specId }));
1207
+ }
1208
+ } else {
1209
+ failures.push(postFailure("waiver-reason",
1210
+ `waiver for ${assertionId} has invalid reason ${reason}`, { spec_id: specId }));
1211
+ }
1212
+ } else {
1213
+ if (disposition.status !== "unknown") {
1214
+ failures.push(postFailure("link-conflict",
1215
+ `assertion ${assertionId} is planned ${disposition.status} but linked unknown`, { spec_id: specId }));
1216
+ }
1217
+ const unknownIds = asArray(link.unknown_ids);
1218
+ if (unknownIds.length === 0) {
1219
+ failures.push(postFailure("link-unknown",
1220
+ `unknown link for ${assertionId} must name unknown_ids`, { spec_id: specId }));
1221
+ }
1222
+ for (const unknownId of unknownIds) {
1223
+ const unknown = unknowns.get(unknownId);
1224
+ if (!unknown) {
1225
+ failures.push(postFailure("link-unknown",
1226
+ `unknown link for ${assertionId} names unknown ${unknownId}`, { spec_id: specId }));
1227
+ } else if (!unresolved.has(unknownId)) {
1228
+ failures.push(postFailure("link-unknown",
1229
+ `unknown link for ${assertionId} cites already-resolved unknown ${unknownId}`,
1230
+ { spec_id: specId }));
1231
+ } else if (unknown.affected_assertion_id !== assertionId) {
1232
+ failures.push(postFailure("link-unknown",
1233
+ `unknown ${unknownId} is not related to assertion ${assertionId}`, { spec_id: specId }));
1234
+ }
1235
+ }
1236
+ }
1237
+ }
1238
+ }
1239
+
1240
+ // Candidate-backed interaction locations are validated here rather than by
1241
+ // the legacy gate loop. A promoted candidate needs a claim whose scenario
1242
+ // agrees with its specified behavior link, a waived candidate needs an
1243
+ // exclusion, and an unknown candidate needs only its linked unresolved
1244
+ // unknown. Missing promoted/waived entries defer under partial delivery; a
1245
+ // present but wrong scenario is always a hard failure.
1246
+ const candidateInteractions = interactionDispositionMap({ evidence, discovery });
1247
+ if (candidateInteractions.size > 0) {
1248
+ // A `by_scenario` index is local to one draft, and a promoted disposition is
1249
+ // owned by the draft that specifies its assertion. Claims are indexed per
1250
+ // draft and never pooled, so a sibling draft's claim at the same location
1251
+ // can neither satisfy nor fail another draft's requirement.
1252
+ const claimsByDraft = new Map();
1253
+ const specifiedByAssertion = new Map();
1254
+ for (const [draftIndex, draft] of drafts.entries()) {
1255
+ const claimsAtLocation = new Map();
1256
+ for (const claim of asArray(draft?.coverage?.interactions)) {
1257
+ const item = claim?.item;
1258
+ if (!nonEmpty(item)) continue;
1259
+ const atIndex = item.lastIndexOf("@");
1260
+ const at = atIndex === -1 ? item : item.slice(atIndex + 1);
1261
+ if (!nonEmpty(at)) continue;
1262
+ if (!claimsAtLocation.has(at)) claimsAtLocation.set(at, []);
1263
+ claimsAtLocation.get(at).push(claim);
1264
+ }
1265
+ claimsByDraft.set(draftIndex, claimsAtLocation);
1266
+ for (const link of asArray(draft?.coverage?.behaviors)) {
1267
+ // The first draft that specifies an assertion owns its scenario index;
1268
+ // duplicate links across drafts are validated separately as link errors.
1269
+ if (link?.status !== "specified" || !nonEmpty(link?.assertion_id)) continue;
1270
+ if (specifiedByAssertion.has(link.assertion_id)) continue;
1271
+ specifiedByAssertion.set(link.assertion_id, {
1272
+ draftIndex,
1273
+ scenario: Number.isInteger(link.scenario) ? link.scenario : null,
1274
+ });
1275
+ }
1276
+ }
1277
+ const excludedAts = new Set();
1278
+ for (const draft of drafts) {
1279
+ for (const entry of asArray(draft?.coverage?.excluded)) {
1280
+ const item = typeof entry === "string" ? entry : entry?.item;
1281
+ if (nonEmpty(item)) excludedAts.add(item);
1282
+ }
1283
+ }
1284
+ const deferredRequirement = new Set();
1285
+ const deferRequirement = key => {
1286
+ if (deferredRequirement.has(key)) return;
1287
+ deferredRequirement.add(key);
1288
+ deferred += 1;
1289
+ };
1290
+ const reportedRequirement = new Set();
1291
+ for (const [at, dispositions] of candidateInteractions) {
1292
+ for (const disposition of dispositions) {
1293
+ switch (disposition.state) {
1294
+ case "promoted": {
1295
+ const specified = specifiedByAssertion.get(disposition.assertion_id);
1296
+ const claims = specified
1297
+ ? claimsByDraft.get(specified.draftIndex)?.get(at) ?? []
1298
+ // No draft specifies the assertion: the scenario check is not this
1299
+ // check's concern, so the legacy location-level claim requirement
1300
+ // still reads every draft.
1301
+ : [...claimsByDraft.values()].flatMap(byAt => byAt.get(at) ?? []);
1302
+ if (claims.length === 0) {
1303
+ if (partial) {
1304
+ deferRequirement(`claim:${at}`);
1305
+ break;
1306
+ }
1307
+ if (!reportedRequirement.has(`claim:${at}`)) {
1308
+ reportedRequirement.add(`claim:${at}`);
1309
+ failures.push(postFailure("interaction-missing",
1310
+ `interaction missing from coverage: ${at}`));
1311
+ }
1312
+ break;
1313
+ }
1314
+ if (!specified || specified.scenario === null) break;
1315
+ const scenario = specified.scenario;
1316
+ // One claim agreeing with this disposition's own scenario is
1317
+ // enough; a sibling draft's claim is not part of this check.
1318
+ if (claims.some(claim => claim?.by_scenario === scenario)) break;
1319
+ const mismatchKey = `scenario:${at}:${disposition.candidate_id}:${scenario}`;
1320
+ if (!reportedRequirement.has(mismatchKey)) {
1321
+ reportedRequirement.add(mismatchKey);
1322
+ const claimedScenarios = claims
1323
+ .map(claim => claim?.by_scenario)
1324
+ .filter(value => value !== undefined);
1325
+ failures.push(postFailure("interaction-scenario-mismatch",
1326
+ `interaction scenario mismatch: ${at} is claimed at scenario ${claimedScenarios.join(", ") || "unknown"} but its promoted assertion is specified at scenario ${scenario}`));
1327
+ }
1328
+ break;
1329
+ }
1330
+ case "waived":
1331
+ if (!excludedAts.has(at)) {
1332
+ if (partial) {
1333
+ deferRequirement(`exclusion:${at}`);
1334
+ break;
1335
+ }
1336
+ if (!reportedRequirement.has(`exclusion:${at}`)) {
1337
+ reportedRequirement.add(`exclusion:${at}`);
1338
+ failures.push(postFailure("interaction-missing-exclusion",
1339
+ `interaction missing from coverage.excluded: ${at}`));
1340
+ }
1341
+ }
1342
+ break;
1343
+ case "unknown": {
1344
+ const accounted = disposition.unknown_ids.some(unknownId => unresolved.has(unknownId));
1345
+ // An unknown with no unresolved linked unknown is still unfinished,
1346
+ // never a reason to demand a fabricated claim or exclusion.
1347
+ if (!accounted) deferRequirement(`unknown:${at}:${disposition.candidate_id}`);
1348
+ break;
1349
+ }
1350
+ default:
1351
+ deferRequirement(`incomplete:${at}:${disposition.candidate_id}`);
1352
+ break;
1353
+ }
1354
+ }
1355
+ }
1356
+ }
1357
+
1358
+ for (const target of canonicalTargets) {
1359
+ const hasSpecified = drafts.some(draft =>
1360
+ asArray(draft?.coverage?.behaviors).some(link =>
1361
+ link?.assertion_id === target && link?.status === "specified"));
1362
+ if (!hasSpecified) {
1363
+ failures.push(postFailure("canonical-link-missing",
1364
+ `canonical assertion ${target} has no specified behavior link`));
1365
+ }
1366
+ }
1367
+
1368
+ for (const assertionId of planned.keys()) {
1369
+ if (linked.has(assertionId)) continue;
1370
+ if (partial) {
1371
+ deferred += 1;
1372
+ continue;
1373
+ }
1374
+ failures.push(postFailure("missing-behavior-link",
1375
+ `assertion ${assertionId} has no coverage.behaviors link in any draft for this page`));
1376
+ }
1377
+
1378
+ return { failures, deferred };
1379
+ }
1380
+
1381
+ function semanticOperationIds(draft) {
1382
+ const ids = new Set();
1383
+ for (const scenario of asArray(draft?.scenarios)) {
1384
+ for (const endpoint of asArray(scenario?.contracts?.endpoints)) {
1385
+ if (nonEmpty(endpoint?.operation_id)) ids.add(endpoint.operation_id);
1386
+ }
1387
+ }
1388
+ for (const link of asArray(draft?.coverage?.behaviors)) {
1389
+ if (nonEmpty(link?.operation_id)) ids.add(link.operation_id);
1390
+ }
1391
+ return ids;
1392
+ }
1393
+
1394
+ function semanticDetailForDraft({ evidence, discovery, draft, isolated, unresolvedUnknowns }) {
1395
+ // Discovery contains the immutable assertions plus worker-authored semantic
1396
+ // additions. Both are evidence-backed and validated by the normal G4 passes;
1397
+ // limiting this input to immutable Evidence would make semantic review a
1398
+ // production no-op for newly reasoned entry/response behavior.
1399
+ const semanticEvidence = {
1400
+ ...evidence,
1401
+ assertions: [
1402
+ ...asArray(evidence?.assertions),
1403
+ ...asArray(discovery?.assertions),
1404
+ ],
1405
+ };
1406
+ if (isolated) {
1407
+ return evaluateSemanticDetail({
1408
+ draft,
1409
+ evidence: semanticEvidence,
1410
+ operationReviews: asArray(discovery?.operation_reviews),
1411
+ discovery,
1412
+ unresolvedUnknowns,
1413
+ });
1414
+ }
1415
+ // Older split-page drafts keep operation/review ownership local to each
1416
+ // draft. Uncited sibling operations cannot satisfy or fail this draft.
1417
+ const operationIds = semanticOperationIds(draft);
1418
+ return evaluateSemanticDetail({
1419
+ draft,
1420
+ evidence: {
1421
+ ...semanticEvidence,
1422
+ assertions: semanticEvidence.assertions.filter(assertion =>
1423
+ !nonEmpty(assertion?.operation_id) || operationIds.has(assertion.operation_id)),
1424
+ operation_candidates: asArray(evidence?.operation_candidates)
1425
+ .filter(operation => operationIds.has(operation?.operation_id)),
1426
+ },
1427
+ operationReviews: asArray(discovery?.operation_reviews)
1428
+ .filter(review => operationIds.has(review?.operation_id)),
1429
+ discovery,
1430
+ unresolvedUnknowns,
1431
+ });
1432
+ }
1433
+
1434
+ /**
1435
+ * Evaluate one page's post-authoring audit.
1436
+ *
1437
+ * Order matters and is shared with the pre-audit: prove the evidence anchor,
1438
+ * then reconcile discovery against immutable evidence, then validate the
1439
+ * source references. Digest/attempt binding and semantic reviews run on top of
1440
+ * that evidence-backed document.
1441
+ *
1442
+ * @returns {{status:"completed"|"incomplete"|"failed", failures:object[], pages:object, counts:object, discovery_digest:string}}
1443
+ */
1444
+ export function evaluatePostAudit({
1445
+ plan,
1446
+ evidence,
1447
+ discovery,
1448
+ preAudit,
1449
+ drafts,
1450
+ postReview,
1451
+ attempt,
1452
+ sourceProject,
1453
+ partial = false,
1454
+ } = {}) {
1455
+ if (!evidence || typeof evidence !== "object") {
1456
+ throw new TypeError("evaluatePostAudit: evidence must be an object");
1457
+ }
1458
+ const doc = discovery && typeof discovery === "object" ? discovery : {};
1459
+ const pre = preAudit && typeof preAudit === "object" ? preAudit : {};
1460
+ const post = postReview && typeof postReview === "object" ? postReview : {};
1461
+ const pageId = doc.page_id ?? evidence.page_id ?? null;
1462
+ const pageDigest = stableDigest(doc);
1463
+ const failures = [];
1464
+
1465
+ const pageDrafts = draftsOf(drafts).filter(draft => draft && draft.page_id === pageId);
1466
+
1467
+ if (!Number.isInteger(attempt) || attempt < 0) {
1468
+ failures.push(postFailure("attempt-invalid", `post-audit attempt ${attempt} is not a non-negative integer`));
1469
+ }
1470
+ for (const [label, value] of [
1471
+ ["discovery", doc.attempt],
1472
+ ["pre-audit", pre.attempt],
1473
+ ["post-review", post.attempt],
1474
+ ]) {
1475
+ if (value !== attempt) {
1476
+ failures.push(postFailure("attempt-mismatch",
1477
+ `${label} attempt ${value} does not match post-audit attempt ${attempt}`));
1478
+ }
1479
+ }
1480
+
1481
+ if (pre.discovery_digest !== pageDigest) {
1482
+ failures.push(postFailure("discovery-digest",
1483
+ `pre-audit discovery_digest does not match the page discovery for ${pageId}`));
1484
+ }
1485
+ if (post.discovery_digest !== pageDigest) {
1486
+ failures.push(postFailure("discovery-digest",
1487
+ `post-review discovery_digest does not match the page discovery for ${pageId}`));
1488
+ }
1489
+ for (const draft of pageDrafts) {
1490
+ if (draft.discovery_digest !== pageDigest) {
1491
+ failures.push(postFailure("draft-discovery-digest",
1492
+ `draft ${draft.spec_id} discovery_digest does not match the page discovery for ${pageId}`,
1493
+ { spec_id: draft.spec_id }));
1494
+ }
1495
+ }
1496
+ if (pageDrafts.length === 0 && !partial) {
1497
+ failures.push(postFailure("draft-missing", `no draft is present for ${pageId}`));
1498
+ }
1499
+
1500
+ try {
1501
+ assertBehaviorEvidenceAnchor({ plan, pageId, evidence });
1502
+ } catch (error) {
1503
+ failures.push(postFailure("evidence-anchor", error.message));
1504
+ }
1505
+ const reconciled = reconcileDiscovery({ evidence, discovery: doc, sourceProject });
1506
+ for (const failure of reconciled.failures) {
1507
+ failures.push(postFailure(failure.code, failure.message));
1508
+ }
1509
+ const scanCheck = checkInteractionScans({ plan, evidence, discovery: doc, pageId });
1510
+ for (const failure of scanCheck.failures) {
1511
+ failures.push(postFailure(failure.code, failure.message));
1512
+ }
1513
+ const lifecycleCheck = checkLifecycleScans({ evidence, discovery: doc, pageId });
1514
+ for (const failure of lifecycleCheck.failures) {
1515
+ failures.push(postFailure(failure.code, failure.message));
1516
+ }
1517
+ const driftUnknowns = sourceUnitDrift({ evidence, sourceProject });
1518
+ const evidenceCheck = evaluatePostEvidence({ evidence, discovery: doc, sourceProject, reconciled });
1519
+ failures.push(...evidenceCheck.failures);
1520
+
1521
+ if (pre.status === "failed") {
1522
+ failures.push(postFailure("pre-audit-failed", `pre-audit failed for ${pageId}`));
1523
+ }
1524
+
1525
+ const reviewResult = evaluateSemanticReviews({ discovery: doc, evidence, postReview: post });
1526
+ failures.push(...reviewResult.failures);
1527
+
1528
+ const linkResult = evaluateBehaviorLinks({
1529
+ discovery: doc,
1530
+ evidence,
1531
+ drafts: pageDrafts,
1532
+ page: asArray(plan?.pages).find(candidate => candidate?.page_id === pageId) ?? null,
1533
+ partial,
1534
+ unresolvedUnknowns: reconciled.unresolved_unknowns,
1535
+ sourceProject,
1536
+ });
1537
+ failures.push(...linkResult.failures);
1538
+
1539
+ const operationReview = evaluateOperationReviews({
1540
+ evidence,
1541
+ discovery: doc,
1542
+ drafts: pageDrafts,
1543
+ sourceProject,
1544
+ partial,
1545
+ });
1546
+ for (const operationFailure of operationReview.failures) {
1547
+ const { code, message, ...extra } = operationFailure;
1548
+ failures.push(postFailure(code, message, extra));
1549
+ }
1550
+
1551
+ const semanticResults = pageDrafts.map(draft => ({
1552
+ draft,
1553
+ result: semanticDetailForDraft({
1554
+ evidence,
1555
+ discovery: doc,
1556
+ draft,
1557
+ isolated: pageDrafts.length === 1,
1558
+ unresolvedUnknowns: reconciled.unresolved_unknowns,
1559
+ }),
1560
+ }));
1561
+ const semanticUnknowns = [];
1562
+ for (const { draft, result } of semanticResults) {
1563
+ for (const semanticFailure of result.failures) {
1564
+ const { code, message, ...extra } = semanticFailure;
1565
+ failures.push(postFailure(code, message, { spec_id: draft.spec_id ?? null, ...extra }));
1566
+ }
1567
+ semanticUnknowns.push(...result.unknowns.map(unknown => ({
1568
+ spec_id: draft.spec_id ?? null,
1569
+ ...unknown,
1570
+ })));
1571
+ }
1572
+ const semanticDetailIncomplete = semanticResults.some(({ result }) => result.unknowns.length > 0);
1573
+
1574
+ const reviewUnknowns = reviewResult.incomplete.map(assertionId => ({
1575
+ id: `review-incomplete:${assertionId}`,
1576
+ reason: "review-incomplete",
1577
+ scope: "assertion",
1578
+ affected_assertion_id: assertionId,
1579
+ next_action: "Complete the semantic evidence and coverage review for this assertion",
1580
+ }));
1581
+ const unresolvedUnknowns = [
1582
+ ...reconciled.unresolved_unknowns,
1583
+ ...reviewUnknowns,
1584
+ ...scanCheck.unknowns,
1585
+ ...lifecycleCheck.unknowns,
1586
+ ...operationReview.unknowns,
1587
+ ...semanticUnknowns,
1588
+ ...driftUnknowns,
1589
+ ];
1590
+ const scanIncomplete = scanStateIncomplete({ scanCheck, lifecycleCheck, unresolvedUnknowns });
1591
+ const postIncomplete = post.status === "failed" || post.status === "incomplete";
1592
+ const postAuditStatus = failures.length > 0
1593
+ ? "failed"
1594
+ : postIncomplete
1595
+ || reconciled.source_review_incomplete
1596
+ || scanIncomplete
1597
+ || reviewResult.incomplete.length > 0
1598
+ || linkResult.deferred > 0
1599
+ || operationReview.deferred > 0
1600
+ || semanticDetailIncomplete
1601
+ ? "incomplete"
1602
+ : "completed";
1603
+
1604
+ const dispositions = asArray(doc.planned);
1605
+ const candidateDispositions = asArray(doc.candidate_dispositions);
1606
+ const state = derivePageState({
1607
+ evidence,
1608
+ dispositions,
1609
+ candidateDispositions,
1610
+ preAudit: pre,
1611
+ postAuditStatus,
1612
+ unresolvedUnknowns,
1613
+ evidenceStatuses: evidenceCheck.statuses,
1614
+ sourceReviewIncomplete: reconciled.source_review_incomplete,
1615
+ scanIncomplete,
1616
+ driftUnknowns,
1617
+ sourceUnitReviews: reconciled.source_unit_reviews,
1618
+ interactionScans: scanCheck.records,
1619
+ lifecycleScans: lifecycleCheck.records,
1620
+ semanticDetailIncomplete,
1621
+ failures,
1622
+ });
1623
+
1624
+ return {
1625
+ status: failures.length > 0 ? "failed" : state.authoring_status === "passed" ? "completed" : "incomplete",
1626
+ failures,
1627
+ pages: { [pageId ?? "unknown"]: state },
1628
+ counts: state.counts,
1629
+ discovery_digest: pageDigest,
1630
+ attempt,
1631
+ };
1632
+ }
1633
+
1634
+ function loadEvidenceFromDisk({ outDir, pageId, sourceProject }) {
1635
+ return {
1636
+ ...loadPersistedEvidence(outDir, pageId),
1637
+ sourceProject,
1638
+ };
1639
+ }
1640
+
1641
+ function failedPage({ attempt, discovery, failures }) {
1642
+ return {
1643
+ status: "failed",
1644
+ failures,
1645
+ unknowns: [],
1646
+ dispositions: asArray(discovery?.planned),
1647
+ discovery_digest: discovery === undefined ? null : stableDigest(discovery),
1648
+ coverage_status: "partial",
1649
+ attempt,
1650
+ };
1651
+ }
1652
+
1653
+ /**
1654
+ * Run the pre-authoring audit for every page in one group.
1655
+ *
1656
+ * The strict-v2 ledger is checked before any evidence is trusted. The immutable
1657
+ * evidence directory is only read; the only write is the attempt-scoped
1658
+ * `pre-audit.json`.
1659
+ */
1660
+ export function runPreAudit({ outDir, groupId, attempt, sourceProject } = {}) {
1661
+ if (typeof outDir !== "string" || outDir === "") {
1662
+ throw new TypeError("runPreAudit: outDir must be a non-empty string");
1663
+ }
1664
+ if (typeof groupId !== "string" || groupId === "") {
1665
+ throw new TypeError("runPreAudit: groupId must be a non-empty string");
1666
+ }
1667
+ if (!Number.isInteger(attempt) || attempt < 1) {
1668
+ throw new TypeError("runPreAudit: attempt must be a positive integer");
1669
+ }
1670
+
1671
+ const plan = readJson(path.join(outDir, "plan.json"));
1672
+ const group = asArray(plan.groups).find(candidate => candidate?.group_id === groupId) ?? null;
1673
+ const discoveryPath = path.join(outDir, "behavior", `attempt-${attempt}`, groupId, "discovery.json");
1674
+ const groupDiscovery = readJson(discoveryPath);
1675
+ const projectRoot = sourceProject ?? plan.inputs?.sourceProject ?? plan.sourceProject ?? null;
1676
+ const ledger = fold(outDir);
1677
+
1678
+ let status = "completed";
1679
+ const groupFailures = [];
1680
+ const ledgerOk = ledger.plan_version === plan.plan_version;
1681
+ const attemptOk = groupDiscovery.attempt === attempt;
1682
+ const groupPages = group === null ? [] : asArray(group.pages);
1683
+ const discoveryByPage = new Map(
1684
+ asArray(groupDiscovery.pages).map(page => [page?.page_id, page]),
1685
+ );
1686
+
1687
+ if (group === null) {
1688
+ groupFailures.push(fail("unknown-group", `group ${groupId} is not present in plan.json`));
1689
+ }
1690
+ if (!ledgerOk) {
1691
+ groupFailures.push(fail("ledger-plan-version",
1692
+ `ledger plan_version ${ledger.plan_version} does not match plan.json ${plan.plan_version}`));
1693
+ }
1694
+ if (!attemptOk) {
1695
+ groupFailures.push(fail("attempt-mismatch",
1696
+ `discovery attempt ${groupDiscovery.attempt} does not match pre-audit attempt ${attempt}`));
1697
+ }
1698
+ for (const page of asArray(groupDiscovery.pages)) {
1699
+ if (!groupPages.includes(page?.page_id)) {
1700
+ groupFailures.push(fail("extra-page", `discovery page ${page?.page_id} does not belong to group ${groupId}`));
1701
+ }
1702
+ }
1703
+
1704
+ const pageResults = {};
1705
+ for (const pageId of groupPages) {
1706
+ const pageDiscovery = discoveryByPage.get(pageId);
1707
+ if (pageDiscovery === undefined) {
1708
+ pageResults[pageId] = failedPage({
1709
+ attempt,
1710
+ discovery: undefined,
1711
+ failures: [fail("missing-page-discovery", `discovery.json has no page entry for ${pageId}`)],
1712
+ });
1713
+ continue;
1714
+ }
1715
+ const blockers = [];
1716
+ if (!ledgerOk) {
1717
+ blockers.push(fail("ledger-plan-version",
1718
+ `ledger plan_version ${ledger.plan_version} does not match plan.json ${plan.plan_version}`));
1719
+ }
1720
+ if (!attemptOk) {
1721
+ blockers.push(fail("attempt-mismatch",
1722
+ `discovery attempt ${groupDiscovery.attempt} does not match pre-audit attempt ${attempt}`));
1723
+ }
1724
+ if (blockers.length > 0) {
1725
+ pageResults[pageId] = failedPage({ attempt, discovery: pageDiscovery, failures: blockers });
1726
+ continue;
1727
+ }
1728
+ let evidence;
1729
+ try {
1730
+ evidence = loadEvidenceFromDisk({ outDir, pageId, sourceProject: projectRoot });
1731
+ } catch (error) {
1732
+ pageResults[pageId] = failedPage({
1733
+ attempt,
1734
+ discovery: pageDiscovery,
1735
+ failures: [fail("evidence-unreadable", `cannot read evidence for ${pageId}: ${error.message}`)],
1736
+ });
1737
+ continue;
1738
+ }
1739
+ try {
1740
+ pageResults[pageId] = evaluatePreAudit({
1741
+ plan, evidence, discovery: pageDiscovery, sourceProject: projectRoot,
1742
+ includeLiveDrift: true,
1743
+ });
1744
+ } catch (error) {
1745
+ // Corrupt evidence must become a recorded G4-style failure, never an
1746
+ // uncaught exception that exits 2 and leaves no audit behind.
1747
+ pageResults[pageId] = failedPage({
1748
+ attempt,
1749
+ discovery: pageDiscovery,
1750
+ failures: [fail("malformed-evidence", `malformed evidence for ${pageId}: ${error.message}`)],
1751
+ });
1752
+ }
1753
+ }
1754
+
1755
+ if (groupFailures.length > 0) {
1756
+ status = "failed";
1757
+ } else if (Object.values(pageResults).some(page => page.status === "failed")) {
1758
+ status = "failed";
1759
+ } else if (Object.values(pageResults).some(page => page.status === "incomplete")) {
1760
+ status = "incomplete";
1761
+ }
1762
+
1763
+ const groupDigest = canonicalGroupDiscoveryDigest(groupDiscovery);
1764
+ const coverageStatus = status !== "completed"
1765
+ || Object.values(pageResults).some(page => page.coverage_status === "partial")
1766
+ ? "partial"
1767
+ : "complete";
1768
+
1769
+ const audit = {
1770
+ status,
1771
+ discovery_digest: groupDigest,
1772
+ pages: pageResults,
1773
+ attempt,
1774
+ coverage_status: coverageStatus,
1775
+ };
1776
+ writeJsonAtomic(path.join(outDir, "behavior", `attempt-${attempt}`, groupId, "pre-audit.json"), audit);
1777
+ return audit;
1778
+ }
1779
+
1780
+ function readAttemptArtifact(file) {
1781
+ try {
1782
+ return { value: readJson(file), missing: false, malformed: false };
1783
+ } catch (error) {
1784
+ if (error?.code === "ENOENT") return { value: undefined, missing: true, malformed: false };
1785
+ return { value: undefined, missing: false, malformed: true, error };
1786
+ }
1787
+ }
1788
+
1789
+ function assertObject(value) {
1790
+ return value !== null && typeof value === "object" && !Array.isArray(value);
1791
+ }
1792
+
1793
+ function setDifference(left, right) {
1794
+ const rightSet = new Set(right);
1795
+ return left.filter(value => !rightSet.has(value));
1796
+ }
1797
+
1798
+ /**
1799
+ * Evaluate every behavior page of one group against the attempt's immutable
1800
+ * evidence and audit artifacts. Read-only: the caller's commit phase owns all
1801
+ * writes.
1802
+ */
1803
+ export function evaluateBehaviorGroup({
1804
+ outDir,
1805
+ plan,
1806
+ group,
1807
+ pages,
1808
+ drafts,
1809
+ partial = false,
1810
+ ledgerPlanVersion,
1811
+ attempt: attemptOverride,
1812
+ sourceProject,
1813
+ requireAuditArtifacts = false,
1814
+ } = {}) {
1815
+ if (!group || group.kind === "shared") return null;
1816
+ const pageMap = pages instanceof Map ? pages : new Map(Object.entries(pages ?? {}));
1817
+ const groupPages = [...new Set(asArray(group.pages))];
1818
+ const behaviorPages = groupPages.filter(pageId => pageMap.get(pageId)?.behavior);
1819
+ if (behaviorPages.length === 0) return null;
1820
+
1821
+ const failures = [];
1822
+ const pageResults = {};
1823
+ let state = null;
1824
+ let ledgerError = null;
1825
+ try {
1826
+ state = fold(outDir);
1827
+ } catch (error) {
1828
+ ledgerError = error;
1829
+ }
1830
+ const resolvedAttempt = Number.isInteger(attemptOverride)
1831
+ ? attemptOverride
1832
+ : state?.groups.get(group.group_id)?.attempt ?? 0;
1833
+ const resolvedPlanVersion = ledgerPlanVersion !== undefined ? ledgerPlanVersion : state?.plan_version;
1834
+ const projectRoot = sourceProject ?? plan?.inputs?.sourceProject ?? plan?.sourceProject ?? null;
1835
+
1836
+ if (ledgerError) {
1837
+ failures.push(postFailure("ledger-unreadable", `cannot read the behavior ledger: ${ledgerError.message}`));
1838
+ }
1839
+ try {
1840
+ assertPlanContentVersion(plan);
1841
+ } catch (error) {
1842
+ failures.push(postFailure("plan-content", error.message));
1843
+ }
1844
+ if (resolvedPlanVersion !== plan?.plan_version) {
1845
+ failures.push(postFailure("ledger-plan-version",
1846
+ `ledger plan_version ${resolvedPlanVersion} does not match plan.json ${plan?.plan_version}`));
1847
+ }
1848
+ const ledgerBarrier = failures.length > 0;
1849
+
1850
+ const behaviorDir = path.join(outDir, "behavior", `attempt-${resolvedAttempt}`, group.group_id);
1851
+ const discoveryArtifact = readAttemptArtifact(path.join(behaviorDir, "discovery.json"));
1852
+ const preArtifact = readAttemptArtifact(path.join(behaviorDir, "pre-audit.json"));
1853
+ const postArtifact = readAttemptArtifact(path.join(behaviorDir, "post-review.json"));
1854
+
1855
+ // A complete submission/finalization may report genuine blind spots, but it
1856
+ // may not treat deleted or never-written audit artifacts as a blind spot.
1857
+ if (requireAuditArtifacts) {
1858
+ for (const [artifact, name, code] of [
1859
+ [discoveryArtifact, "discovery.json", "missing-discovery"],
1860
+ [preArtifact, "pre-audit.json", "missing-pre-audit"],
1861
+ [postArtifact, "post-review.json", "missing-post-review"],
1862
+ ]) {
1863
+ if (artifact.missing) failures.push(postFailure(code, `${name} is required before finalization`));
1864
+ }
1865
+ }
1866
+
1867
+ const allDrafts = draftsOf(drafts);
1868
+ const groupSpecIds = asArray(group.spec_ids);
1869
+ const draftsComplete = groupSpecIds.every(specId =>
1870
+ allDrafts.some(draft => draft?.spec_id === specId));
1871
+
1872
+ // `coverage.behaviors` is a gate input whenever it is present. A non-array
1873
+ // value is a hard G4 shape failure even when discovery is missing or the group
1874
+ // would otherwise fall back to partial, so it can never be silently treated as
1875
+ // an empty link list.
1876
+ for (const draft of allDrafts) {
1877
+ if (!draft?.coverage || !("behaviors" in draft.coverage)) continue;
1878
+ if (!Array.isArray(draft.coverage.behaviors)) {
1879
+ failures.push(postFailure("behaviors-shape",
1880
+ `draft ${draft.spec_id} coverage.behaviors must be an array`,
1881
+ { spec_id: draft.spec_id ?? null }));
1882
+ }
1883
+ }
1884
+
1885
+ const groupAssertionIds = new Set();
1886
+
1887
+ let groupDigest = null;
1888
+ const discoveryByPage = new Map();
1889
+ if (discoveryArtifact.missing) {
1890
+ // A missing discovery is only honest unfinished work when the audit never
1891
+ // ran and no draft has been linked to behavior. Once pre-audit state exists,
1892
+ // or a draft already claims behavior coverage, the missing document is a
1893
+ // hard tamper signal rather than a path to partial delivery.
1894
+ const hasPreAudit = !preArtifact.missing;
1895
+ const hasBehaviorLinks = allDrafts.some(draft =>
1896
+ asArray(draft?.coverage?.behaviors).length > 0);
1897
+ if (!requireAuditArtifacts && (hasPreAudit || hasBehaviorLinks)) {
1898
+ failures.push(postFailure("missing-discovery",
1899
+ `behavior discovery.json is missing although${hasPreAudit ? " pre-audit state exists" : ""}`
1900
+ + `${hasPreAudit && hasBehaviorLinks ? " and" : ""}`
1901
+ + `${hasBehaviorLinks ? " group drafts already carry behavior links" : ""}`));
1902
+ }
1903
+ } else if (discoveryArtifact.malformed) {
1904
+ failures.push(postFailure("malformed-discovery", `behavior discovery.json is malformed: ${discoveryArtifact.error.message}`));
1905
+ } else {
1906
+ const document = discoveryArtifact.value;
1907
+ if (!assertObject(document) || !Array.isArray(document.pages)) {
1908
+ failures.push(postFailure("malformed-discovery", "behavior discovery.json needs a pages array"));
1909
+ } else {
1910
+ groupDigest = canonicalGroupDiscoveryDigest(document);
1911
+ if (document.attempt !== resolvedAttempt) {
1912
+ failures.push(postFailure("attempt-mismatch",
1913
+ `discovery attempt ${document.attempt} does not match attempt ${resolvedAttempt}`));
1914
+ }
1915
+ const seen = new Set();
1916
+ for (const page of document.pages) {
1917
+ if (!assertObject(page) || !nonEmpty(page.page_id)) {
1918
+ failures.push(postFailure("malformed-discovery", "discovery pages need a page_id"));
1919
+ continue;
1920
+ }
1921
+ if (seen.has(page.page_id)) {
1922
+ failures.push(postFailure("duplicate-page-discovery",
1923
+ `discovery has more than one entry for ${page.page_id}`));
1924
+ continue;
1925
+ }
1926
+ seen.add(page.page_id);
1927
+ discoveryByPage.set(page.page_id, page);
1928
+ for (const assertion of asArray(page.assertions)) {
1929
+ if (nonEmpty(assertion?.id)) groupAssertionIds.add(assertion.id);
1930
+ }
1931
+ }
1932
+ for (const extra of setDifference([...seen], groupPages)) {
1933
+ failures.push(postFailure("extra-page",
1934
+ `discovery page ${extra} does not belong to group ${group.group_id}`));
1935
+ }
1936
+ for (const missing of setDifference(groupPages, [...seen])) {
1937
+ failures.push(postFailure("missing-page-discovery",
1938
+ `discovery has no page entry for ${missing}`));
1939
+ }
1940
+ }
1941
+ }
1942
+
1943
+ let pre = preArtifact.value;
1944
+ if (preArtifact.malformed) {
1945
+ failures.push(postFailure("malformed-pre-audit", `pre-audit.json is malformed: ${preArtifact.error.message}`));
1946
+ } else if (pre !== undefined) {
1947
+ if (!assertObject(pre) || !assertObject(pre.pages)
1948
+ || !Number.isInteger(pre.attempt) || !nonEmpty(pre.discovery_digest)) {
1949
+ failures.push(postFailure("malformed-pre-audit", "pre-audit.json needs attempt, discovery_digest, and pages"));
1950
+ pre = undefined;
1951
+ } else {
1952
+ if (pre.attempt !== resolvedAttempt) {
1953
+ failures.push(postFailure("attempt-mismatch",
1954
+ `pre-audit attempt ${pre.attempt} does not match attempt ${resolvedAttempt}`));
1955
+ }
1956
+ if (groupDigest !== null && pre.discovery_digest !== groupDigest) {
1957
+ failures.push(postFailure("discovery-digest",
1958
+ "pre-audit discovery_digest does not match the group discovery document"));
1959
+ }
1960
+ const prePageIds = Object.keys(pre.pages);
1961
+ for (const extra of setDifference(prePageIds, groupPages)) {
1962
+ failures.push(postFailure("extra-page-audit", `pre-audit has an entry for unknown page ${extra}`));
1963
+ }
1964
+ for (const missing of setDifference(groupPages, prePageIds)) {
1965
+ failures.push(postFailure("missing-page-audit", `pre-audit has no entry for page ${missing}`));
1966
+ }
1967
+ }
1968
+ }
1969
+
1970
+ let post = postArtifact.value;
1971
+ if (postArtifact.malformed) {
1972
+ failures.push(postFailure("malformed-post-review", `post-review.json is malformed: ${postArtifact.error.message}`));
1973
+ } else if (post !== undefined) {
1974
+ if (!assertObject(post) || !assertObject(post.page_digests) || !Array.isArray(post.reviews)
1975
+ || !Number.isInteger(post.attempt) || !nonEmpty(post.discovery_digest)) {
1976
+ failures.push(postFailure("malformed-post-review",
1977
+ "post-review.json needs attempt, discovery_digest, page_digests, and reviews"));
1978
+ post = undefined;
1979
+ } else {
1980
+ if (post.attempt !== resolvedAttempt) {
1981
+ failures.push(postFailure("attempt-mismatch",
1982
+ `post-review attempt ${post.attempt} does not match attempt ${resolvedAttempt}`));
1983
+ }
1984
+ if (groupDigest !== null && post.discovery_digest !== groupDigest) {
1985
+ failures.push(postFailure("discovery-digest",
1986
+ "post-review discovery_digest does not match the group discovery document"));
1987
+ }
1988
+ const postPageIds = Object.keys(post.page_digests);
1989
+ for (const extra of setDifference(postPageIds, groupPages)) {
1990
+ failures.push(postFailure("extra-page-digest", `post-review has a digest for unknown page ${extra}`));
1991
+ }
1992
+ for (const missing of setDifference(groupPages, postPageIds)) {
1993
+ failures.push(postFailure("missing-page-digest", `post-review has no digest for page ${missing}`));
1994
+ }
1995
+ }
1996
+ }
1997
+
1998
+ // The group drafts digest covers every canonical group draft. A partial call
1999
+ // with missing siblings defers that whole-page completeness, while a complete
2000
+ // call still enforces the exact sorted digest.
2001
+ if (post !== undefined && !(partial && !draftsComplete)) {
2002
+ const draftFailure = evaluateGroupDraftDigest({ drafts, postReview: post });
2003
+ if (draftFailure !== null) failures.push(draftFailure);
2004
+ }
2005
+
2006
+ for (const review of post !== undefined ? asArray(post.reviews) : []) {
2007
+ if (!review || typeof review !== "object" || !nonEmpty(review.assertion_id)) {
2008
+ failures.push(postFailure("review-shape", "post-review reviews entries need an assertion_id"));
2009
+ }
2010
+ }
2011
+
2012
+ const units = asArray(plan?.spec_units);
2013
+ const pageSpecIdsFor = pageId => groupSpecIds.filter(specId => {
2014
+ const unit = units.find(candidate => candidate.spec_id === specId);
2015
+ return (unit?.page_id ?? specId) === pageId;
2016
+ });
2017
+
2018
+ for (const pageId of groupPages) {
2019
+ if (ledgerBarrier) {
2020
+ pageResults[pageId] = placeholderPageState({ preAudit: undefined, failures });
2021
+ continue;
2022
+ }
2023
+ const pageDiscovery = discoveryByPage.get(pageId);
2024
+ if (!pageDiscovery) {
2025
+ const stateForPage = placeholderPageState({ preAudit: pre?.pages?.[pageId], failures: [] });
2026
+ pageResults[pageId] = stateForPage;
2027
+ continue;
2028
+ }
2029
+
2030
+ let evidence;
2031
+ try {
2032
+ evidence = loadEvidenceFromDisk({ outDir, pageId, sourceProject: projectRoot });
2033
+ } catch (error) {
2034
+ const failure = postFailure("evidence-unreadable",
2035
+ `cannot read evidence for ${pageId}: ${error.message}`, { spec_id: pageSpecIdsFor(pageId)[0] ?? null });
2036
+ failures.push(failure);
2037
+ pageResults[pageId] = placeholderPageState({ preAudit: pre?.pages?.[pageId], failures: [failure] });
2038
+ continue;
2039
+ }
2040
+ for (const assertion of asArray(evidence.assertions)) {
2041
+ if (nonEmpty(assertion?.id)) groupAssertionIds.add(assertion.id);
2042
+ }
2043
+
2044
+ const pageDigest = stableDigest(pageDiscovery);
2045
+ let pagePre = pre?.pages?.[pageId] ?? {
2046
+ status: "incomplete",
2047
+ coverage_status: "partial",
2048
+ attempt: resolvedAttempt,
2049
+ discovery_digest: pageDigest,
2050
+ };
2051
+ if (pre !== undefined && pageId in pre.pages) {
2052
+ try {
2053
+ // Honest live drift may have appeared before or after the recorded
2054
+ // pre-audit. Accept either projection, but a tampered discovery changes
2055
+ // both, so the fence still catches it.
2056
+ const recomputedWithDrift = evaluatePreAudit({
2057
+ plan,
2058
+ evidence,
2059
+ discovery: pageDiscovery,
2060
+ sourceProject: projectRoot,
2061
+ includeLiveDrift: true,
2062
+ });
2063
+ const recomputedWithoutDrift = evaluatePreAudit({
2064
+ plan,
2065
+ evidence,
2066
+ discovery: pageDiscovery,
2067
+ sourceProject: projectRoot,
2068
+ includeLiveDrift: false,
2069
+ });
2070
+ const recordedPre = pre.pages[pageId];
2071
+ const matches = projection =>
2072
+ recordedPre.status === projection.status
2073
+ && recordedPre.coverage_status === projection.coverage_status
2074
+ && recordedPre.discovery_digest === pageDigest
2075
+ && recordedPre.attempt === resolvedAttempt;
2076
+ if (!matches(recomputedWithDrift) && !matches(recomputedWithoutDrift)) {
2077
+ failures.push(postFailure("pre-audit-mismatch",
2078
+ `pre-audit verdict for ${pageId} does not match a fresh evaluation of Evidence and discovery`,
2079
+ { spec_id: pageSpecIdsFor(pageId)[0] ?? null }));
2080
+ recomputedWithDrift.status = "failed";
2081
+ recomputedWithDrift.coverage_status = "partial";
2082
+ }
2083
+ // Only the fresh verdict is authoritative, and the live-source
2084
+ // projection is the one the page actually has. The disk artifact is a
2085
+ // diagnostic receipt, never a worker-editable source of trust.
2086
+ pagePre = recomputedWithDrift;
2087
+ } catch (error) {
2088
+ failures.push(postFailure("malformed-discovery",
2089
+ `cannot recompute pre-audit for ${pageId}: ${error.message}`,
2090
+ { spec_id: pageSpecIdsFor(pageId)[0] ?? null }));
2091
+ pagePre = {
2092
+ status: "failed",
2093
+ coverage_status: "partial",
2094
+ attempt: resolvedAttempt,
2095
+ discovery_digest: pageDigest,
2096
+ };
2097
+ }
2098
+ }
2099
+ if (pre !== undefined && !(pageId in pre.pages)) {
2100
+ const failure = postFailure("missing-page-audit",
2101
+ `pre-audit has no entry for page ${pageId}`,
2102
+ { spec_id: pageSpecIdsFor(pageId)[0] ?? null });
2103
+ failures.push(failure);
2104
+ }
2105
+
2106
+ let pagePost;
2107
+ if (post !== undefined) {
2108
+ if (!(pageId in post.page_digests)) {
2109
+ failures.push(postFailure("missing-page-digest",
2110
+ `post-review has no page digest for ${pageId}`,
2111
+ { spec_id: pageSpecIdsFor(pageId)[0] ?? null }));
2112
+ }
2113
+ const pageAssertionIds = new Set([
2114
+ ...asArray(pageDiscovery.assertions).map(assertion => assertion?.id).filter(Boolean),
2115
+ ...asArray(evidence.assertions).map(assertion => assertion?.id).filter(Boolean),
2116
+ ]);
2117
+ pagePost = {
2118
+ ...post,
2119
+ discovery_digest: post.page_digests[pageId],
2120
+ reviews: asArray(post.reviews)
2121
+ .filter(review => pageAssertionIds.has(review?.assertion_id)),
2122
+ };
2123
+ } else {
2124
+ pagePost = {
2125
+ attempt: resolvedAttempt,
2126
+ discovery_digest: pageDigest,
2127
+ reviews: [],
2128
+ status: "incomplete",
2129
+ };
2130
+ }
2131
+
2132
+ const pageDrafts = new Map(allDrafts
2133
+ .filter(draft => draft?.page_id === pageId && groupSpecIds.includes(draft.spec_id))
2134
+ .map(draft => [draft.spec_id, draft]));
2135
+
2136
+ let pageResult;
2137
+ try {
2138
+ pageResult = evaluatePostAudit({
2139
+ plan,
2140
+ evidence,
2141
+ discovery: pageDiscovery,
2142
+ preAudit: pagePre,
2143
+ drafts: pageDrafts,
2144
+ postReview: pagePost,
2145
+ attempt: resolvedAttempt,
2146
+ sourceProject: projectRoot,
2147
+ partial,
2148
+ });
2149
+ } catch (error) {
2150
+ const failure = postFailure("malformed-evidence",
2151
+ `malformed evidence for ${pageId}: ${error.message}`,
2152
+ { spec_id: pageSpecIdsFor(pageId)[0] ?? null });
2153
+ failures.push(failure);
2154
+ pageResults[pageId] = placeholderPageState({ preAudit: pagePre, failures: [failure] });
2155
+ continue;
2156
+ }
2157
+
2158
+ const pageSpecIds = pageSpecIdsFor(pageId);
2159
+ for (const failure of pageResult.failures) {
2160
+ failures.push({
2161
+ ...failure,
2162
+ spec_id: failure.spec_id === undefined ? pageSpecIds[0] ?? null : failure.spec_id,
2163
+ });
2164
+ }
2165
+ let pageState = pageResult.pages[pageId] ?? placeholderPageState({ preAudit: pagePre, failures: pageResult.failures });
2166
+ if (partial && !pageSpecIds.every(specId => allDrafts.some(draft => draft?.spec_id === specId))) {
2167
+ pageState = { ...pageState, authoring_status: "partial", coverage_status: "partial" };
2168
+ }
2169
+ const freshness = assertGraphFreshness({
2170
+ evidence,
2171
+ sourceProject: projectRoot,
2172
+ indexAction: plan?.index?.action ?? "none",
2173
+ });
2174
+ if (freshness.unknowns.length > 0) {
2175
+ const unknowns = new Map();
2176
+ for (const unknown of [...asArray(pageState.unknowns), ...freshness.unknowns]) {
2177
+ const key = unknown?.id ?? stableDigest(unknown);
2178
+ if (!unknowns.has(key)) unknowns.set(key, unknown);
2179
+ }
2180
+ pageState = {
2181
+ ...pageState,
2182
+ coverage_status: "partial",
2183
+ delivery_status: pageState.delivery_status === "failed" ? "failed" : "delivered-partial",
2184
+ unknowns: [...unknowns.values()],
2185
+ };
2186
+ }
2187
+ pageResults[pageId] = pageState;
2188
+ }
2189
+
2190
+ // The group scope owns the page union. A review ID that matches no page
2191
+ // assertion set cannot be filtered into any page's evaluator, so it must be
2192
+ // rejected here rather than disappearing from every page projection.
2193
+ for (const review of post !== undefined ? asArray(post.reviews) : []) {
2194
+ if (nonEmpty(review?.assertion_id) && !groupAssertionIds.has(review.assertion_id)) {
2195
+ failures.push(postFailure("review-extra",
2196
+ `post-review names unknown assertion ${review.assertion_id}`));
2197
+ }
2198
+ }
2199
+
2200
+ const counts = { specified: 0, waived: 0, unknown: 0, conflicted: 0 };
2201
+ for (const pageState of Object.values(pageResults)) {
2202
+ for (const key of Object.keys(counts)) counts[key] += pageState.counts?.[key] ?? 0;
2203
+ }
2204
+ const status = failures.length > 0
2205
+ ? "failed"
2206
+ : Object.values(pageResults).every(page => page.authoring_status === "passed")
2207
+ ? "completed"
2208
+ : "incomplete";
2209
+ const coverageStatus = failures.length > 0 || Object.values(pageResults)
2210
+ .some(page => page.coverage_status !== "complete") ? "partial" : "complete";
2211
+
2212
+ return {
2213
+ status,
2214
+ failures,
2215
+ pages: pageResults,
2216
+ counts,
2217
+ discovery_digest: groupDigest,
2218
+ coverage_status: coverageStatus,
2219
+ attempt: resolvedAttempt,
2220
+ };
2221
+ }
2222
+
2223
+ function readGroupDrafts(outDir, group, attempt) {
2224
+ const drafts = new Map();
2225
+ for (const specId of asArray(group?.spec_ids)) {
2226
+ try {
2227
+ drafts.set(specId, readJson(path.join(outDir, "drafts", `attempt-${attempt}`, `${stemOf(specId)}.json`)));
2228
+ } catch (error) {
2229
+ if (error?.code !== "ENOENT") throw error;
2230
+ }
2231
+ }
2232
+ return drafts;
2233
+ }
2234
+
2235
+ /**
2236
+ * Run the post-authoring audit for every page in one group and write the
2237
+ * operator's attempt-scoped `post-audit.json`. It never writes evidence or
2238
+ * drafts, and submit/recovery call the shared evaluator read-only instead.
2239
+ */
2240
+ export function runPostAudit({ outDir, groupId, attempt, sourceProject } = {}) {
2241
+ if (typeof outDir !== "string" || outDir === "") {
2242
+ throw new TypeError("runPostAudit: outDir must be a non-empty string");
2243
+ }
2244
+ if (typeof groupId !== "string" || groupId === "") {
2245
+ throw new TypeError("runPostAudit: groupId must be a non-empty string");
2246
+ }
2247
+ if (!Number.isInteger(attempt) || attempt < 0) {
2248
+ throw new TypeError("runPostAudit: attempt must be a non-negative integer");
2249
+ }
2250
+
2251
+ const plan = readJson(path.join(outDir, "plan.json"));
2252
+ const group = asArray(plan.groups).find(candidate => candidate?.group_id === groupId) ?? null;
2253
+ if (group === null) {
2254
+ const audit = {
2255
+ status: "failed",
2256
+ discovery_digest: null,
2257
+ pages: {},
2258
+ counts: { specified: 0, waived: 0, unknown: 0, conflicted: 0 },
2259
+ coverage_status: "partial",
2260
+ attempt,
2261
+ failures: [postFailure("unknown-group", `group ${groupId} is not present in plan.json`)],
2262
+ };
2263
+ writeJsonAtomic(path.join(outDir, "behavior", `attempt-${attempt}`, groupId, "post-audit.json"), audit);
2264
+ return audit;
2265
+ }
2266
+
2267
+ const drafts = readGroupDrafts(outDir, group, attempt);
2268
+ let ledgerPlanVersion;
2269
+ try {
2270
+ ledgerPlanVersion = fold(outDir).plan_version;
2271
+ } catch {
2272
+ ledgerPlanVersion = null;
2273
+ }
2274
+ const behavior = evaluateBehaviorGroup({
2275
+ outDir,
2276
+ plan,
2277
+ group,
2278
+ pages: new Map(asArray(plan.pages).map(page => [page.page_id, page])),
2279
+ drafts,
2280
+ partial: !asArray(group.spec_ids).every(specId => drafts.has(specId)),
2281
+ ledgerPlanVersion,
2282
+ attempt,
2283
+ sourceProject: sourceProject ?? plan.inputs?.sourceProject ?? plan.sourceProject ?? null,
2284
+ });
2285
+ const audit = behavior ?? {
2286
+ status: "failed",
2287
+ discovery_digest: null,
2288
+ pages: {},
2289
+ counts: { specified: 0, waived: 0, unknown: 0, conflicted: 0 },
2290
+ coverage_status: "partial",
2291
+ attempt,
2292
+ failures: [postFailure("behavior-disabled", `group ${groupId} has no behavior-enabled page`)],
2293
+ };
2294
+ writeJsonAtomic(path.join(outDir, "behavior", `attempt-${attempt}`, groupId, "post-audit.json"), audit);
2295
+ return audit;
2296
+ }
2297
+
2298
+ function sha256File(file) {
2299
+ return crypto.createHash("sha256").update(fs.readFileSync(file)).digest("hex");
2300
+ }
2301
+
2302
+ const BEHAVIOR_EVIDENCE_FILES = Object.freeze([
2303
+ "composition.json",
2304
+ "candidates.json",
2305
+ "assertions.json",
2306
+ "unknowns.json",
2307
+ ]);
2308
+
2309
+ /**
2310
+ * Collect the submission/commit fence for immutable evidence and the
2311
+ * attempt-scoped audit artifacts. The four fixed evidence files of every
2312
+ * behavior page are always present in the map: a file missing at collection
2313
+ * time is recorded as `null` so a later appearance is a conflict rather than a
2314
+ * newly discovered expected artifact.
2315
+ *
2316
+ * @returns {Map<string, string|null>} absolute path -> sha256 (or null)
2317
+ */
2318
+ export function collectBehaviorArtifactDigests({ outDir, groupId, attempt, plan } = {}) {
2319
+ const root = path.resolve(outDir);
2320
+ const digests = new Map();
2321
+
2322
+ let resolvedPlan = plan;
2323
+ if (!resolvedPlan || typeof resolvedPlan !== "object") {
2324
+ try {
2325
+ resolvedPlan = readJson(path.join(root, "plan.json"));
2326
+ } catch {
2327
+ resolvedPlan = null;
2328
+ }
2329
+ }
2330
+ const behaviorPageIds = [...new Set(asArray(resolvedPlan?.pages)
2331
+ .filter(page => page?.behavior && nonEmpty(page.page_id))
2332
+ .map(page => page.page_id))];
2333
+ for (const pageId of behaviorPageIds) {
2334
+ for (const name of BEHAVIOR_EVIDENCE_FILES) {
2335
+ const file = path.resolve(path.join(root, "evidence", stemOf(pageId), name));
2336
+ digests.set(file, fs.existsSync(file) ? sha256File(file) : null);
2337
+ }
2338
+ }
2339
+
2340
+ for (const file of listFilesRecursively(path.join(root, "evidence"))) {
2341
+ digests.set(path.resolve(file), sha256File(file));
2342
+ }
2343
+ const behaviorDir = path.join(root, "behavior", `attempt-${attempt}`, groupId);
2344
+ for (const name of ["discovery.json", "pre-audit.json", "post-review.json", "post-audit.json"]) {
2345
+ const file = path.resolve(path.join(behaviorDir, name));
2346
+ digests.set(file, fs.existsSync(file) ? sha256File(file) : null);
2347
+ }
2348
+ return new Map([...digests.entries()]
2349
+ .sort(([left], [right]) => (left < right ? -1 : left > right ? 1 : 0)));
2350
+ }
2351
+
2352
+ /**
2353
+ * Verify that a later observation is still within an already-complete
2354
+ * baseline. New keys and `null` -> present transitions are hard conflicts: they
2355
+ * must never be merged into the baseline after validation began.
2356
+ */
2357
+ export function assertBehaviorArtifactBaseline(baseline, observed) {
2358
+ const expected = baseline ?? new Map();
2359
+ const current = observed ?? new Map();
2360
+ for (const file of current.keys()) {
2361
+ if (!expected.has(file)) {
2362
+ throw new Error(`behavior artifact appeared after baseline: ${file}`);
2363
+ }
2364
+ }
2365
+ for (const [file, digest] of expected) {
2366
+ if (!current.has(file)) {
2367
+ throw new Error(`behavior artifact disappeared after baseline: ${file}`);
2368
+ }
2369
+ if (digest === null && current.get(file) !== null) {
2370
+ throw new Error(`behavior artifact appeared after baseline: ${file}`);
2371
+ }
2372
+ }
2373
+ return true;
2374
+ }
2375
+
2376
+ /** Throw when a collected behavior artifact disappeared, appeared, or changed. */
2377
+ export function assertBehaviorArtifactsUnchanged(digests) {
2378
+ for (const [file, expected] of digests ?? new Map()) {
2379
+ if (expected === null) {
2380
+ if (fs.existsSync(file)) throw new Error(`behavior artifact appeared after validation: ${file}`);
2381
+ continue;
2382
+ }
2383
+ let actual;
2384
+ try {
2385
+ actual = sha256File(file);
2386
+ } catch {
2387
+ throw new Error(`behavior artifact disappeared after validation: ${file}`);
2388
+ }
2389
+ if (actual !== expected) throw new Error(`behavior artifact changed after validation: ${file}`);
2390
+ }
2391
+ }
2392
+
2393
+ function parseCliArgs(argv) {
2394
+ const outDir = argv[0];
2395
+ const command = argv[1];
2396
+ const groupId = argv[2];
2397
+ let attempt = null;
2398
+ for (let index = 3; index < argv.length; index += 1) {
2399
+ if (argv[index] === "--attempt") {
2400
+ attempt = Number(argv[index + 1]);
2401
+ index += 1;
2402
+ }
2403
+ }
2404
+ if (!nonEmpty(outDir) || !["pre", "post", "digest"].includes(command) || !nonEmpty(groupId)) {
2405
+ throw new Error("usage: behavior-audit.mjs <out> pre|post|digest <group> --attempt <n>");
2406
+ }
2407
+ if (!Number.isInteger(attempt) || attempt < (command === "digest" ? 0 : 1)) {
2408
+ throw new Error(`behavior-audit.mjs: --attempt must be ${command === "digest" ? "a non-negative" : "a positive"} integer`);
2409
+ }
2410
+ return { outDir, groupId, attempt, command };
2411
+ }
2412
+
2413
+ async function main() {
2414
+ const { outDir, groupId, attempt, command } = parseCliArgs(process.argv.slice(2));
2415
+ if (command === "digest") {
2416
+ const plan = readJson(path.join(outDir, "plan.json"));
2417
+ const group = asArray(plan.groups).find(candidate => candidate?.group_id === groupId) ?? null;
2418
+ if (group === null) throw new Error(`group ${groupId} is not present in plan.json`);
2419
+ const drafts = readGroupDrafts(outDir, group, attempt);
2420
+ const canonical = [...drafts.values()].sort((a, b) => a.spec_id.localeCompare(b.spec_id));
2421
+ process.stdout.write(`${stableDigest(canonical)}\n`);
2422
+ return;
2423
+ }
2424
+ const result = command === "post"
2425
+ ? runPostAudit({ outDir, groupId, attempt })
2426
+ : runPreAudit({ outDir, groupId, attempt });
2427
+ process.stdout.write(`${command}-audit ${result.status} (attempt ${attempt})\n`);
2428
+ process.exitCode = result.status === "failed" ? 1 : 0;
2429
+ }
2430
+
2431
+ if (isMainModule(import.meta.url)) {
2432
+ main().catch(error => {
2433
+ console.error(error);
2434
+ process.exit(2);
2435
+ });
2436
+ }