@buaa_smat/hometrans 26.0.5 → 26.0.6

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 (472) hide show
  1. package/README.md +249 -279
  2. package/agents/code-reviewer.md +1 -1
  3. package/dist/cli/editors.json +20 -0
  4. package/dist/platform/registry.js +1 -0
  5. package/dist/platform/validate.js +2 -1
  6. package/i18n/agents/code-reviewer.md +1 -1
  7. package/i18n/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  8. package/i18n/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  9. package/i18n/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  10. package/i18n/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  11. package/i18n/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  12. package/i18n/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  13. package/i18n/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
  14. package/i18n/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  15. package/i18n/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  16. package/i18n/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  17. package/i18n/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  18. package/i18n/skills/a2h-app-migrate/SKILL.md +32 -15
  19. package/i18n/skills/a2h-app-migrate/references/stage-map.md +4 -2
  20. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +148 -89
  21. package/i18n/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
  22. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
  23. package/i18n/skills/a2h-app-migrate/test/test_build_fixer_contract.mjs +1 -1
  24. package/i18n/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
  25. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
  26. package/i18n/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
  27. package/i18n/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
  28. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +9 -3
  29. package/i18n/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
  30. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
  31. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
  32. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
  33. package/i18n/skills/a2h-batch-ui-align/SKILL.md +14 -12
  34. package/i18n/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
  35. package/i18n/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
  36. package/i18n/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
  37. package/i18n/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
  38. package/i18n/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
  39. package/i18n/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
  40. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
  41. package/i18n/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
  42. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
  43. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
  44. package/i18n/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
  45. package/i18n/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
  46. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
  47. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
  48. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
  49. package/i18n/skills/a2h-batch-ui-align/references/state-mgmt/_paradigm-selection.md +1 -1
  50. package/i18n/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
  51. package/i18n/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
  52. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
  53. package/i18n/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
  54. package/i18n/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
  55. package/i18n/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
  56. package/i18n/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
  57. package/i18n/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
  58. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
  59. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
  60. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
  61. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
  62. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
  63. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
  64. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
  65. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
  66. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
  67. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
  68. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
  69. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
  70. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
  71. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
  72. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
  73. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
  74. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
  75. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
  76. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
  77. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
  78. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
  79. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
  80. package/i18n/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
  81. package/i18n/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
  82. package/i18n/skills/a2h-module-semantic-docs/SKILL.md +3 -2
  83. package/i18n/skills/a2h-page-specgen/SKILL.md +36 -5
  84. package/i18n/skills/a2h-page-specgen/references/behavior-ledger.md +89 -21
  85. package/i18n/skills/a2h-page-specgen/references/gates.md +33 -7
  86. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
  87. package/i18n/skills/a2h-page-specgen/references/spec-example.md +166 -32
  88. package/i18n/skills/a2h-page-specgen/references/spec-template.md +8 -5
  89. package/i18n/skills/a2h-page-specgen/scripts/behavior-audit.mjs +37 -1
  90. package/i18n/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
  91. package/i18n/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
  92. package/i18n/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +32 -0
  93. package/i18n/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
  94. package/i18n/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
  95. package/i18n/skills/a2h-page-specgen/scripts/gate.mjs +19 -10
  96. package/i18n/skills/a2h-page-specgen/scripts/lib/contracts.mjs +62 -3
  97. package/i18n/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
  98. package/i18n/skills/a2h-page-specgen/scripts/lib/hg.mjs +116 -6
  99. package/i18n/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
  100. package/i18n/skills/a2h-page-specgen/scripts/prepare.mjs +26 -14
  101. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +118 -25
  102. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +104 -19
  103. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +118 -25
  104. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +104 -19
  105. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +216 -216
  106. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
  107. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
  108. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +118 -25
  109. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +100 -15
  110. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +118 -25
  111. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +104 -19
  112. package/i18n/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +155 -3
  113. package/i18n/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
  114. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
  115. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
  116. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
  117. package/i18n/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
  118. package/i18n/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
  119. package/i18n/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +75 -3
  120. package/i18n/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
  121. package/i18n/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +124 -0
  122. package/i18n/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
  123. package/i18n/skills/a2h-page-specgen/scripts/test/gate.test.mjs +106 -1
  124. package/i18n/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
  125. package/i18n/skills/a2h-page-specgen/scripts/test/hg.test.mjs +12 -0
  126. package/i18n/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
  127. package/i18n/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +11 -3
  128. package/i18n/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
  129. package/i18n/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
  130. package/i18n/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
  131. package/i18n/skills/a2h-resource-convert/SKILL.md +1 -1
  132. package/i18n/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
  133. package/i18n/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
  134. package/i18n/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
  135. package/i18n/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
  136. package/i18n/skills/a2h-spec-design-pipeline/SKILL.md +15 -12
  137. package/i18n/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
  138. package/i18n/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
  139. package/i18n/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
  140. package/i18n/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
  141. package/i18n/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
  142. package/i18n/skills/a2h-spec-design-pipeline/references/scripts.md +5 -3
  143. package/i18n/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
  144. package/i18n/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
  145. package/i18n/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
  146. package/i18n/skills/a2h-spec-generate/references/input-formats.md +1 -1
  147. package/i18n/skills/a2h-utg-explorer/SKILL.md +11 -5
  148. package/i18n/skills/a2h-utg-explorer/references/architecture.md +37 -19
  149. package/i18n/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +48 -3
  150. package/i18n/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
  151. package/i18n/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
  152. package/i18n/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
  153. package/i18n/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
  154. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
  155. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +143 -14
  156. package/i18n/skills/a2h-utg-static/SKILL.md +3 -3
  157. package/i18n/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
  158. package/i18n/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
  159. package/i18n/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
  160. package/i18n/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
  161. package/package.json +2 -1
  162. package/platforms/atomcode/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  163. package/platforms/claude-code/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  164. package/platforms/codebuddy/agents/build-fixer.frontmatter.md +5 -0
  165. package/platforms/codebuddy/agents/code-reviewer.frontmatter.md +5 -0
  166. package/platforms/codebuddy/agents/model-render-worker.frontmatter.md +5 -0
  167. package/platforms/codebuddy/agents/model-worker.frontmatter.md +5 -0
  168. package/platforms/codebuddy/agents/specgen-worker.frontmatter.md +5 -0
  169. package/platforms/codebuddy/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  170. package/platforms/codex/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  171. package/platforms/cursor/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  172. package/platforms/deveco/agents/build-fixer.frontmatter.md +2 -0
  173. package/platforms/deveco/agents/code-reviewer.frontmatter.md +2 -0
  174. package/platforms/deveco/agents/model-render-worker.frontmatter.md +2 -0
  175. package/platforms/deveco/agents/model-worker.frontmatter.md +2 -0
  176. package/platforms/deveco/agents/specgen-worker.frontmatter.md +2 -0
  177. package/platforms/deveco/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  178. package/platforms/opencode/agents/build-fixer.frontmatter.md +2 -0
  179. package/platforms/opencode/agents/code-reviewer.frontmatter.md +2 -0
  180. package/platforms/opencode/agents/model-render-worker.frontmatter.md +2 -0
  181. package/platforms/opencode/agents/model-worker.frontmatter.md +2 -0
  182. package/platforms/opencode/agents/specgen-worker.frontmatter.md +2 -0
  183. package/platforms/opencode/skills/a2h-app-migrate/SKILL.unique.md +10 -0
  184. package/platforms/qoder/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  185. package/platforms/qoder-cn/skills/a2h-app-migrate/SKILL.unique.md +8 -0
  186. package/platforms/trae/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  187. package/platforms/trae-cn/skills/a2h-app-migrate/SKILL.unique.md +3 -0
  188. package/skills/a2h-app-migrate/SKILL.md +31 -14
  189. package/skills/a2h-app-migrate/references/stage-map.md +4 -2
  190. package/skills/a2h-app-migrate/references/workflow.yaml +152 -89
  191. package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +1 -1
  192. package/skills/a2h-app-migrate/scripts/check_ui_batch_done.mjs +28 -11
  193. package/skills/a2h-app-migrate/scripts/dag_action_catalog.mjs +76 -0
  194. package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +60 -5
  195. package/skills/a2h-app-migrate/scripts/dag_runner.mjs +184 -4
  196. package/skills/a2h-app-migrate/scripts/env_preflight.mjs +1 -1
  197. package/skills/a2h-app-migrate/scripts/ledger.mjs +2 -2
  198. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -3
  199. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +51 -2
  200. package/skills/a2h-app-migrate/test/test_dag_blocked_guard.mjs +291 -0
  201. package/skills/a2h-app-migrate/test/test_dag_production.mjs +40 -0
  202. package/skills/a2h-app-migrate/test/test_dag_runner.mjs +4 -3
  203. package/skills/a2h-app-migrate/test/test_i18n_engine_mirror.mjs +1 -1
  204. package/skills/a2h-app-migrate/test/test_interaction.mjs +0 -2
  205. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
  206. package/skills/a2h-app-migrate/test/test_skill_doc.mjs +1 -1
  207. package/skills/a2h-app-migrate/test/test_spec_engine_contract.mjs +1 -1
  208. package/skills/a2h-app-migrate/test/test_specs_json_preflight.mjs +1 -1
  209. package/skills/a2h-app-migrate/test/test_ui_batch_done.mjs +36 -0
  210. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +19 -6
  211. package/skills/a2h-app-migrate/test/test_validate_workflow_bilingual.mjs +4 -2
  212. package/skills/a2h-arkts-logic-coder/SKILL.md +8 -7
  213. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +2 -2
  214. package/skills/a2h-arkts-logic-coder/references/code-generation.md +33 -12
  215. package/skills/a2h-batch-ui-align/SKILL.md +14 -12
  216. package/skills/a2h-batch-ui-align/references/cards/alignment.md +1 -0
  217. package/skills/a2h-batch-ui-align/references/cards/canvas.md +1 -0
  218. package/skills/a2h-batch-ui-align/references/cards/dynamics.md +32 -1
  219. package/skills/a2h-batch-ui-align/references/cards/geometry.md +3 -2
  220. package/skills/a2h-batch-ui-align/references/cards/interaction.md +4 -0
  221. package/skills/a2h-batch-ui-align/references/cards/resources.md +19 -1
  222. package/skills/a2h-batch-ui-align/references/cards/widgets.md +13 -1
  223. package/skills/a2h-batch-ui-align/references/cards/window.md +2 -2
  224. package/skills/a2h-batch-ui-align/references/checker-rules.md +205 -7
  225. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +10 -17
  226. package/skills/a2h-batch-ui-align/references/incremental-scope.md +3 -4
  227. package/skills/a2h-batch-ui-align/references/lottie-integration.md +47 -2
  228. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-atomic-component-mapping-reference.md +52 -328
  229. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-interaction-mapping-reference.md +1 -138
  230. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +2 -11
  231. package/skills/a2h-batch-ui-align/references/state-mgmt/_/350/214/203/345/274/217/351/200/211/346/213/251/350/257/264/346/230/216.md +1 -1
  232. package/skills/a2h-batch-ui-align/references/step3-capture.md +8 -23
  233. package/skills/a2h-batch-ui-align/references/step4-prepare.md +2 -1
  234. package/skills/a2h-batch-ui-align/references/step5-convert.md +17 -9
  235. package/skills/a2h-batch-ui-align/scripts/build_conversion_set.mjs +239 -16
  236. package/skills/a2h-batch-ui-align/scripts/group_commit.mjs +6 -1
  237. package/skills/a2h-batch-ui-align/scripts/group_pack.mjs +6 -0
  238. package/skills/a2h-batch-ui-align/scripts/group_pass.mjs +270 -0
  239. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +134 -16
  240. package/skills/a2h-batch-ui-align/scripts/group_watch.mjs +39 -8
  241. package/skills/a2h-batch-ui-align/scripts/icon_coverage.mjs +6 -3
  242. package/skills/a2h-batch-ui-align/scripts/measure_pack.ts +170 -10
  243. package/skills/a2h-batch-ui-align/scripts/module_placement.mjs +189 -0
  244. package/skills/a2h-batch-ui-align/scripts/overlay_effects.mjs +205 -0
  245. package/skills/a2h-batch-ui-align/scripts/phase5_check.mjs +42 -1
  246. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +20 -1
  247. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +28 -0
  248. package/skills/a2h-batch-ui-align/scripts/static_check/rules/attr_chain.ts +81 -0
  249. package/skills/a2h-batch-ui-align/scripts/static_check/rules/click_handler.ts +140 -0
  250. package/skills/a2h-batch-ui-align/scripts/static_check/rules/collapsing_toolbar.ts +124 -0
  251. package/skills/a2h-batch-ui-align/scripts/static_check/rules/compose_semantics.ts +287 -0
  252. package/skills/a2h-batch-ui-align/scripts/static_check/rules/flowitem_width.ts +78 -0
  253. package/skills/a2h-batch-ui-align/scripts/static_check/rules/hit_test.ts +194 -8
  254. package/skills/a2h-batch-ui-align/scripts/static_check/rules/inset_stacked.ts +138 -0
  255. package/skills/a2h-batch-ui-align/scripts/static_check/rules/int_division.ts +181 -0
  256. package/skills/a2h-batch-ui-align/scripts/static_check/rules/layout_placement.ts +62 -2
  257. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_path.ts +77 -0
  258. package/skills/a2h-batch-ui-align/scripts/static_check/rules/lottie_ready.ts +109 -0
  259. package/skills/a2h-batch-ui-align/scripts/static_check/rules/media_tint.ts +88 -18
  260. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_cycle.ts +140 -0
  261. package/skills/a2h-batch-ui-align/scripts/static_check/rules/relative_container_height.ts +2 -2
  262. package/skills/a2h-batch-ui-align/scripts/static_check/rules/see_through_overlay.ts +149 -0
  263. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_builder.ts +139 -0
  264. package/skills/a2h-batch-ui-align/scripts/static_check/rules/sheet_show_close.ts +53 -0
  265. package/skills/a2h-batch-ui-align/scripts/static_check/rules/space_between_optional.ts +115 -0
  266. package/skills/a2h-batch-ui-align/scripts/static_check/rules/theme_color.ts +7 -1
  267. package/skills/a2h-batch-ui-align/scripts/static_check/rules/width_fill.ts +160 -0
  268. package/skills/a2h-batch-ui-align/scripts/static_check/scan_file.ts +28 -0
  269. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_chrome_defaults.test.mjs +328 -0
  270. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_click_handler.test.mjs +127 -0
  271. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_compose_semantics.test.mjs +150 -0
  272. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_hit_test.test.mjs +117 -0
  273. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_inset_stacked.test.mjs +155 -0
  274. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_layout_placement.test.mjs +60 -0
  275. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_rule_smoke.test.mjs +413 -0
  276. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_runtime_api.test.mjs +159 -0
  277. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_sheet_builder.test.mjs +192 -0
  278. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_theme.test.mjs +4 -2
  279. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set.test.mjs +38 -0
  280. package/skills/a2h-batch-ui-align/scripts/tests/build_conversion_set_compose.test.mjs +106 -0
  281. package/skills/a2h-batch-ui-align/scripts/tests/group_commit.test.mjs +15 -0
  282. package/skills/a2h-batch-ui-align/scripts/tests/group_pass.test.mjs +150 -0
  283. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +125 -0
  284. package/skills/a2h-batch-ui-align/scripts/tests/group_watch.test.mjs +56 -0
  285. package/skills/a2h-batch-ui-align/scripts/tests/measure_pack_icon_leaf.test.mjs +143 -0
  286. package/skills/a2h-batch-ui-align/scripts/tests/module_placement.test.mjs +248 -0
  287. package/skills/a2h-batch-ui-align/scripts/tests/overlay_effects.test.mjs +214 -0
  288. package/skills/a2h-fix-build-errors/references/known-patterns.md +5 -5
  289. package/skills/a2h-module-semantic-docs/SKILL.md +3 -2
  290. package/skills/a2h-module-semantic-docs/scripts/commit_module_state.mjs +10 -0
  291. package/skills/a2h-module-semantic-docs/scripts/design_baseline.mjs +158 -0
  292. package/skills/a2h-module-semantic-docs/test/test_design_baseline.mjs +128 -0
  293. package/skills/a2h-page-specgen/SKILL.md +36 -5
  294. package/skills/a2h-page-specgen/references/behavior-ledger.md +88 -21
  295. package/skills/a2h-page-specgen/references/evidence.md +2 -1
  296. package/skills/a2h-page-specgen/references/execution-model.md +13 -5
  297. package/skills/a2h-page-specgen/references/gates.md +33 -7
  298. package/skills/a2h-page-specgen/references/scenario-authoring.md +67 -13
  299. package/skills/a2h-page-specgen/references/spec-example.md +166 -32
  300. package/skills/a2h-page-specgen/references/spec-template.md +8 -5
  301. package/skills/a2h-page-specgen/scripts/behavior-audit.mjs +40 -2
  302. package/skills/a2h-page-specgen/scripts/behavior-discovery.mjs +241 -22
  303. package/skills/a2h-page-specgen/scripts/behavior-model.mjs +29 -2
  304. package/skills/a2h-page-specgen/scripts/behavior-reconcile.mjs +35 -2
  305. package/skills/a2h-page-specgen/scripts/contract-calls.mjs +715 -0
  306. package/skills/a2h-page-specgen/scripts/finalize.mjs +55 -2
  307. package/skills/a2h-page-specgen/scripts/footprint.mjs +129 -2
  308. package/skills/a2h-page-specgen/scripts/gate.mjs +20 -11
  309. package/skills/a2h-page-specgen/scripts/lib/contracts.mjs +56 -3
  310. package/skills/a2h-page-specgen/scripts/lib/graph-evidence.mjs +27 -0
  311. package/skills/a2h-page-specgen/scripts/lib/hg.mjs +114 -5
  312. package/skills/a2h-page-specgen/scripts/lib/ledger.mjs +20 -3
  313. package/skills/a2h-page-specgen/scripts/operation-evidence.mjs +270 -29
  314. package/skills/a2h-page-specgen/scripts/prepare.mjs +25 -14
  315. package/skills/a2h-page-specgen/scripts/report.mjs +26 -5
  316. package/skills/a2h-page-specgen/scripts/submission.mjs +69 -2
  317. package/skills/a2h-page-specgen/scripts/submit.mjs +105 -4
  318. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.prompt.md +110 -18
  319. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/PlainDisplayPage.worker.md +97 -12
  320. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.prompt.md +110 -18
  321. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/SilentFailurePage.worker.md +97 -12
  322. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.discovery.json +224 -224
  323. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.json +1 -1
  324. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.post-review.json +2 -2
  325. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.prompt.md +110 -18
  326. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/UniAppSourcePage.worker.md +97 -12
  327. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.prompt.md +110 -18
  328. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/ValidatedSearchPage.worker.md +97 -12
  329. package/skills/a2h-page-specgen/scripts/test/acceptance/authoring/run.mjs +153 -3
  330. package/skills/a2h-page-specgen/scripts/test/android-operation-evidence.test.mjs +529 -1
  331. package/skills/a2h-page-specgen/scripts/test/behavior-audit-pre.test.mjs +27 -0
  332. package/skills/a2h-page-specgen/scripts/test/behavior-discovery.test.mjs +158 -0
  333. package/skills/a2h-page-specgen/scripts/test/behavior-fixtures.mjs +11 -13
  334. package/skills/a2h-page-specgen/scripts/test/behavior-reconcile.test.mjs +97 -0
  335. package/skills/a2h-page-specgen/scripts/test/contract-calls.test.mjs +737 -0
  336. package/skills/a2h-page-specgen/scripts/test/contracts.test.mjs +82 -3
  337. package/skills/a2h-page-specgen/scripts/test/finalize.test.mjs +24 -0
  338. package/skills/a2h-page-specgen/scripts/test/fixtures/hg.mkdb.mjs +11 -0
  339. package/skills/a2h-page-specgen/scripts/test/footprint-resolve.test.mjs +6 -2
  340. package/skills/a2h-page-specgen/scripts/test/gate.test.mjs +94 -1
  341. package/skills/a2h-page-specgen/scripts/test/graph-evidence.test.mjs +32 -0
  342. package/skills/a2h-page-specgen/scripts/test/hg.test.mjs +14 -0
  343. package/skills/a2h-page-specgen/scripts/test/ledger.test.mjs +49 -1
  344. package/skills/a2h-page-specgen/scripts/test/operation-reviews.test.mjs +6 -1
  345. package/skills/a2h-page-specgen/scripts/test/prompt-tpl.test.mjs +12 -4
  346. package/skills/a2h-page-specgen/scripts/test/protocol-docs.test.mjs +1 -1
  347. package/skills/a2h-page-specgen/scripts/test/recovery-e2e.test.mjs +1 -0
  348. package/skills/a2h-page-specgen/scripts/test/report.test.mjs +80 -1
  349. package/skills/a2h-page-specgen/scripts/test/submit.test.mjs +159 -27
  350. package/skills/a2h-page-specgen/scripts/test/waker-process.test.mjs +23 -0
  351. package/skills/a2h-page-specgen/scripts/waker.mjs +8 -1
  352. package/skills/a2h-resource-convert/SKILL.md +1 -1
  353. package/skills/a2h-resource-convert/data/framework-strings/NOTICE +10 -0
  354. package/skills/a2h-resource-convert/data/framework-strings/manifest.json +90 -0
  355. package/skills/a2h-resource-convert/data/framework-strings/strings.json +382 -0
  356. package/skills/a2h-resource-convert/references/conversion-rules.md +7 -1
  357. package/skills/a2h-resource-convert/references/lottie-conversion-rules.md +2 -2
  358. package/skills/a2h-resource-convert/references/step5-reference-resolution.md +16 -0
  359. package/skills/a2h-resource-convert/scripts/a2h_resource_convert.ts +124 -8
  360. package/skills/a2h-resource-convert/scripts/sync-framework-strings.mjs +147 -0
  361. package/skills/a2h-resource-convert/scripts/tests/framework_strings.test.mjs +131 -0
  362. package/skills/a2h-spec-design-pipeline/SKILL.md +14 -11
  363. package/skills/a2h-spec-design-pipeline/references/coding-loop.md +38 -10
  364. package/skills/a2h-spec-design-pipeline/references/execution-model.md +3 -0
  365. package/skills/a2h-spec-design-pipeline/references/final-report-template.md +6 -3
  366. package/skills/a2h-spec-design-pipeline/references/initialization.md +2 -2
  367. package/skills/a2h-spec-design-pipeline/references/post-loop.md +2 -2
  368. package/skills/a2h-spec-design-pipeline/references/reply-recovery.md +172 -0
  369. package/skills/a2h-spec-design-pipeline/references/review-loop.md +2 -2
  370. package/skills/a2h-spec-design-pipeline/references/scripts.md +4 -3
  371. package/skills/a2h-spec-design-pipeline/references/shared-layer.md +24 -19
  372. package/skills/a2h-spec-design-pipeline/references/state-and-resume.md +7 -1
  373. package/skills/a2h-spec-design-pipeline/references/static-defect-gate.md +12 -5
  374. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleMeta.json +5 -0
  375. package/skills/a2h-spec-design-pipeline/rules/migration-rules/config/ruleSet.json +4 -0
  376. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/README.md +27 -3
  377. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-param-contract.json +46 -1
  378. package/skills/a2h-spec-design-pipeline/rules/migration-rules/data/api-permission-map.json +2511 -295
  379. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-cn.md +27 -72
  380. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/api-permission-declared-en.md +39 -83
  381. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-cn.md +132 -101
  382. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/arkui-runtime-pitfall-en.md +158 -115
  383. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-cn.md +60 -93
  384. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/platform-api-contract-en.md +73 -100
  385. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-cn.md +52 -0
  386. package/skills/a2h-spec-design-pipeline/rules/migration-rules/document/checker/hometrans/route-page-side-effect-import-en.md +59 -0
  387. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ApiPermissionDeclaredCheck.js +57 -8
  388. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/ArkUIRuntimePitfallCheck.js +475 -18
  389. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/PlatformApiContractCheck.js +472 -4
  390. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/RoutePageSideEffectImportCheck.js +570 -0
  391. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/arkui/RouteParamCarrierSubCheck.js +1053 -0
  392. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/checker/sql/SqlIdentifierAnalysis.js +427 -0
  393. package/skills/a2h-spec-design-pipeline/rules/migration-rules/lib/index.js +7 -1
  394. package/skills/a2h-spec-design-pipeline/rules/migration-rules/package.json +1 -1
  395. package/skills/a2h-spec-design-pipeline/scripts/plan_groups.ts +1 -1
  396. package/skills/a2h-spec-design-pipeline/scripts/settle.ts +785 -0
  397. package/skills/a2h-spec-design-pipeline/scripts/test_api_permission_declared.ts +286 -0
  398. package/skills/a2h-spec-design-pipeline/scripts/test_arkui_runtime_pitfall.ts +166 -2
  399. package/skills/a2h-spec-design-pipeline/scripts/test_docs_refresh_contract.ts +40 -0
  400. package/skills/a2h-spec-design-pipeline/scripts/test_plan_groups.ts +2 -0
  401. package/skills/a2h-spec-design-pipeline/scripts/test_platform_api_contract.ts +350 -7
  402. package/skills/a2h-spec-design-pipeline/scripts/test_route_page_side_effect_import.ts +185 -0
  403. package/skills/a2h-spec-design-pipeline/scripts/test_route_param_carrier.ts +341 -0
  404. package/skills/a2h-spec-design-pipeline/scripts/test_settle.ts +593 -0
  405. package/skills/a2h-spec-design-pipeline/scripts/test_shared_layer_docs.ts +92 -1
  406. package/skills/a2h-spec-design-pipeline/scripts/test_sql_identifier_analysis.ts +137 -0
  407. package/skills/a2h-spec-generate/references/input-formats.md +1 -1
  408. package/skills/a2h-utg-explorer/SKILL.md +11 -5
  409. package/skills/a2h-utg-explorer/references/architecture.md +37 -19
  410. package/skills/a2h-utg-explorer/scripts/audit.mjs +6 -2
  411. package/skills/a2h-utg-explorer/scripts/close_phases.mjs +8 -5
  412. package/skills/a2h-utg-explorer/scripts/compile_tasks.mjs +95 -19
  413. package/skills/a2h-utg-explorer/scripts/d_prereqs.mjs +192 -4
  414. package/skills/a2h-utg-explorer/scripts/final_utg.mjs +21 -0
  415. package/skills/a2h-utg-explorer/scripts/panel_routes.mjs +1 -1
  416. package/skills/a2h-utg-explorer/scripts/plan.mjs +16 -1
  417. package/skills/a2h-utg-explorer/scripts/predicates.mjs +270 -0
  418. package/skills/a2h-utg-explorer/scripts/promote_dynamic.mjs +2 -0
  419. package/skills/a2h-utg-explorer/scripts/recover.mjs +4 -3
  420. package/skills/a2h-utg-explorer/scripts/recover_d.mjs +67 -8
  421. package/skills/a2h-utg-explorer/scripts/rejudge.mjs +4 -3
  422. package/skills/a2h-utg-explorer/scripts/report.mjs +32 -2
  423. package/skills/a2h-utg-explorer/scripts/run_cycle.mjs +103 -36
  424. package/skills/a2h-utg-explorer/scripts/run_device.mjs +3 -8
  425. package/skills/a2h-utg-explorer/scripts/schedule_states.mjs +189 -0
  426. package/skills/a2h-utg-explorer/scripts/tests/calendar_round_fixes.test.mjs +9 -0
  427. package/skills/a2h-utg-explorer/scripts/tests/coverage_rules.test.mjs +11 -0
  428. package/skills/a2h-utg-explorer/scripts/tests/d_prereqs.test.mjs +31 -2
  429. package/skills/a2h-utg-explorer/scripts/tests/device_lock_retry.test.mjs +1 -1
  430. package/skills/a2h-utg-explorer/scripts/tests/diagnostics.test.mjs +32 -0
  431. package/skills/a2h-utg-explorer/scripts/tests/dialog_own_layout.test.mjs +40 -0
  432. package/skills/a2h-utg-explorer/scripts/tests/explorer_review_fixes.test.mjs +4 -1
  433. package/skills/a2h-utg-explorer/scripts/tests/hybrid_route.test.mjs +6 -28
  434. package/skills/a2h-utg-explorer/scripts/tests/in_route_surface.test.mjs +125 -0
  435. package/skills/a2h-utg-explorer/scripts/tests/list_probe_target_wait.test.mjs +86 -0
  436. package/skills/a2h-utg-explorer/scripts/tests/multi_host.test.mjs +167 -0
  437. package/skills/a2h-utg-explorer/scripts/tests/nested_list.test.mjs +58 -0
  438. package/skills/a2h-utg-explorer/scripts/tests/overlay_opener.test.mjs +100 -0
  439. package/skills/a2h-utg-explorer/scripts/tests/pipeline.test.mjs +8 -1
  440. package/skills/a2h-utg-explorer/scripts/tests/pr169_review_fixes.test.mjs +1 -0
  441. package/skills/a2h-utg-explorer/scripts/tests/pr191_review_fixes.test.mjs +2 -31
  442. package/skills/a2h-utg-explorer/scripts/tests/review_fixes.test.mjs +1 -1
  443. package/skills/a2h-utg-explorer/scripts/tests/run_cycle.test.mjs +56 -7
  444. package/skills/a2h-utg-explorer/scripts/tests/snapshot_integrity.test.mjs +117 -6
  445. package/skills/a2h-utg-explorer/scripts/tests/state_inventory.test.mjs +414 -0
  446. package/skills/a2h-utg-explorer/scripts/tests/tree_unreliable.test.mjs +197 -0
  447. package/skills/a2h-utg-explorer/scripts/utg_explorer/adapters.mjs +196 -30
  448. package/skills/a2h-utg-explorer/scripts/utg_explorer/hosts.mjs +146 -0
  449. package/skills/a2h-utg-explorer/scripts/utg_explorer/semantics.mjs +63 -2
  450. package/skills/a2h-utg-explorer/scripts/utg_explorer/states.mjs +286 -0
  451. package/skills/a2h-utg-explorer/scripts/utg_explorer/task_runner.mjs +197 -19
  452. package/skills/a2h-utg-static/SKILL.md +3 -3
  453. package/skills/a2h-utg-static/references/extractors.md +7 -0
  454. package/skills/a2h-utg-static/references/ui-elements-static-utg-schema.md +4 -3
  455. package/skills/a2h-utg-static/scripts/click_paths.mjs +1 -1
  456. package/skills/a2h-utg-static/scripts/compose_overlay.mjs +642 -22
  457. package/skills/a2h-utg-static/scripts/tests/test_compose_res_text.mjs +25 -0
  458. package/skills/a2h-utg-static/scripts/tests/test_in_route_surface.mjs +123 -0
  459. package/skills/a2h-utg-static/scripts/tests/test_overlay_host_effects.mjs +239 -0
  460. package/skills/a2h-utg-static/scripts/tests/test_shared_host_depths.mjs +48 -0
  461. package/skills/a2h-utg-static/scripts/utg_html.mjs +2 -0
  462. package/skills/a2h-utg-static/tools/convert_static_utg_to_ui_elements.ts +1 -0
  463. package/i18n/skills/a2h-app-migrate/references/specs.example.json +0 -19
  464. package/i18n/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
  465. package/i18n/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
  466. package/resource/convert_pipeline_process.svg +0 -114
  467. package/resource/project_architecture.svg +0 -120
  468. package/resource/set_environment.png +0 -0
  469. package/resource/set_multimodel.png +0 -0
  470. package/skills/a2h-app-migrate/references/specs.example.json +0 -19
  471. package/skills/a2h-batch-ui-align/scripts/databinding_analyzer_design.md +0 -79
  472. package/skills/a2h-utg-explorer/scripts/utg_explorer/state_phase.mjs +0 -47
@@ -0,0 +1,593 @@
1
+ // Tests for settle.ts — the host-independent reply-recovery evidence gate.
2
+ // Core contract: absence of change is NEVER completion; a fresh artifact
3
+ // (newer than dispatch_at, different from the baseline, owned by this
4
+ // campaign/commit) is the only positive verdict. A pre-dispatch file must
5
+ // not make the probe look "quiet"; a tracked modification must be seen even
6
+ // though `git status --porcelain` starts with a leading space.
7
+ import { spawnSync } from 'node:child_process';
8
+ import { mkdirSync, mkdtempSync, readFileSync, rmSync, utimesSync, writeFileSync } from 'node:fs';
9
+ import * as os from 'node:os';
10
+ import * as path from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { test, type TestContext } from 'node:test';
13
+ import assert from 'node:assert/strict';
14
+
15
+ const HERE = path.dirname(fileURLToPath(import.meta.url));
16
+ const SCRIPT = path.join(HERE, 'settle.ts');
17
+ const T0 = Date.now() - 600_000; // dispatch (10m ago)
18
+ const NOW = Date.now() + 600_000; // settle sample (10m after the baseline write)
19
+ const iso = (ms: number) => new Date(ms).toISOString();
20
+
21
+ interface Fx { tmp: string; hmos: string; ht: string; wave: string; }
22
+
23
+ function gitOut(fx: Fx, ...args: string[]): string {
24
+ const r = spawnSync('git', ['-C', fx.hmos, ...args], { encoding: 'utf8' });
25
+ assert.equal(r.status, 0, r.stderr);
26
+ return (r.stdout ?? '').trim();
27
+ }
28
+
29
+ function makeFx(t: TestContext): Fx {
30
+ const tmp = mkdtempSync(path.join(os.tmpdir(), 'settle-'));
31
+ t.after(() => rmSync(tmp, { recursive: true, force: true }));
32
+ const hmos = path.join(tmp, 'hmos');
33
+ const ht = path.join(hmos, '.hometrans');
34
+ const wave = path.join(ht, 'wave_1');
35
+ mkdirSync(wave, { recursive: true });
36
+ writeFileSync(path.join(hmos, '.gitignore'), '.hometrans/\n', 'utf8');
37
+ writeFileSync(path.join(hmos, 'src.txt'), 'base\n', 'utf8');
38
+ const g = (...args: string[]) => spawnSync('git', ['-C', hmos, ...args], { encoding: 'utf8' });
39
+ g('init', '-q');
40
+ g('config', 'user.name', 'test');
41
+ g('config', 'user.email', 'test@example.com');
42
+ g('add', '.gitignore', 'src.txt');
43
+ g('commit', '-q', '-m', 'init');
44
+ return { tmp, hmos, ht, wave };
45
+ }
46
+
47
+ function writeAt(file: string, ms: number, content = 'x'): void {
48
+ mkdirSync(path.dirname(file), { recursive: true });
49
+ writeFileSync(file, content, 'utf8');
50
+ utimesSync(file, new Date(ms), new Date(ms));
51
+ }
52
+
53
+ function run(fx: Fx, ...args: string[]) {
54
+ return spawnSync(process.execPath, [SCRIPT, fx.hmos, ...args],
55
+ { encoding: 'utf8', timeout: 120_000 });
56
+ }
57
+
58
+ function initF0(fx: Fx): string {
59
+ const pre = gitOut(fx, 'rev-parse', 'HEAD');
60
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--dispatch-at', iso(T0),
61
+ '--campaign-id', 'C', '--base', pre, '--init');
62
+ assert.equal(r.status, 0, r.stderr);
63
+ return pre;
64
+ }
65
+
66
+ function settleF0(fx: Fx, extra: string[] = []) {
67
+ return run(fx, '--stage', 'f0', '--wave', '1', '--once', '--now', iso(NOW), ...extra);
68
+ }
69
+
70
+ function initB3(fx: Fx, pre: string): string {
71
+ const outDir = path.join(fx.wave, 'build');
72
+ const r = run(fx, '--stage', 'b3', '--wave', '1', '--dispatch-at', iso(T0),
73
+ '--output', outDir, '--pre-head', pre, '--init');
74
+ assert.equal(r.status, 0, r.stderr);
75
+ return outDir;
76
+ }
77
+
78
+ function settleB3(fx: Fx, outDir: string) {
79
+ return run(fx, '--stage', 'b3', '--wave', '1', '--output', outDir,
80
+ '--once', '--now', iso(NOW));
81
+ }
82
+
83
+ test('init records dispatch_at, pre_head, campaign/base and the artifact baseline', (t) => {
84
+ const fx = makeFx(t);
85
+ const pre = initF0(fx);
86
+ const b = JSON.parse(readFileSync(path.join(fx.wave, 'reply_recovery_f0.json'), 'utf8'));
87
+ assert.equal(b.schema, 'spec_reply_recovery/v2');
88
+ assert.equal(b.dispatch_at, iso(T0));
89
+ assert.equal(b.pre_head, pre);
90
+ assert.equal(b.campaign_id, 'C');
91
+ assert.equal(b.base, pre);
92
+ assert.deepEqual(b.targets, [path.join(fx.wave, 'shared_manifest.json')]);
93
+ assert.equal(b.artifacts[0].state, 'absent');
94
+ });
95
+
96
+ test('a missing artifact is settled_empty, never artifact_fresh', (t) => {
97
+ const fx = makeFx(t);
98
+ initF0(fx);
99
+ const r = settleF0(fx);
100
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
101
+ const out = JSON.parse(r.stdout as string);
102
+ assert.equal(out.verdict, 'settled_empty');
103
+ assert.equal(out.quietMs, 660_000);
104
+ assert.equal(out.artifacts[0].state, 'absent');
105
+ });
106
+
107
+ test('a pre-dispatch file does not make the probe look quiet', (t) => {
108
+ const fx = makeFx(t);
109
+ writeAt(path.join(fx.wave, 'old.log'), T0 - 3_600_000);
110
+ initF0(fx);
111
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--now', iso(T0 + 10_000));
112
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
113
+ assert.equal(JSON.parse(r.stdout as string).verdict, 'pending');
114
+ });
115
+
116
+ test('a tracked modification is seen despite the leading status space', (t) => {
117
+ const fx = makeFx(t);
118
+ initF0(fx);
119
+ writeFileSync(path.join(fx.hmos, 'src.txt'), 'changed\n', 'utf8');
120
+ utimesSync(path.join(fx.hmos, 'src.txt'), new Date(NOW - 30_000), new Date(NOW - 30_000));
121
+ const r = settleF0(fx);
122
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
123
+ const out = JSON.parse(r.stdout as string);
124
+ assert.equal(out.verdict, 'pending');
125
+ assert.ok(out.dirty.includes('src.txt'), JSON.stringify(out.dirty));
126
+ });
127
+
128
+ test('an artifact older than dispatch_at is stale, not fresh', (t) => {
129
+ const fx = makeFx(t);
130
+ const manifest = path.join(fx.wave, 'shared_manifest.json');
131
+ writeAt(manifest, T0 - 60_000, JSON.stringify({ campaign_id: 'C', base: 'x' }));
132
+ initF0(fx);
133
+ const r = settleF0(fx);
134
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
135
+ const out = JSON.parse(r.stdout as string);
136
+ assert.notEqual(out.verdict, 'artifact_fresh');
137
+ assert.equal(out.artifacts[0].state, 'stale');
138
+ });
139
+
140
+ test('a fresh manifest ends the recovery using the baseline ownership fields', (t) => {
141
+ const fx = makeFx(t);
142
+ const pre = initF0(fx);
143
+ writeAt(path.join(fx.wave, 'shared_manifest.json'), T0 + 1_000,
144
+ JSON.stringify({ campaign_id: 'C', base: pre }));
145
+ const r = settleF0(fx);
146
+ assert.equal(r.status, 0, `${r.stderr}${r.stdout}`);
147
+ const out = JSON.parse(r.stdout as string);
148
+ assert.equal(out.verdict, 'artifact_fresh');
149
+ assert.equal(out.artifacts[0].state, 'fresh');
150
+ });
151
+
152
+ test('a manifest from another campaign is invalid, never fresh', (t) => {
153
+ const fx = makeFx(t);
154
+ initF0(fx);
155
+ writeAt(path.join(fx.wave, 'shared_manifest.json'), T0 + 1_000,
156
+ JSON.stringify({ campaign_id: 'OTHER', base: 'x' }));
157
+ const r = settleF0(fx);
158
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
159
+ const out = JSON.parse(r.stdout as string);
160
+ assert.equal(out.verdict, 'settled_empty');
161
+ assert.equal(out.artifacts[0].state, 'invalid');
162
+ });
163
+
164
+ test('activity under an ignored root keeps the verdict pending', (t) => {
165
+ const fx = makeFx(t);
166
+ initF0(fx);
167
+ writeAt(path.join(fx.wave, 'build_attempt_1.log'), NOW - 30_000);
168
+ const r = settleF0(fx);
169
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
170
+ assert.equal(JSON.parse(r.stdout as string).verdict, 'pending');
171
+ });
172
+
173
+ test('activity through the whole wait budget is settled_timeout', (t) => {
174
+ const fx = makeFx(t);
175
+ initF0(fx);
176
+ writeAt(path.join(fx.wave, 'build_attempt_1.log'), NOW - 30_000);
177
+ const r = settleF0(fx, ['--wait-ms', '300000']);
178
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
179
+ assert.equal(JSON.parse(r.stdout as string).verdict, 'settled_timeout');
180
+ });
181
+
182
+ test('b3: commit_id none is fresh only while HEAD is still pre_head', (t) => {
183
+ const fx = makeFx(t);
184
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
185
+ const outDir = initB3(fx, a);
186
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
187
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, 'commit_id: none\n');
188
+ const ok = settleB3(fx, outDir);
189
+ assert.equal(ok.status, 0, `${ok.stderr}${ok.stdout}`);
190
+ assert.equal(JSON.parse(ok.stdout as string).verdict, 'artifact_fresh');
191
+
192
+ gitOut(fx, 'commit', '--allow-empty', '-q', '-m', 'moved');
193
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 2_000, 'commit_id: none\n');
194
+ const bad = settleB3(fx, outDir);
195
+ assert.equal(bad.status, 3, `${bad.stderr}${bad.stdout}`);
196
+ assert.equal(JSON.parse(bad.stdout as string).artifacts[1]!.state, 'invalid');
197
+ });
198
+
199
+ test('b3: commit == pre_head is not a new fix commit', (t) => {
200
+ const fx = makeFx(t);
201
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
202
+ const outDir = initB3(fx, a);
203
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
204
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, `commit_id: ${a}\n`);
205
+ const r = settleB3(fx, outDir);
206
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
207
+ assert.equal(JSON.parse(r.stdout as string).artifacts[1]!.state, 'invalid');
208
+ });
209
+
210
+ test('b3: a real fix commit descended from pre_head ends the recovery', (t) => {
211
+ const fx = makeFx(t);
212
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
213
+ const outDir = initB3(fx, a);
214
+ writeFileSync(path.join(fx.hmos, 'src.txt'), 'fixed\n', 'utf8');
215
+ gitOut(fx, 'add', 'src.txt');
216
+ gitOut(fx, 'commit', '-q', '-m', 'fix(build): fix 1 compilation error');
217
+ const b = gitOut(fx, 'rev-parse', 'HEAD');
218
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
219
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, `commit_id: ${b}\n`);
220
+ const r = settleB3(fx, outDir);
221
+ assert.equal(r.status, 0, `${r.stderr}${r.stdout}`);
222
+ assert.equal(JSON.parse(r.stdout as string).verdict, 'artifact_fresh');
223
+ });
224
+
225
+ test('b3: an empty report is invalid even with a valid commit', (t) => {
226
+ const fx = makeFx(t);
227
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
228
+ const outDir = initB3(fx, a);
229
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'hello\n');
230
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, 'commit_id: none\n');
231
+ const r = settleB3(fx, outDir);
232
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
233
+ assert.equal(JSON.parse(r.stdout as string).artifacts[0]!.state, 'invalid');
234
+ });
235
+
236
+ test('a commit after dispatch counts once, then the probe can go quiet', (t) => {
237
+ const fx = makeFx(t);
238
+ initF0(fx);
239
+ gitOut(fx, 'commit', '--allow-empty', '-q', '-m', 'later');
240
+ const later = Date.now() + 1_800_000;
241
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--now', iso(later));
242
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
243
+ const out = JSON.parse(r.stdout as string);
244
+ assert.equal(out.verdict, 'settled_empty');
245
+ assert.equal(out.headChanged, true);
246
+ });
247
+
248
+ test('a relative baseline resolves under .hometrans and supplies dispatch_at', (t) => {
249
+ const fx = makeFx(t);
250
+ const pre = initF0(fx);
251
+ writeAt(path.join(fx.wave, 'shared_manifest.json'), T0 + 1_000,
252
+ JSON.stringify({ campaign_id: 'C', base: pre }));
253
+ const r = run(fx, '--baseline', 'wave_1/reply_recovery_f0.json',
254
+ '--once', '--now', iso(NOW));
255
+ assert.equal(r.status, 0, `${r.stderr}${r.stdout}`);
256
+ assert.equal(JSON.parse(r.stdout as string).verdict, 'artifact_fresh');
257
+ });
258
+
259
+ test('a missing baseline is a usage error', (t) => {
260
+ const fx = makeFx(t);
261
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once');
262
+ assert.equal(r.status, 2, `${r.stderr}${r.stdout}`);
263
+ });
264
+
265
+ test('loop mode returns pending at the slice boundary, not settled_empty', (t) => {
266
+ const fx = makeFx(t);
267
+ initF0(fx);
268
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--now', iso(T0 + 10_000),
269
+ '--slice-ms', '100', '--poll-ms', '50', '--wait-ms', '600000');
270
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
271
+ assert.equal(JSON.parse(r.stdout as string).verdict, 'pending');
272
+ });
273
+
274
+ test('b3: a short sha of pre_head is still not a new commit', (t) => {
275
+ const fx = makeFx(t);
276
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
277
+ const outDir = initB3(fx, a);
278
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
279
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, `commit_id: ${a.slice(0, 7)}\n`);
280
+ const r = settleB3(fx, outDir);
281
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
282
+ const out = JSON.parse(r.stdout as string);
283
+ assert.equal(out.artifacts[1]!.state, 'invalid');
284
+ assert.equal(out.artifacts[1]!.note, 'not-a-new-commit');
285
+ });
286
+
287
+ test('b3: markdown-bold Build Status is accepted', (t) => {
288
+ const fx = makeFx(t);
289
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
290
+ const outDir = initB3(fx, a);
291
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, '1. **Build Status**: SUCCESS\n');
292
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, 'commit_id: none\n');
293
+ const r = settleB3(fx, outDir);
294
+ assert.equal(r.status, 0, `${r.stderr}${r.stdout}`);
295
+ const out = JSON.parse(r.stdout as string);
296
+ assert.equal(out.verdict, 'artifact_fresh');
297
+ assert.equal(out.quietMs, 660_000);
298
+ });
299
+
300
+ test('b3: commit_id none with a dirty tree is invalid', (t) => {
301
+ const fx = makeFx(t);
302
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
303
+ const outDir = initB3(fx, a);
304
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
305
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, 'commit_id: none\n');
306
+ writeFileSync(path.join(fx.hmos, 'src.txt'), 'dirty\n', 'utf8');
307
+ const r = settleB3(fx, outDir);
308
+ const out = JSON.parse(r.stdout as string);
309
+ assert.equal(out.artifacts[1]!.state, 'invalid');
310
+ assert.equal(out.artifacts[1]!.note, 'none-but-dirty-tree');
311
+ });
312
+
313
+ test('b3: a commit outside HEAD is rejected', (t) => {
314
+ const fx = makeFx(t);
315
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
316
+ const outDir = initB3(fx, a);
317
+ const branch = gitOut(fx, 'rev-parse', '--abbrev-ref', 'HEAD');
318
+ gitOut(fx, 'checkout', '--orphan', 'other');
319
+ gitOut(fx, 'commit', '--allow-empty', '-q', '-m', 'other');
320
+ const b = gitOut(fx, 'rev-parse', 'HEAD');
321
+ gitOut(fx, 'checkout', '-q', branch);
322
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
323
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, `commit_id: ${b}\n`);
324
+ const r = settleB3(fx, outDir);
325
+ const out = JSON.parse(r.stdout as string);
326
+ assert.equal(out.artifacts[1]!.state, 'invalid');
327
+ });
328
+
329
+ test('a truncated scan is fail-closed, not settled_empty', (t) => {
330
+ const fx = makeFx(t);
331
+ initF0(fx);
332
+ writeAt(path.join(fx.wave, 'a.log'), T0);
333
+ writeAt(path.join(fx.wave, 'b.log'), T0);
334
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--now', iso(NOW),
335
+ '--scan-budget', '1');
336
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
337
+ const out = JSON.parse(r.stdout as string);
338
+ assert.equal(out.verdict, 'pending');
339
+ assert.equal(out.activityTruncated, true);
340
+ });
341
+
342
+ test('a scan budget exactly consumed by the entries is not truncated', (t) => {
343
+ const fx = makeFx(t);
344
+ initF0(fx);
345
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--now', iso(T0 + 10_000),
346
+ '--scan-budget', '1');
347
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
348
+ const out = JSON.parse(r.stdout as string);
349
+ assert.equal(out.activityTruncated, false);
350
+ assert.equal(out.verdict, 'pending');
351
+ });
352
+
353
+ test('a future file does not erase real recent activity', (t) => {
354
+ const fx = makeFx(t);
355
+ initF0(fx);
356
+ writeAt(path.join(fx.wave, 'real.log'), NOW - 30_000);
357
+ writeAt(path.join(fx.wave, 'future.log'), NOW + 3_600_000);
358
+ const r = settleF0(fx);
359
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
360
+ const out = JSON.parse(r.stdout as string);
361
+ assert.equal(out.verdict, 'pending');
362
+ assert.equal(out.clockSkew, true);
363
+ });
364
+
365
+ test('a dirty list above the scan budget is fail-closed', (t) => {
366
+ const fx = makeFx(t);
367
+ initF0(fx);
368
+ for (const name of ['a.txt', 'b.txt', 'c.txt']) {
369
+ writeAt(path.join(fx.hmos, name), T0 - 3_600_000, name);
370
+ }
371
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--now', iso(NOW),
372
+ '--scan-budget', '2');
373
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
374
+ const out = JSON.parse(r.stdout as string);
375
+ assert.equal(out.verdict, 'pending');
376
+ assert.equal(out.activityTruncated, true);
377
+ });
378
+
379
+ test('a lone future artifact stays quiet but is flagged', (t) => {
380
+ const fx = makeFx(t);
381
+ const pre = initF0(fx);
382
+ writeAt(path.join(fx.wave, 'shared_manifest.json'), NOW + 3_600_000,
383
+ JSON.stringify({ campaign_id: 'C', base: pre }));
384
+ const r = settleF0(fx);
385
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
386
+ const out = JSON.parse(r.stdout as string);
387
+ assert.equal(out.verdict, 'settled_empty');
388
+ assert.equal(out.artifacts[0]!.state, 'invalid');
389
+ assert.equal(out.artifacts[0]!.note, 'future-mtime');
390
+ assert.equal(out.clockSkew, true);
391
+ });
392
+
393
+ test('f0 init requires campaign/base; stage must match the baseline', (t) => {
394
+ const fx = makeFx(t);
395
+ const bad = run(fx, '--stage', 'f0', '--wave', '1', '--dispatch-at', iso(T0), '--init');
396
+ assert.equal(bad.status, 2, `${bad.stderr}${bad.stdout}`);
397
+ initF0(fx);
398
+ const mismatch = run(fx, '--stage', 'b3', '--wave', '1',
399
+ '--baseline', 'wave_1/reply_recovery_f0.json', '--once');
400
+ assert.equal(mismatch.status, 2, `${mismatch.stderr}${mismatch.stdout}`);
401
+ });
402
+
403
+ test('init refuses to overwrite a baseline without --force', (t) => {
404
+ const fx = makeFx(t);
405
+ initF0(fx);
406
+ const again = run(fx, '--stage', 'f0', '--wave', '1', '--dispatch-at', iso(T0),
407
+ '--campaign-id', 'C', '--base', gitOut(fx, 'rev-parse', 'HEAD'), '--init');
408
+ assert.equal(again.status, 2, `${again.stderr}${again.stdout}`);
409
+ const forced = run(fx, '--stage', 'f0', '--wave', '1', '--dispatch-at', iso(T0),
410
+ '--campaign-id', 'C', '--base', gitOut(fx, 'rev-parse', 'HEAD'), '--init', '--force');
411
+ assert.equal(forced.status, 0, `${forced.stderr}${forced.stdout}`);
412
+ });
413
+
414
+ test('--wait-ms and --max-ms are aliases and cannot be combined', (t) => {
415
+ const fx = makeFx(t);
416
+ initF0(fx);
417
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once',
418
+ '--wait-ms', '1000', '--max-ms', '2000');
419
+ assert.equal(r.status, 2, `${r.stderr}${r.stdout}`);
420
+ });
421
+
422
+ test('an untracked file rewritten inside a new directory counts as activity', (t) => {
423
+ const fx = makeFx(t);
424
+ initF0(fx);
425
+ const dir = path.join(fx.hmos, 'feature');
426
+ mkdirSync(dir, { recursive: true });
427
+ const file = path.join(dir, 'Index.ets');
428
+ writeFileSync(file, 'v1\n', 'utf8');
429
+ utimesSync(dir, new Date(T0 - 3_600_000), new Date(T0 - 3_600_000));
430
+ writeFileSync(file, 'v2\n', 'utf8');
431
+ utimesSync(file, new Date(NOW - 30_000), new Date(NOW - 30_000));
432
+ const r = settleF0(fx);
433
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
434
+ const out = JSON.parse(r.stdout as string);
435
+ assert.equal(out.verdict, 'pending');
436
+ assert.ok(out.dirty.includes('feature/Index.ets'), JSON.stringify(out.dirty));
437
+ });
438
+
439
+ test('deleting a tracked file counts as activity', (t) => {
440
+ const fx = makeFx(t);
441
+ initF0(fx);
442
+ rmSync(path.join(fx.hmos, 'src.txt'));
443
+ const r = settleF0(fx);
444
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
445
+ const out = JSON.parse(r.stdout as string);
446
+ assert.equal(out.verdict, 'pending');
447
+ assert.ok(out.dirty.includes('src.txt'), JSON.stringify(out.dirty));
448
+ });
449
+
450
+ test('probe --artifact must include every baseline target', (t) => {
451
+ const fx = makeFx(t);
452
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
453
+ const outDir = initB3(fx, a);
454
+ const report = path.join(outDir, 'build-fix-report.md');
455
+ writeAt(report, T0 + 1_000, 'Build Status: SUCCESS\n');
456
+ const r = run(fx, '--stage', 'b3', '--wave', '1', '--output', outDir,
457
+ '--artifact', report, '--once', '--now', iso(NOW));
458
+ assert.equal(r.status, 2, `${r.stderr}${r.stdout}`);
459
+ });
460
+
461
+ test('probe rejects ownership overrides that differ from the baseline', (t) => {
462
+ const fx = makeFx(t);
463
+ const pre = initF0(fx);
464
+ writeAt(path.join(fx.wave, 'shared_manifest.json'), T0 + 1_000,
465
+ JSON.stringify({ campaign_id: 'C', base: pre }));
466
+ const campaign = settleF0(fx, ['--campaign-id', 'OTHER']);
467
+ assert.equal(campaign.status, 2, `${campaign.stderr}${campaign.stdout}`);
468
+ const base = settleF0(fx, ['--base', 'deadbeef']);
469
+ assert.equal(base.status, 2, `${base.stderr}${base.stdout}`);
470
+ const dispatch = settleF0(fx, ['--dispatch-at', iso(T0 + 1_000)]);
471
+ assert.equal(dispatch.status, 2, `${dispatch.stderr}${dispatch.stdout}`);
472
+ const preHead = settleF0(fx, ['--pre-head', 'deadbeef']);
473
+ assert.equal(preHead.status, 2, `${preHead.stderr}${preHead.stdout}`);
474
+ });
475
+
476
+ test('report prose does not satisfy the Build Status contract', (t) => {
477
+ const fx = makeFx(t);
478
+ const a = gitOut(fx, 'rev-parse', 'HEAD');
479
+ const outDir = initB3(fx, a);
480
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000,
481
+ 'Earlier attempt: Build Status: FAILED, then fixed\n');
482
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, 'commit_id: none\n');
483
+ const r = settleB3(fx, outDir);
484
+ const out = JSON.parse(r.stdout as string);
485
+ assert.equal(out.artifacts[0]!.state, 'invalid');
486
+ assert.equal(out.artifacts[0]!.note, 'report-status-missing');
487
+ });
488
+
489
+ test('round-specific baselines allow a second review round', (t) => {
490
+ const fx = makeFx(t);
491
+ const pre = gitOut(fx, 'rev-parse', 'HEAD');
492
+ for (const name of ['r1.json', 'r2.json']) {
493
+ const r = run(fx, '--init', '--stage', 'f0', '--wave', '1',
494
+ '--dispatch-at', iso(T0), '--campaign-id', 'C', '--base', pre,
495
+ '--baseline', `wave_1/${name}`);
496
+ assert.equal(r.status, 0, `${r.stderr}${r.stdout}`);
497
+ }
498
+ });
499
+
500
+ test('init stores resolved OIDs even when given the literal HEAD', (t) => {
501
+ const fx = makeFx(t);
502
+ const pre = gitOut(fx, 'rev-parse', 'HEAD');
503
+ const outDir = path.join(fx.wave, 'build');
504
+ const init = run(fx, '--init', '--stage', 'b3', '--wave', '1', '--dispatch-at', iso(T0),
505
+ '--output', outDir, '--pre-head', 'HEAD');
506
+ assert.equal(init.status, 0, `${init.stderr}${init.stdout}`);
507
+ const b = JSON.parse(readFileSync(path.join(fx.wave, 'reply_recovery_b3.json'), 'utf8'));
508
+ assert.equal(b.pre_head, pre);
509
+ gitOut(fx, 'commit', '--allow-empty', '-q', '-m', 'moved');
510
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
511
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, 'commit_id: none\n');
512
+ const r = run(fx, '--stage', 'b3', '--wave', '1', '--output', outDir, '--once', '--now', iso(NOW));
513
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
514
+ assert.equal(JSON.parse(r.stdout as string).artifacts[1]!.note, 'none-but-head-moved');
515
+ });
516
+
517
+ test('f0 accepts a short --base when the manifest has the full sha', (t) => {
518
+ const fx = makeFx(t);
519
+ const pre = gitOut(fx, 'rev-parse', 'HEAD');
520
+ const init = run(fx, '--init', '--stage', 'f0', '--wave', '1',
521
+ '--dispatch-at', iso(T0), '--campaign-id', 'C', '--base', pre.slice(0, 8));
522
+ assert.equal(init.status, 0, `${init.stderr}${init.stdout}`);
523
+ writeAt(path.join(fx.wave, 'shared_manifest.json'), T0 + 1_000,
524
+ JSON.stringify({ campaign_id: 'C', base: pre }));
525
+ const r = settleF0(fx);
526
+ assert.equal(r.status, 0, `${r.stderr}${r.stdout}`);
527
+ assert.equal(JSON.parse(r.stdout as string).verdict, 'artifact_fresh');
528
+ });
529
+
530
+ test('a dirty path with a future mtime is skew, not endless activity', (t) => {
531
+ const fx = makeFx(t);
532
+ initF0(fx);
533
+ writeFileSync(path.join(fx.hmos, 'src.txt'), 'future\n', 'utf8');
534
+ utimesSync(path.join(fx.hmos, 'src.txt'), new Date(NOW + 3_600_000), new Date(NOW + 3_600_000));
535
+ const later = NOW + 2_400_000;
536
+ const r = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--now', iso(later));
537
+ assert.equal(r.status, 3, `${r.stderr}${r.stdout}`);
538
+ const out = JSON.parse(r.stdout as string);
539
+ assert.equal(out.verdict, 'settled_empty');
540
+ assert.equal(out.clockSkew, true);
541
+ });
542
+
543
+ test('b4-rebuild requires a round-specific baseline at init and probe', (t) => {
544
+ const fx = makeFx(t);
545
+ const pre = gitOut(fx, 'rev-parse', 'HEAD');
546
+ const outDir = path.join(fx.wave, 'review_round_1', 'build');
547
+ const init = run(fx, '--init', '--stage', 'b4-rebuild', '--wave', '1',
548
+ '--dispatch-at', iso(T0), '--output', outDir, '--pre-head', pre);
549
+ assert.equal(init.status, 2, `${init.stderr}${init.stdout}`);
550
+ const probe = run(fx, '--stage', 'b4-rebuild', '--wave', '1',
551
+ '--output', outDir, '--once');
552
+ assert.equal(probe.status, 2, `${probe.stderr}${probe.stdout}`);
553
+ });
554
+
555
+ test('init rejects an unresolvable pre-head/base', (t) => {
556
+ const fx = makeFx(t);
557
+ const outDir = path.join(fx.wave, 'build');
558
+ const badPre = run(fx, '--init', '--stage', 'b3', '--wave', '1', '--dispatch-at', iso(T0),
559
+ '--output', outDir, '--pre-head', 'deadbeef');
560
+ assert.equal(badPre.status, 2, `${badPre.stderr}${badPre.stdout}`);
561
+ const badBase = run(fx, '--init', '--stage', 'f0', '--wave', '1', '--dispatch-at', iso(T0),
562
+ '--campaign-id', 'C', '--base', 'deadbeef');
563
+ assert.equal(badBase.status, 2, `${badBase.stderr}${badBase.stdout}`);
564
+ });
565
+
566
+ test('numeric knobs reject zero/explicit invalid values', (t) => {
567
+ const fx = makeFx(t);
568
+ initF0(fx);
569
+ const wait = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--wait-ms', '0');
570
+ assert.equal(wait.status, 2, `${wait.stderr}${wait.stdout}`);
571
+ const scan = run(fx, '--stage', 'f0', '--wave', '1', '--once', '--scan-budget', '0');
572
+ assert.equal(scan.status, 2, `${scan.stderr}${scan.stdout}`);
573
+ });
574
+
575
+ test('b4-rebuild round baselines keep round 1 and round 2 independent', (t) => {
576
+ const fx = makeFx(t);
577
+ const pre = gitOut(fx, 'rev-parse', 'HEAD');
578
+ const round = (r: number) => {
579
+ const outDir = path.join(fx.wave, `review_round_${r}`, 'build');
580
+ const baseline = path.join(fx.wave, `review_round_${r}`, 'reply_recovery_b4-rebuild.json');
581
+ const init = run(fx, '--init', '--stage', 'b4-rebuild', '--wave', '1',
582
+ '--dispatch-at', iso(T0), '--output', outDir, '--pre-head', pre, '--baseline', baseline);
583
+ assert.equal(init.status, 0, `${init.stderr}${init.stdout}`);
584
+ writeAt(path.join(outDir, 'build-fix-report.md'), T0 + 1_000, 'Build Status: SUCCESS\n');
585
+ writeAt(path.join(outDir, 'build-fix-commit-info.md'), T0 + 1_000, 'commit_id: none\n');
586
+ const probe = run(fx, '--stage', 'b4-rebuild', '--wave', '1', '--output', outDir,
587
+ '--baseline', baseline, '--once', '--now', iso(NOW));
588
+ assert.equal(probe.status, 0, `${probe.stderr}${probe.stdout}`);
589
+ assert.equal(JSON.parse(probe.stdout as string).verdict, 'artifact_fresh');
590
+ };
591
+ round(1);
592
+ round(2);
593
+ });