@buaa_smat/hometrans 26.0.4 → 26.0.5

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 (102) hide show
  1. package/agents/code-reviewer.md +2 -0
  2. package/agents/model-render-worker.md +1 -1
  3. package/i18n/agents/code-reviewer.md +2 -0
  4. package/i18n/agents/model-render-worker.md +1 -1
  5. package/i18n/skills/a2h-app-migrate/SKILL.md +51 -3
  6. package/i18n/skills/a2h-app-migrate/references/workflow.yaml +140 -32
  7. package/i18n/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
  8. package/i18n/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
  9. package/i18n/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
  10. package/i18n/skills/a2h-app-migrate/test/test_image_probe.mjs +3 -3
  11. package/i18n/skills/a2h-app-migrate/test/test_resume_plan.mjs +1 -1
  12. package/i18n/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
  13. package/i18n/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
  14. package/i18n/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
  15. package/i18n/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
  16. package/i18n/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
  17. package/i18n/skills/a2h-batch-ui-align/SKILL.md +1 -1
  18. package/i18n/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
  19. package/i18n/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
  20. package/i18n/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
  21. package/i18n/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
  22. package/i18n/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
  23. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
  24. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
  25. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
  26. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
  27. package/i18n/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
  28. package/i18n/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
  29. package/i18n/skills/a2h-page-specgen/references/spec-example.md +35 -5
  30. package/i18n/skills/a2h-page-specgen/references/spec-template.md +4 -4
  31. package/i18n/skills/a2h-spec-generate/SKILL.md +3 -1
  32. package/i18n/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
  33. package/i18n/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  34. package/i18n/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
  35. package/i18n/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
  36. package/i18n/skills/a2h-spec-generate/references/spec-samples.md +5 -1
  37. package/i18n/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
  38. package/i18n/skills/a2h-spec-generate/references/worker-rules.md +25 -2
  39. package/i18n/skills/a2h-spec-generate/scripts/check_spec.ts +121 -6
  40. package/i18n/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +2 -1
  41. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
  42. package/i18n/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
  43. package/i18n/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +11 -2
  44. package/i18n/skills/a2h-spec-generate/test/check-spec.test.ts +35 -0
  45. package/package.json +1 -1
  46. package/skills/a2h-app-migrate/SKILL.md +53 -5
  47. package/skills/a2h-app-migrate/references/workflow.yaml +140 -32
  48. package/skills/a2h-app-migrate/scripts/assert_dag_complete.mjs +226 -0
  49. package/skills/a2h-app-migrate/scripts/dag_graph.mjs +297 -0
  50. package/skills/a2h-app-migrate/scripts/dag_process_executor.mjs +199 -0
  51. package/skills/a2h-app-migrate/scripts/dag_production_executor.mjs +897 -0
  52. package/skills/a2h-app-migrate/scripts/dag_runner.mjs +1767 -0
  53. package/skills/a2h-app-migrate/scripts/ledger.mjs +15 -2
  54. package/skills/a2h-app-migrate/scripts/lib-yaml-lite.mjs +8 -2
  55. package/skills/a2h-app-migrate/scripts/resume_plan.mjs +3 -8
  56. package/skills/a2h-app-migrate/scripts/validate_workflow.mjs +134 -21
  57. package/skills/a2h-app-migrate/test/test_dag_complete.mjs +222 -0
  58. package/skills/a2h-app-migrate/test/test_dag_production.mjs +670 -0
  59. package/skills/a2h-app-migrate/test/test_dag_runner.mjs +423 -0
  60. package/skills/a2h-app-migrate/test/test_finalize.mjs +21 -4
  61. package/skills/a2h-app-migrate/test/test_image_probe.mjs +1 -1
  62. package/skills/a2h-app-migrate/test/test_resume_plan.mjs +16 -1
  63. package/skills/a2h-app-migrate/test/test_reuse_static_utg.mjs +1 -1
  64. package/skills/a2h-app-migrate/test/test_utg_static_done.mjs +12 -5
  65. package/skills/a2h-arkts-logic-coder/SKILL.md +7 -8
  66. package/skills/a2h-arkts-logic-coder/references/ISSUES.md +1 -1
  67. package/skills/a2h-arkts-logic-coder/references/code-generation.md +27 -15
  68. package/skills/a2h-batch-ui-align/SKILL.md +1 -1
  69. package/skills/a2h-batch-ui-align/references/cards/widgets.md +4 -0
  70. package/skills/a2h-batch-ui-align/references/checker-rules.md +36 -0
  71. package/skills/a2h-batch-ui-align/references/conversion-procedure.md +4 -0
  72. package/skills/a2h-batch-ui-align/references/mappings/android-to-harmonyOS-ui-layout-mapping-reference.md +4 -0
  73. package/skills/a2h-batch-ui-align/references/step5-convert.md +3 -3
  74. package/skills/a2h-batch-ui-align/scripts/group_queue.mjs +49 -3
  75. package/skills/a2h-batch-ui-align/scripts/static_check/core/android.ts +36 -0
  76. package/skills/a2h-batch-ui-align/scripts/static_check/main.ts +8 -0
  77. package/skills/a2h-batch-ui-align/scripts/static_check/registry.ts +8 -0
  78. package/skills/a2h-batch-ui-align/scripts/static_check/rules/overlay_in_linear.ts +164 -0
  79. package/skills/a2h-batch-ui-align/scripts/static_check/rules/self_drawn_sheet.ts +105 -0
  80. package/skills/a2h-batch-ui-align/scripts/static_check/rules/staggered_lanes.ts +127 -0
  81. package/skills/a2h-batch-ui-align/scripts/static_check/rules/window_size_constant.ts +114 -0
  82. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_coolmall_ds1123.test.mjs +433 -0
  83. package/skills/a2h-batch-ui-align/scripts/tests/arkts_static_check_overlay_in_linear.test.mjs +288 -0
  84. package/skills/a2h-batch-ui-align/scripts/tests/group_queue.test.mjs +46 -0
  85. package/skills/a2h-page-specgen/references/scenario-authoring.md +4 -1
  86. package/skills/a2h-page-specgen/references/spec-example.md +35 -5
  87. package/skills/a2h-page-specgen/references/spec-template.md +4 -4
  88. package/skills/a2h-spec-generate/SKILL.md +3 -1
  89. package/skills/a2h-spec-generate/references/fusion-task-contract.md +15 -3
  90. package/skills/a2h-spec-generate/references/review-checklist.md +1 -0
  91. package/skills/a2h-spec-generate/references/spec-sample-complex.md +16 -0
  92. package/skills/a2h-spec-generate/references/spec-sample-transfer.md +16 -0
  93. package/skills/a2h-spec-generate/references/spec-samples.md +5 -1
  94. package/skills/a2h-spec-generate/references/synthesis-rules.md +21 -1
  95. package/skills/a2h-spec-generate/references/worker-rules.md +25 -2
  96. package/skills/a2h-spec-generate/scripts/check-fused-spec.mjs +3 -1
  97. package/skills/a2h-spec-generate/scripts/check_spec.ts +262 -6
  98. package/skills/a2h-spec-generate/scripts/reqgen/src/fusion/task-contract.ts +12 -2
  99. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-behavior-e2e.test.ts +3 -0
  100. package/skills/a2h-spec-generate/scripts/reqgen/test/fusion-spec.test.ts +16 -2
  101. package/skills/a2h-spec-generate/test/check-fused-spec.test.mjs +54 -3
  102. package/skills/a2h-spec-generate/test/check-spec.test.ts +247 -0
@@ -132,19 +132,30 @@ rendered value, write `state-docs: not-applicable` to `{output-path}/state_docs_
132
132
  dispatcher's field) → skip step 2, use `references/ISSUES.md`, write `state-docs: unavailable`,
133
133
  and continue; the chunk is never blocked on the docs.
134
134
 
135
- **Platform API doc gate (soft, before writing a platform call whose shape you do not know).**
136
- A platform API guessed by analogy compiles and misbehaves at runtime (wrong param order, a missing
137
- `await`, a callback that fires before the resource is ready). Run this gate when the chunk calls an
138
- API imported from `@kit.*` / `@ohos.*` and **the worktree does not already contain a working call
139
- site for it**, and any of these is unclear: parameter order/types, sync vs async, lifecycle
140
- (`create`/`destroy`, unregister), the return value's shape or unit, or the throwing/error path.
141
- Otherwise skip it — a local, already-used call site beats any doc — and record
142
- `api-docs: not-applicable`.
143
-
144
- Source precedence, always: **worktree code > local SDK `.d.ts` > docs**. The `.d.ts` wins on what
145
- exists, its signature, defaults, units and since-level; the doc wins on usage, parameter meaning,
146
- lifecycle and a runnable example. Both may be right about the signature and the doc still decide
147
- the `await`.
135
+ **Platform API doc gate.** Two classes — the class decides, not the writer's confidence.
136
+
137
+ *Shape (soft).* A platform API guessed by analogy compiles and misbehaves at runtime (wrong param
138
+ order, a missing `await`, a callback that fires too early). Run the steps below when the worktree has
139
+ no working call site for the API and its parameter order/types, sync/async, lifecycle, return shape
140
+ or error path is unclear; otherwise skip it and record `api-docs: not-applicable`.
141
+
142
+ *Semantics (mandatory).* A signature says what exists, not what a call means. Read one section of the
143
+ official page — even when a working call site exists — for any call whose correctness depends on:
144
+
145
+ - **Targets** — what it actually affects, and what it replaces, removes or leaves behind.
146
+ - **Ordering** — when it runs, and what must already exist by then.
147
+ - **Capability** — what is granted, at which level, and what denial must do.
148
+ - **Units** — unit, rounding, and whether a range is inclusive.
149
+ - **Addressed state** — which key, which store owns it, what a missing key means.
150
+
151
+ Read each distinct API once per chunk — dedupe by API, not by call site — at most 5 per chunk. Record
152
+ **one verbatim sentence from that page** in the row's `conclusion`; restating intent, or a row sourced
153
+ only from `SDK .d.ts`, does not satisfy this gate. Past the cap, or when the page cannot be read,
154
+ record `api-docs: unavailable` with the key and continue; never record `available`.
155
+
156
+ Source precedence: for **shape**, a working call site first, then `.d.ts`, then the official page; for
157
+ **meaning**, the official page outranks both. A difference in behaviour (not existence) goes in
158
+ `## Spec deviations`.
148
159
 
149
160
  1. Search once for the module, not for prose: `node <skill-dir>/scripts/state_doc.mjs search
150
161
  "@ohos.net.http request" --limit 3`. Only the `harmonyos-guides` and `harmonyos-references`
@@ -163,8 +174,9 @@ the `await`.
163
174
  `api-taskpool`, `api-crypto`, `api-i18n`, `api-webview`, `api-socket`, `api-common-event`,
164
175
  `api-background-task`; `list --api` prints the table) resolves the ID for you and is capped at
165
176
  400 lines by default.
166
- 3. Budget: at most 3 `search` calls and 2 section reads per chunk, batched into one turn. If that
167
- is not enough, re-read the local `.d.ts` instead of searching further.
177
+ 3. Budget: at most 3 searches and 2 section reads per chunk for shape queries. Semantics reads are
178
+ separate and deduped by API: one section per distinct API, at most 5 per chunk; the rest are
179
+ recorded `api-docs: unavailable`.
168
180
  4. Guard the API level: the doc tags a section `phone 12+ | 2in1 13+ …`. If the tag is above the
169
181
  project's `compatibleSdkVersion` (or the module's `minAPIVersion`), use the fallback the doc
170
182
  names (`canIUse`, an older overload, or a different API) instead of the newer call.
@@ -259,7 +259,7 @@ If a task-tracking tool is available, create one task per page, with already-`do
259
259
  - **5.3** host-chain groups run serially, self-contained groups concurrently; `group_queue.mjs` applies the rules from `plan`. When in doubt, serialize. Rule 7 binds every concurrent prompt:
260
260
 
261
261
  7. **The shared registry surface is parent-owned while any other group is in flight.** Every concurrently dispatched group's prompt states: do not edit `main_pages.json`, `resources/**/element/*.json`, `oh-package*.json5`, `module.json5` or the ability's `loadContent()`. Instead, list the additions in the report under `registry_requests`. The parent applies each group's requests when that group is released, one group at a time. Merge, never overwrite: an existing name with a different value is a conflict, so keep the existing value and record it in the report.
262
- - **5.4** Never dispatch blocking waves. `Q init` once, then one pass per parent turn: release (`Q reap` → `Q release`), lease and dispatch (`Q lease`, pass `message` verbatim, `Q bind`), verify every `returned_unverified` group (`phase5_check.mjs --group`, `Q verified`, `group_commit.mjs`), then `Q wait` with a shell timeout above 9 min. Go on only when `summary.idle` is true, nothing is unverified and `summary.stuck` is empty.
262
+ - **5.4** Never dispatch blocking waves. `Q init` once, then one pass per parent turn: release (`Q reap` → `Q release`), lease and dispatch (`Q lease`, pass `message` verbatim, `Q bind`), verify every `returned_unverified` group (`phase5_check.mjs --group`, `Q verified --summary`, which marks its pages `done` in `batch_progress.json`, then `group_commit.mjs`), then `Q wait` with a shell timeout above 9 min. Go on only when `summary.idle` is true, nothing is unverified and `summary.stuck` is empty.
263
263
  - **5.5** One background sub-agent (Step 0.1) does the wiring: confirm every `registry_requests` was applied, wire self-contained components and shell hosts, and wire navigation from `navigates_to`. No group is in flight any more, so this agent may edit the registry surface of Rule 7. The parent writes `${harmony_project_dir}/.hometrans/work/prompts/wiring.md` (the Step 5.5 procedure of step5-convert.md plus its inputs), dispatches it the way Step 2 is dispatched, and joins on `.hometrans/work/wiring.report.md`. **Gate (parent re-checks after the join):** `orphan-component` is zero, and `phase5_check.mjs --files <every file changed since the last group commit>` has `blocking` 0, and `node scripts/shell_requests.mjs verify --hp ${harmony_project_dir}` exits 0 (every ledger id answered, every deleted `.ets` has its merge line), before Step 6. Run `shell_requests.mjs collect` before writing `wiring.md` and put its table in the prompt; carry every `deferred` row into Step 7's Manual Follow-up TODOs. Take that file list from `git status --porcelain` (modified and untracked), not from the report: a file the agent edited but left out of the report would otherwise skip the gate and still be committed. The parent then commits the wiring.
264
264
 
265
265
  ## Step 6 — Static Check, Build, Smoke Gate
@@ -26,6 +26,10 @@ The report must include this ownership table, **each row labeled (a) / (b1) / (b
26
26
 
27
27
  **Appearance Substitution — do not "downgrade" an appearance the reference has captured**: if the **graphic structure** of a framework widget (picker, dialog, switch, progress bar…) in the reference screenshot differs from the same-named ArkUI component, the conclusion of question 2 can only be (b2) override or (a) custom drawing, or flagged `escalate`; you **must not** just write "ArkUI has no such form, degraded to X". This follows the same principle as the captured-state rule in Phase 5 "Transition Implementation Evidence": the appearance captured in the screenshot is itself the acceptance target. The typical instances are Android `TimePicker` / `TimePickerDialog`'s default clock face and `DatePicker` / `DatePickerDialog`'s default month calendar, while the same-named ArkUI components are all wheels (the "map by mode" row of the mapping table; GATE `framework-picker-appearance`). When the parent flow accepts the difference, write `// APPEARANCE-ESCALATED(<Widget>): <ruling source>` above the line and register `escalate` in the report.
28
28
 
29
+ **Bottom sheets (`ModalBottomSheet` / `BottomSheetDialog` / `BottomSheetScaffold`): use `bindSheet`; self-drawing is not the way out of a look mismatch**: besides its look, an Android Material bottom sheet carries a set of behaviors: drag the panel down to close, tap the scrim to close, back key to close, panel height bounded by the window. `bindSheet` / `UIContext.openBindSheet` bring these behaviors with them. Solve look differences with options: with `dragBar: false` the system draws no handle and the builder draws the Android one (e.g. 40×4dp, radius 2), which **does not count as drawing it twice**; panel color goes in `backgroundColor`, corners in `radius`, height in `height` / `detents`, scrim color in `maskColor`. So "the system handle differs from Android's" is not a reason to re-classify the sheet as (a) self-drawn. When it really must be self-drawn (Stack + scrim + panel), the report's part-ownership row lists each behavior of the original control and where it is implemented: drag to close (`PanGesture({ direction: PanDirection.Down })`, following the finger and calling the dismiss callback past a distance or velocity threshold), tap the scrim to close, back key to close (`onBackPress` / host interception), maximum panel height. A missing one is `needs escalation`, not implemented. GATE `self-drawn-sheet-no-drag-dismiss`.
30
+
31
+ **When part ownership is (a) self-drawn, take over the behavior too**: the three verdicts above only ask whether a decoration is drawn twice and whether it looks right. Once a control is re-classified (a) and the atomic component is no longer instantiated, its built-in **interaction behavior** is gone with it (drag to close, inertia, keyboard avoidance, back key, accessibility role), and neither the compiler, the screenshot comparison nor the GATEs notice. So an (a) row lists, besides the graphic structure, "built-in behavior of the original control → `file:line` of the self-drawn implementation"; a behavior with no implementation site is marked `needs escalation`.
32
+
29
33
  **One sheet / content cover per node**: a `bindSheet` / `bindContentCover` is owned by the node it is bound to, and a node keeps one modal lifecycle; with two on one attribute chain, one closes right after it opens ("tap, flash, gone"), and neither the build nor the smoke test shows it. Each Compose `ModalBottomSheet` has its own state, which in ArkUI means its own host node: bind each on its trigger node, or wrap each in an empty container as host; with many overlays, manage them with `UIContext.openBindSheet` / `closeBindSheet`. This applies equally when Step 5.5 wiring adds an overlay. GATE `multiple-overlay-binds-same-node`.
30
34
 
31
35
  **System dialogs and menus — anchor with the native mechanism, take the look from the source theme**: Android `PopupMenu` / `ContextMenu` / a `ListPopupWindow` anchored to a button, and `AlertDialog.Builder` / `MaterialAlertDialogBuilder`, are framework widgets whose **look is set by the Android app theme**, not by "the system"; once moved to ArkUI, "the system look" becomes the HarmonyOS look. The mapping table's "Direct mapping" only says the APIs line up, not that the look does.
@@ -116,6 +116,15 @@ A downgrade marker is written above the hit line (with the colon and the basis),
116
116
  - Fix: `main-axis-pct-siblings` (GATE: ≥2 direct children of a `Row`/`Column` are all `'100%'` on the main axis, including `@Builder` root nodes; CAND when only 1 is and it has other siblings) → change to `.layoutWeight(n)`
117
117
  - Downgrade marker: none
118
118
 
119
+ ### overlay-component-in-linear-container
120
+
121
+ - Level: GATE / CAND
122
+ - Needs: —
123
+ - Knowledge card: `references/cards/geometry.md`
124
+ - Trigger: A direct child (if / else branches included) of a `Row`/`Column` is an overlay component of this project — its build() root is `'100%'` on both axes and is shown under an `if (...)` flag with no (non-empty) else, or carries `.transition(` (an if / else state-switch view does not count); the same container has siblings that are not mutually exclusive with it, and the call site has no position/offset/markAnchor/layoutWeight/flexGrow. Decided across files, through package-name imports and wrapper components.
125
+ - Fix: An overlay is a layering element and takes no place in linear layout: make it a direct child of a `Stack` / `RelativeContainer` (after the content, at the same level as the content sibling), or use `bindSheet` / `bindContentCover` / `openCustomDialog`. When a `ForEach`/`Column` wrapper is added only to force a subtree rebuild, wrap the content alone and keep the overlay in the outer `Stack`. When it really takes a place in the flow (e.g. an inline expanding panel), write `// OVERLAY-IN-FLOW: <basis>` above the call to downgrade it to CAND.
126
+ - Downgrade marker: `// OVERLAY-IN-FLOW: <basis>`
127
+
119
128
  ### padding-consumes-fixed-size
120
129
 
121
130
  - Level: GATE / CAND
@@ -233,6 +242,15 @@ A downgrade marker is written above the hit line (with the colon and the basis),
233
242
  - Fix: `stack-overlay-default-center` (GATE: in a `Stack` likewise without `alignContent`, one of ≥2 siblings is positioned only by a one-sided `margin.bottom`/`margin.top`, does not fill the height, and has no position/offset/align; write `// STACK-CENTER: <basis>` for an intentional center to downgrade it to CAND) → set the matching `alignContent` on the `Stack`
234
243
  - Downgrade marker: `// STACK-CENTER: <basis>`
235
244
 
245
+ ### staggered-grid-lanes-by-index
246
+
247
+ - Level: GATE / CAND
248
+ - Needs: `--android`
249
+ - Knowledge card: `references/cards/geometry.md`
250
+ - Trigger: Data split into two columns by index parity: `for (let i = <non-zero start>; …; i += 2)`, or `.filter((_, i) => i % 2 …)`. GATE needs `--android`, and the two-column shape visible in the .ets file whose Android source (same file name, or it cites `X.kt`) uses `LazyVerticalStaggeredGrid` / `StaggeredGridItemSpan` / `StaggeredGridLayoutManager`: the method holding the loop (member method or top-level function) is called once with lane argument `0` and once with `1` (e.g. `vm.laneItems(0)` / `laneItems(this.all, 1)`), or that file writes two `.filter` splits. Any other step-2 loop (walking key/value pairs, etc.) is CAND only.
251
+ - Fix: A staggered grid places each item into the currently shortest column. A parity split balances the item count, not the height: with cards of different heights the two columns drift further apart row by row, and neither column is lazy. Use `WaterFlow` + `FlowItem` (`columnsTemplate('1fr 1fr')`); full-line items (`span = FullLine`) go into a `crossCount: 1` section (`WaterFlowSections`; spacing as in waterflow-sections-no-gap). When the source really splits by parity (not a staggered grid), write `// LANES-BY-INDEX: <source evidence>` above the split to close this rule.
252
+ - Downgrade marker: `// LANES-BY-INDEX: <basis>`
253
+
236
254
  ### text-input-default-padding-clips
237
255
 
238
256
  - Level: GATE / CAND
@@ -269,6 +287,15 @@ A downgrade marker is written above the hit line (with the colon and the basis),
269
287
  - Fix: write it as a relative width following Android's ratios (dialog: the backboard option `width` takes the screen-width share from the `dialog panel` line of measure_summary; the backboard is the panel, see the "Dialogs" item of the widgets card); when it really is a fixed width, note the basis
270
288
  - Downgrade marker: none
271
289
 
290
+ ### window-size-frozen-constant
291
+
292
+ - Level: GATE / CAND
293
+ - Needs: `--android`
294
+ - Knowledge card: `references/cards/geometry.md`
295
+ - Trigger: A `constraintSize` `maxHeight` / `maxWidth` is a number literal (≥ 100) or a constant initialized to one in this file, and this file reads no runtime window size (`getDefaultDisplaySync` / `getWindowProperties` / `windowSizeChange` / `windowRect` / `mainWindowSize`; `onAreaChange` / `onSizeChange` measure a component and do not count). Judged per axis: GATE when the Android source this file ports (same file name, or it cites `X.kt`) reads the window size on the same axis (height: `.screenHeightDp` / `heightPixels` / `containerSize.height` / `bounds.height()`; width likewise); CAND when it reads only an axis-less window API (`LocalWindowInfo` / `LocalConfiguration` / `displayMetrics` / `currentWindowMetrics`); nothing when it reads only the other axis. Members are matched on their own, so a value read into a local first (`configuration.screenHeightDp`) and the Java form (`getDisplayMetrics().heightPixels`) count.
296
+ - Fix: A bound the Android side computes from the runtime window cannot become a constant worked out on the capture device: on a shorter screen the region keeps its height and pushes the buttons after it off screen. Read the runtime window height (`display.getDefaultDisplaySync()` / the window's `getWindowProperties().windowRect`, px to vp, minus the reserved height from the source), or make the layout flexible: the scrolling region `layoutWeight(1)` (or `flexShrink(1)`) under a parent with `constraintSize({ maxHeight })`, the fixed block (button row) after it so it is never pushed out. When the bound really has nothing to do with the window, write `// SIZE-NOT-WINDOW: <source evidence>` above the line to close this rule.
297
+ - Downgrade marker: `// SIZE-NOT-WINDOW: <basis>`
298
+
272
299
  ## appearance — Appearance (color, widget appearance, visual effects, transitions)
273
300
 
274
301
  ### alpha-scale-mismatch
@@ -680,6 +707,15 @@ A downgrade marker is written above the hit line (with the colon and the basis),
680
707
  - Fix: the callback argument is this frame's delta, not the accumulated offset. For an accumulated offset (collapsing header, top-bar fade, Compose `firstVisibleItemScrollOffset` / View `getScrollY()`) read `this.scroller.currentOffset().yOffset`, or accumulate on state with `+=`; comparing with 0 to tell the direction is fine. When a delta is really meant, write `// SCROLL-DELTA: <basis>` above the callback or the assignment to downgrade to CAND.
681
708
  - Downgrade marker: `// SCROLL-DELTA: <basis>`
682
709
 
710
+ ### self-drawn-sheet-no-drag-dismiss
711
+
712
+ - Level: GATE / CAND
713
+ - Needs: `--android`
714
+ - Knowledge card: `references/cards/widgets.md`
715
+ - Trigger: A direct child of `Stack({ alignContent: Alignment.Bottom* })` is a scrim filling both axes with `.onClick`, with another sibling (the panel), and neither that Stack block nor the `this.X()` @Builder bodies it calls hold a `PanGesture` / `SwipeGesture`. Each Stack is judged on its own: a `bindSheet` or gesture on another overlay in the same file does not exempt this one. GATE needs `--android`, and the Android source this file ports (same file name, or it cites `X.kt`) uses `ModalBottomSheet` / `BottomSheetDialog` / `BottomSheetScaffold`; otherwise CAND only. Known false positive: a full-size tappable layer plus a sibling for another purpose (tap blank space to hide the keyboard + a bottom bar) is reported as GATE too when the matching Android file also has a bottom sheet; close it with the marker once confirmed not a sheet.
716
+ - Fix: An Android Material bottom sheet closes when dragged down; a self-drawn Stack keeps only tap-the-scrim. Prefer `bindSheet(..., { dragBar: false, backgroundColor, ... })` or `UIContext.openBindSheet`, drawing the Android drag handle in the builder (with `dragBar: false` the system draws none, so nothing is drawn twice). When it must be self-drawn, put `PanGesture({ direction: PanDirection.Down })` on the panel, follow the finger and call the dismiss callback past a distance or velocity threshold, and handle the back key. When the source really cannot be dragged closed (`sheetGesturesEnabled = false`, or `confirmValueChange` refuses hiding), write `// SHEET-NO-DRAG: <source evidence>` above the Stack to close this rule.
717
+ - Downgrade marker: `// SHEET-NO-DRAG: <basis>`
718
+
683
719
  ### shell-content-has-entry
684
720
 
685
721
  - Level: GATE
@@ -194,6 +194,8 @@ Criterion (mechanical): when the conclusion text contains words like "built in /
194
194
  - `bounds` differences are only for computing region ratios and verifying relative layout, never used directly as vp; intrinsic dp/sp sizes follow Android XML/dimens
195
195
  - Resources use `$r('app.color.xxx')` / `$r('app.string.xxx')` / `$r('app.media.xxx')`
196
196
 
197
+ **When several call sites become one `@Builder` / component, merge only what every call site has**: compare the arguments of each similar Android call (e.g. two cards whose title rows are both `AppListItem(leadingContent = TitleWithLine(...))`) before deciding the builder's shape. Only content every call site passes may be hard-coded in the builder; content only some call sites have (a `trailingContent`, icon, arrow or badge present in one place) becomes a parameter (an optional `@Builder` slot or a boolean), and each call site passes its own Android argument. The test: for each call site, ask "expanded here, does every node the builder adds or drops exist at this Android call". The CoolMall logistics page: the logistics-info card title row has the courier logo, the logistics-track card title row has none; merged into one `TitleRow` with the logo hard-coded, the track card's title gained an extra icon. A source-only page has no screenshot to compare against, so only this per-call-site comparison catches it. In Phase 5 visible-resource closure, list for every builder with several call sites "call site → `file:line` of the matching Android call → optional parts present / absent there".
198
+
197
199
  **Routing**: implement the routing relations between the UI and components.
198
200
 
199
201
  **Interactive elements**:
@@ -302,6 +304,8 @@ List every layout/component/resource reference in the converted HarmonyOS UI and
302
304
  - **Shape Background Evidence**: list the mapping from Android ShapeDrawables to ArkUI styles; a stretchable shape without `<size>` used via an ordinary Image + `ImageFit.Fill` is a failure.
303
305
  - **Static Clipping Check**: using the main-region ratios of the reference screenshot/view tree, check that the toolbar, content area, cards and bottom area do not cover each other or exceed the expected content area. **Also**:
304
306
  - For sibling text/icon rows inside a `Stack`, write out each one's vertical interval `[top, top+height]` and its origin (criterion: the origin paragraph of "Hard requirement (coordinate system)" in `cards/geometry.md`); for state-driven offsets/sizes, compute the start and end values once each and compare them with the corresponding snapshot bounds — if the snapshot shows no overlap but the computation does, it fails.
307
+ - **Compute every state branch, not only the captured frame**: for each source branch that makes this region taller (rows added after a selection, an expanded state, an error hint, a block shown only `if (x != null)`), add its extra height from the state-branch list and compute again. A fixed bottom block (button row, input bar) must stay on screen in every branch: the scrolling region takes `layoutWeight(1)` (or `flexShrink(1)`) under a parent with a height bound, and the fixed block comes after it. Proving "it fits" with one frame's numbers (e.g. `759 < 783.6`) while the source has a taller branch fails this item.
308
+ - **A size computed from the window stays computed from the window**: a bound Android derives from `LocalWindowInfo` / `LocalConfiguration.screenHeightDp` / `displayMetrics` (e.g. `heightIn(max = screen height − 380dp)`) reads the runtime window size on HarmonyOS, or becomes the flexible layout above. It is never the constant worked out on the capture device (`914.29 − 380 = 534`), which is right only on that screen. GATE `window-size-frozen-constant`.
305
309
  - For text that is **single-line** `wrap_content` in the reference view tree (height ≈ one line of text), find its available width on the HarmonyOS side (parent width − width taken by same-row siblings − padding) and estimate from the font size that the text fits; if it does not fit while it fits on Android, the structure has spread siblings into the same row (the "two-dimensional constraints" row of the ConstraintLayout rewrite table in `cards/geometry.md`) — change the structure; do not mask it by shrinking the font or truncating with `maxLines(1)`.
306
310
  - **Interaction Reachability Evidence**: for each clickable element, list its **z-order** in the parent `Stack`/layered structure and confirm that **no** sibling after it covers its visible rectangle. **Also** list every container on this page with `width('100%')` and `height('100%')` (or equivalent fill) and label each as interactive or as having declared `hitTestBehavior(HitTestMode.None)`. "No visual overlap" and "hits not blocked" are two different things: a transparent or bottom-pinned container does not count as covering in a visual check, yet it can swallow every click beneath it. The typical sign of missing this item is an element that looks normal but does nothing at all when tapped (not even console output), because the event is consumed by an upper node that has no `onClick` of its own. Whether a filling layer swallows taps is decided by the checker from the layer structure: a `stack-swallows-taps` / `fullsize-container` GATE closes only by fixing the code or by a `// HIT-TEST:` marker the checker verifies, not by the evidence written here; this item only annotates the remaining CANDs one by one.
307
311
 
@@ -108,6 +108,10 @@
108
108
  | `ArrayAdapter` | `ForEach` + array | Array adapter |
109
109
  | `BaseAdapter` | `ForEach` / `LazyForEach` | Base adapter |
110
110
 
111
+ ### A staggered grid is not two Columns filled by index
112
+
113
+ `LazyVerticalStaggeredGrid` / `StaggeredGridLayoutManager` puts each next item into the **currently shortest** column. A `Row` of two `Column`s filled by index parity (`for (let i = lane; …; i += 2)`) gives each column the same number of items but not the same height: with cards of different heights the two columns drift further apart toward the bottom, and the order the user sees differs from Android. Neither `Column` is lazy, so the whole goods area sits in one `ListItem` and every load-more lays out all data at once. Always use `WaterFlow` + `FlowItem`: `columnsTemplate('1fr 1fr')`, full-line items (`span = FullLine`) in a `crossCount: 1` section, grid items in a `crossCount: 2` section, the load-more tail as the `WaterFlow` `footer`. "Weight + fixed spacing" describes column width, not placement, and does not justify two `Column`s. GATE `staggered-grid-lanes-by-index`.
114
+
111
115
  ### Compose lazy grid parameters (LazyVerticalStaggeredGrid / LazyVerticalGrid → WaterFlow / Grid)
112
116
 
113
117
  Beyond the component mapping, these parameters decide spacing and full-line items. **Map every one; a missing one is a visible defect** (GATE `waterflow-sections-no-gap`):
@@ -89,7 +89,7 @@ A fresh attempt of the leader withdraws its markers, while a resume keeps them.
89
89
  **Incremental mode:** the entry page, shared files and conventions already exist. This group's job is to **read and record** the conventions (decorator paradigm, naming, `fontFamily`, resource style, project-wide bans) into the Step 4.4 facts, and to extend the existing shared files. It still runs alone and first, since it is the group most likely to touch the pre-existing shared surface.
90
90
  2. After it completes, the remaining host-chain groups run serially and self-contained groups concurrently beside them.
91
91
  3. **A self-contained group may not edit the entry page or shared VM/Model; its prompt says so.** If it needs to, it reports that instead of writing. The parent does the wiring in Step 5.5, or reclassifies the group as host-chain on a later run.
92
- 4. **Only the parent writes `batch_progress.json`**: read-modify-write, one group at a time, after each group returns.
92
+ 4. **Only the parent writes `batch_progress.json`**: read-modify-write, one group at a time, after each group returns. `Q verified` writes the group's pages `done` itself (below); the parent writes only `failed` pages and notes.
93
93
  5. If a group's actual writes violate its class, the parallel assumption is broken: finish serially and record it.
94
94
  6. **Captured groups go before the source-only groups that depend on them.** Shared tokens (theme colours, density-derived dimensions, list-row and toolbar components) must come from measured pages. Captures show the light scheme only: when the contract's `theme.mode` is not `static`, a colour token is a `$r('app.color.*')` resource whose dark value comes from the Android dark scheme / `values-night` line it cites, never a hex constant (GATE `theme-color-literal`). A source-only group waits for its `template_groups` and `reuse_from` leaders, not for every captured group. It may extend a value a captured group established, but not change it. Contradicting source evidence is reported (contract item 4), and the parent decides.
95
95
  7. **The shared registry surface is parent-owned while any other group is in flight.** Every concurrently dispatched group's prompt states: do not edit `main_pages.json`, `resources/**/element/*.json`, `oh-package*.json5`, `module.json5` or the ability's `loadContent()`. Instead, list the additions in the report under `registry_requests`: `{ "main_pages": ["pages/X"], "elements": { "string": [{"name","value"}], "color": [...], "dark_color": [...], "float": [...] }, "dependencies": {"@ohos/lottie": "<ver>"}, "entry_route": "pages/X" | null }`.
@@ -135,7 +135,7 @@ Only true dependencies make a group wait (`after`, lane, `reuse_from`, `template
135
135
  - Parallel `Q` calls are safe: every mutating call holds `.hometrans/queue_state.json.lock`.
136
136
  2. **Lease and dispatch.** `Q lease ${harmony_project_dir}` returns `dispatch: [{unit, groups, resume_task, description, message, message_file}]`. `message` is a one-line pointer (`Read the file <message_file> and follow it fully.`), and the full text is in `message_file` (`.hometrans/work/dispatch/<unit>.a<attempt>.md`, one file per attempt). Pass `message` verbatim as the sub-agent prompt, for fresh and resumed sessions alike. `Q message ${harmony_project_dir} --unit <unit>` prints it again while the unit runs. Never rebuild a message yourself or call the script's internal functions. `released_without_dispatch` lists queued resumes whose session had already written its report: they are released without an agent; verify them like any return. For each `dispatch` entry, start one background sub-agent with `message` as its prompt (all in one message; opencode v2 `subagent` with `background: true`, opencode v1 / DevEco `task` with `background: true`). When `resume_task` is set, resume that session instead (opencode v2: `subagent` with `sessionID` = `resume_task`; opencode v1 / DevEco: `task` with `task_id` = `resume_task`; Claude Code: SendMessage to that agent if it is still known, otherwise a fresh agent with the same message). Then `Q bind … --unit <unit> --task <handle>` for each, where `<handle>` is the returned `sessionID` (v2) or `task_id` (v1/DevEco).
137
137
  - **Evidence intake (two steps, one session).** A fresh session of a group with screenshots or view trees is leased with `phase: "intake"`: its message lists only that group's evidence (`.hometrans/work/evidence/<GID>.json`: meta.json, every screenshot, every view tree, measure_summary.txt, plus `conversion-procedure.md` with its source-only section named when a member is source-only or an attached node has no capture) and the `evidence_gate.mjs ack` command. It carries no conversion task and no write set, so nothing can be written before the evidence is read. Dispatch and `bind` it like any unit; the agent replies `READY <GID>`. Its release returns `intake-accepted` once every member's ack covers its manifest, and the next `lease` resumes **that same session** (`phase: "convert"`, `resume_task` set) with the full prompt. The evidence it read stays in its context. The continuation is leased before any other unit and keeps its slot and lane. `intake-resume` resumes the session with the files still unread (at most `INTAKE_MAX_ROUNDS` rounds, then `intake-failed`). `intake-unbound` means no `bind` was recorded, so a fresh session reads again: always bind. After `INTAKE_MAX_ROUNDS` unbound intakes the group is `intake-failed`. `intake-recaptured` means a member was captured while the session read: it reads again with the new frames. A queued `RECAPTURED` or `requeue --message` text is held through intake and delivered with the conversion task, and `requeue` after a failed intake starts a new one. A predicted file changed during intake is listed as `touched`, and the conversion message tells the agent to re-check it. A source-only group (no frames) and every resume of a converting session skip intake; `init --no-evidence-gate` turns it off.
138
- 3. **Verify** every group in `summary.returned_unverified` (below). Then update `batch_progress.json`, run `Q verified … --group <GID>` (only a `returned` group: never mark a group done in `batch_progress.json` by hand to close it), and, when `harmony_project_dir` is in a git work tree, `node <this skill>/scripts/group_commit.mjs ${harmony_project_dir} --group <GID>`. The commit takes only the files that group changed and holds other unsettled groups' predicted writes; a file shared by several groups goes to the first one committed.
138
+ 3. **Verify** every group in `summary.returned_unverified` (below). Then run `Q verified … --group <GID> --summary "<one line>"` (only a `returned` group: never mark a group done in `batch_progress.json` by hand to close it). It marks every page of the group `done` in `batch_progress.json` (`status`, `group`, `verified_at`, `tier`, `output` = the files it wrote plus the `.ets` its report names, `summary`) and refreshes `updated_at`, so the page ledger never trails the queue; it refuses a file that belongs to another run. Then, when `harmony_project_dir` is in a git work tree, `node <this skill>/scripts/group_commit.mjs ${harmony_project_dir} --group <GID>`. The commit takes only the files that group changed and holds other unsettled groups' predicted writes; a file shared by several groups goes to the first one committed.
139
139
  - `missing` non-empty: `Q requeue … --group <GID> --resume --message "<missing files; written files are read-only context>"`.
140
140
  - Verification failed: `Q requeue … --group <GID> --message "<what to fix>"`. If the group's bound session had stalled, this resumes that session automatically. Use `--fresh` only after that session's completion notice has arrived.
141
141
  4. **Capture track** (Step 3.2) work, if any. Then `Q wait ${harmony_project_dir} [--job run_cycle]` (bound reviewers are followed; `--answers` only for unbound files). It returns within seconds of a report, a silent unit, an ended job, complete answers, or an evidence-intake ack that now covers every file (`reasons: ["intake"]`, `intake_acked: [GID…]` — release those groups). It also returns when a free slot has a ready or backfill unit. Otherwise it returns after 9 min. Give the shell call a timeout above that (e.g. 600000 ms). Never sleep in a loop instead.
@@ -154,7 +154,7 @@ Only true dependencies make a group wait (`after`, lane, `reuse_from`, `template
154
154
  - the Phase 5 evidence is in the location the output contract assigns it;
155
155
  - the parent's own mechanical re-verification passes.
156
156
 
157
- Otherwise set it `failed` with what is missing. For `done`, record `output` + a one-line `summary`, refresh `updated_at`, and append the summary to the cumulative report.
157
+ Otherwise set it `failed` with what is missing and `requeue` the group. For `done`, run `Q verified --summary` (it records `output`, `summary` and `updated_at`; never write a `done` page by hand, and never defer the write to the end of Step 5), and append the summary to the cumulative report.
158
158
 
159
159
  Phase 5 evidence by tier:
160
160
  - **A-tier — written out in full in the report** (one-line conclusions do not count): **Window Mode Evidence (all four sub-items), Transition Implementation Evidence, Duplicate Decoration Check, Visible Resource Closure, Position Anchor Evidence**. Their failure mode is two individually-correct rules combining into an error, which only shows when the reasoning chain is spelled out.
@@ -20,6 +20,7 @@ import { checkFormatStringWithoutArgs } from './rules/format_string.ts';
20
20
  import { checkFrameworkDialogAppearance } from './rules/framework_dialog.ts';
21
21
  import { checkFrameworkPickerAppearance } from './rules/framework_picker.ts';
22
22
  import { checkPctAutoRoots, checkStackCustomKids } from './rules/layout_placement.ts';
23
+ import { checkOverlayInLinearContainer } from './rules/overlay_in_linear.ts';
23
24
  import { checkMediaContentUsable } from './rules/media_content.ts';
24
25
  import { checkFullViewportTint, checkRasterTint, checkSvgTintChannel } from './rules/media_tint.ts';
25
26
  import { checkOffsetInScrollContent } from './rules/offset_in_scroll.ts';
@@ -37,6 +38,9 @@ import { checkStackOccludingSibling, loadColors } from './rules/stack_occluding.
37
38
  import { checkHitTest } from './rules/hit_test.ts';
38
39
  import { checkEventDefaultClick } from './rules/event_default_click.ts';
39
40
  import { checkWaterFlowSectionGaps } from './rules/waterflow_sections.ts';
41
+ import { checkStaggeredLanes } from './rules/staggered_lanes.ts';
42
+ import { checkSelfDrawnSheet } from './rules/self_drawn_sheet.ts';
43
+ import { checkWindowSizeConstant } from './rules/window_size_constant.ts';
40
44
  import { checkLottieHost } from './rules/lottie_host.ts';
41
45
  import { checkStringResources } from './rules/string_quote_leak.ts';
42
46
  import { checkSurfaceStroke } from './rules/surface_stroke.ts';
@@ -137,6 +141,7 @@ export function main(): void {
137
141
  checkRootWeightWrapped(scans);
138
142
  checkPctAutoRoots(scans);
139
143
  checkStackCustomKids(scans);
144
+ checkOverlayInLinearContainer(scans);
140
145
  checkSharedChromePlacement(scans);
141
146
  checkPercentHeightInScroll(scans);
142
147
  checkRelativeContainerInScroll(scans);
@@ -147,6 +152,9 @@ export function main(): void {
147
152
  checkHitTest(scans);
148
153
  checkEventDefaultClick(scans);
149
154
  checkWaterFlowSectionGaps(scans, androidDir);
155
+ checkStaggeredLanes(scans, androidDir);
156
+ checkSelfDrawnSheet(scans, androidDir);
157
+ checkWindowSizeConstant(scans, androidDir);
150
158
  checkOffsetInScrollContent(scans);
151
159
  checkEntryRoute(scans, etsRoots);
152
160
  checkRequestPermissions(etsRoots, argOf('--sdk') || process.env.DEVECO_SDK_HOME || '');
@@ -0,0 +1,164 @@
1
+ // static_check/rules/overlay_in_linear.ts — GATE overlay-component-in-linear-container.
2
+
3
+ import { report } from '../core/findings.ts';
4
+ import { directUiChildren, exclusiveBranches, expandStyles, fullOnAxis, hasAttr, lineOfIndex, markedAbove, matchBracket, styleDecls } from '../core/parse.ts';
5
+ import type { UiAttr, UiChild } from '../core/parse.ts';
6
+ import { maskedOf } from '../core/scan.ts';
7
+ import type { FileScan } from '../core/scan.ts';
8
+ import type { RuleMeta } from '../core/meta.ts';
9
+ import { BUILTIN_KINDS, structDeclFile } from './layout_placement.ts';
10
+
11
+ /** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
12
+ export const meta: RuleMeta[] = [
13
+ {
14
+ id: "overlay-component-in-linear-container",
15
+ levels: ["GATE", "CAND"],
16
+ invariant: "geometry",
17
+ card: "geometry",
18
+ needs: [],
19
+ summary: "A direct child (if / else branches included) of a `Row`/`Column` is an overlay component of this project — its build() root is `'100%'` on both axes and is shown under an `if (...)` flag with no (non-empty) else, or carries `.transition(` (an if / else state-switch view does not count); the same container has siblings that are not mutually exclusive with it, and the call site has no position/offset/markAnchor/layoutWeight/flexGrow. Decided across files, through package-name imports and wrapper components.",
20
+ fix: "An overlay is a layering element and takes no place in linear layout: make it a direct child of a `Stack` / `RelativeContainer` (after the content, at the same level as the content sibling), or use `bindSheet` / `bindContentCover` / `openCustomDialog`. When a `ForEach`/`Column` wrapper is added only to force a subtree rebuild, wrap the content alone and keep the overlay in the outer `Stack`. When it really takes a place in the flow (e.g. an inline expanding panel), write `// OVERLAY-IN-FLOW: <basis>` above the call to downgrade it to CAND.",
21
+ escape: "// OVERLAY-IN-FLOW:",
22
+ cases: [
23
+ "Measured (ds-1123 Weather): a review fix round rebuilt the content tree on language switch by wrapping the shell Stack's content and the search overlay together in `ForEach([uiRevision]) { Column() {...} }`; `SearchMenuFragmentDialog` (root `if (visible) { Stack().width('100%').height('100%').transition(...) }`) came after the 100%-high content page, landed below the viewport, and tapping search showed no panel. Build, Homecheck and smoke all passed; round 2 review judged FAIL but the orchestrator did not fix it.",
24
+ ],
25
+ },
26
+ ];
27
+
28
+ /** What makes a struct an overlay: its build() root fills both axes and is shown on a flag or animates in. */
29
+ interface OverlayRoot {
30
+ /** File and line of the root statement, for the report. */
31
+ file: FileScan;
32
+ line: number;
33
+ /** Wrapper structs walked through (Outer → Inner). */
34
+ via: string[];
35
+ }
36
+
37
+ /** Bounds of `build() { … }` inside `struct <name> { … }` in code, or null. */
38
+ function buildBody(code: string, name: string): [number, number] | null {
39
+ const re: RegExp = new RegExp('\\bstruct\\s+' + name + '\\b[^{]*\\{', 'g');
40
+ const m: RegExpExecArray | null = re.exec(code);
41
+ if (m === null) { return null; }
42
+ const open: number = m.index + m[0].length - 1;
43
+ const close: number = matchBracket(code, open);
44
+ if (close < 0) { return null; }
45
+ const bm: RegExpExecArray | null = /\bbuild\s*\(\s*\)\s*(?::\s*void\s*)?\{/.exec(code.slice(open, close));
46
+ if (bm === null) { return null; }
47
+ const bOpen: number = open + bm.index + bm[0].length - 1;
48
+ const bClose: number = matchBracket(code, bOpen);
49
+ return bClose < 0 ? null : [bOpen, bClose];
50
+ }
51
+
52
+ const PLACED: string[] = ['position', 'offset', 'markAnchor', 'alignRules'];
53
+
54
+ /**
55
+ * The root is shown on a flag: some `if` it sits in has no other branch drawing anything (no `else`, or an empty one).
56
+ * A root in an if / else chain whose other branch draws something is a state switch (empty view ↔ list), not an
57
+ * overlay: the component always occupies its place, it only changes what it draws there.
58
+ */
59
+ function flagShown(r: UiChild, all: UiChild[]): boolean {
60
+ return (r.branchPath ?? []).some(([chain, idx]) => !all.some((o) => o !== r &&
61
+ (o.branchPath ?? []).some(([c, i]) => c === chain && i !== idx)));
62
+ }
63
+
64
+ /**
65
+ * Whether struct `comp` (seen from `from`) renders as an overlay. Wrapper components whose only root is another
66
+ * custom component are followed (up to `depth` levels); the wrapper may be the one that adds the flag.
67
+ */
68
+ function overlayRootOf(scans: FileScan[], declCount: Map<string, number>, from: FileScan, comp: string,
69
+ via: string[] = [], conditional: boolean = false, depth: number = 4): OverlayRoot | undefined {
70
+ if (depth <= 0 || via.includes(comp)) { return undefined; }
71
+ const file: FileScan | undefined = structDeclFile(scans, declCount, from, comp);
72
+ if (file === undefined) { return undefined; }
73
+ const body: [number, number] | null = buildBody(file.code, comp);
74
+ if (body === null) { return undefined; }
75
+ const all: UiChild[] = directUiChildren(file.code, body[0], body[1], undefined, { intoBranches: true });
76
+ const roots: UiChild[] = all.filter((c) => c.control !== true);
77
+ if (roots.length === 0) { return undefined; }
78
+ const styles = styleDecls(file.code, maskedOf(file));
79
+ for (const r of roots) {
80
+ const a: UiAttr[] = expandStyles(file.code, styles, r.attrs, r.at);
81
+ if (PLACED.some((n) => hasAttr(a, n))) { continue; }
82
+ const shown: boolean = conditional || flagShown(r, all) || hasAttr(a, 'transition');
83
+ if (fullOnAxis(a, 'width') && fullOnAxis(a, 'height') && shown) {
84
+ return { file, line: lineOfIndex(file.code, r.at), via: [...via, comp] };
85
+ }
86
+ if (roots.length === 1 && !r.isBuilderCall && /^[A-Z]/.test(r.name) && !BUILTIN_KINDS.has(r.name)) {
87
+ return overlayRootOf(scans, declCount, file, r.name, [...via, comp], shown, depth - 1);
88
+ }
89
+ }
90
+ return undefined;
91
+ }
92
+
93
+ /**
94
+ * GATE overlay-component-in-linear-container: an overlay component (full-size root shown on a flag / animated in)
95
+ * sits in a Row / Column next to siblings that are on screen at the same time.
96
+ *
97
+ * A Row / Column lays its children out one after another on the main axis; percentages are resolved against the
98
+ * parent and not shared, and children do not shrink by default. An overlay placed after a full-size content sibling
99
+ * therefore starts at y = 100% (below the viewport); placed before it, it pushes the content out while it is shown.
100
+ * Either way the flag flips, the tap handler runs, and nothing visible appears — compile, Homecheck and cold-start
101
+ * smoke all pass, because none of them taps the entry.
102
+ *
103
+ * The overlay's root usually lives in another module (imported by package name), so the call site alone shows
104
+ * nothing wrong; this is decided across files. Children in different branches of one if / else chain are never on
105
+ * screen together and do not count as siblings.
106
+ */
107
+ export function checkOverlayInLinearContainer(scans: FileScan[]): void {
108
+ const declCount: Map<string, number> = new Map();
109
+ for (const s of scans) {
110
+ for (const n of s.declaredStructs) { declCount.set(n, (declCount.get(n) || 0) + 1); }
111
+ }
112
+ const cache: Map<string, OverlayRoot | null> = new Map();
113
+ for (const s of scans) {
114
+ const rawLines: string[] = s.src.split(/\r?\n/);
115
+ // Find containers in the string-masked text (same length as code), so `Column(` inside a string never matches.
116
+ const masked: string = maskedOf(s);
117
+ const styles = styleDecls(s.code, masked);
118
+ const re: RegExp = /(^|[^\w$.])(Row|Column)\s*\(/g;
119
+ let m: RegExpExecArray | null;
120
+ while ((m = re.exec(masked)) !== null) {
121
+ const paren: number = m.index + m[0].length - 1;
122
+ const pclose: number = matchBracket(masked, paren);
123
+ if (pclose < 0) { continue; }
124
+ let k: number = pclose + 1;
125
+ while (k < masked.length && /\s/.test(masked[k])) { k++; }
126
+ if (masked[k] !== '{') { continue; }
127
+ const close: number = matchBracket(masked, k);
128
+ if (close < 0) { continue; }
129
+ const kids: UiChild[] = directUiChildren(s.code, k, close, undefined, { intoBranches: true })
130
+ .filter((c) => c.control !== true);
131
+ if (kids.length < 2) { continue; }
132
+ for (const c of kids) {
133
+ if (c.isBuilderCall || !/^[A-Z]/.test(c.name) || BUILTIN_KINDS.has(c.name)) { continue; }
134
+ const ca: UiAttr[] = expandStyles(s.code, styles, c.attrs, c.at);
135
+ if (PLACED.some((n) => hasAttr(ca, n))) { continue; }
136
+ // A weighted child takes only the space its siblings leave; it is never pushed past the viewport.
137
+ if (hasAttr(ca, 'layoutWeight') || hasAttr(ca, 'flexGrow')) { continue; }
138
+ const others: UiChild[] = kids.filter((o) => o !== c && !exclusiveBranches(c, o));
139
+ if (others.length === 0) { continue; }
140
+ const key: string = `${s.abs}\u0000${c.name}`;
141
+ let ov: OverlayRoot | null | undefined = cache.get(key);
142
+ if (ov === undefined) {
143
+ ov = overlayRootOf(scans, declCount, s, c.name) ?? null;
144
+ cache.set(key, ov);
145
+ }
146
+ if (ov === null) { continue; }
147
+ const line: number = lineOfIndex(s.code, c.at);
148
+ const kind: string = m[2];
149
+ // Siblings after it are pushed out while it shows; with every sibling before it, it starts past their end.
150
+ const pushes: boolean = others.some((o) => o.at > c.at);
151
+ const chain: string = ov.via.length > 1 ? ` (through ${ov.via.join(' → ')})` : '';
152
+ report(markedAbove(rawLines, line, 'OVERLAY-IN-FLOW') ? 'CAND' : 'GATE',
153
+ 'overlay-component-in-linear-container', s.rel, line,
154
+ `${c.name}(…) is an overlay — its build() root (${ov.file.rel}:${ov.line}${chain}) is '100%' × '100%' and shown on a flag / ` +
155
+ `animated in — but it is a child of a ${kind} next to siblings that are on screen at the same time. ` +
156
+ `A ${kind} lays children out one after another and does not shrink them, so the overlay ` +
157
+ (pushes ? 'pushes the content out of view while it is shown' : 'is laid out after its siblings, below the viewport, and never appears') +
158
+ '. Make it a direct child of a Stack / RelativeContainer (after the content), or use bindSheet / bindContentCover / ' +
159
+ 'openCustomDialog; when a ForEach / Column wrapper exists only to rebuild the content, wrap the content alone. ' +
160
+ 'When it really takes a place in the flow, write // OVERLAY-IN-FLOW: <basis> above the call');
161
+ }
162
+ }
163
+ }
164
+ }
@@ -0,0 +1,105 @@
1
+ // static_check/rules/self_drawn_sheet.ts — GATE self-drawn-sheet-no-drag-dismiss.
2
+ //
3
+ // Material ModalBottomSheet / BottomSheetDialog close when the user drags the panel down. A converter that redraws
4
+ // the sheet as a Stack (full-screen scrim + bottom panel) to match the Android look keeps the tap-scrim-to-close but
5
+ // silently loses the drag: nothing in ArkUI adds it to a plain Stack. bindSheet keeps the drag, and with
6
+ // `dragBar: false` the builder can draw the Android drag handle itself, so the look is not a reason to self-draw.
7
+
8
+ import * as fs from 'fs';
9
+ import { report } from '../core/findings.ts';
10
+ import { attrsWithArgs, directUiChildren, fullOnAxis, hasAttr, lineOfIndex, markedAbove, matchBracket } from '../core/parse.ts';
11
+ import { androidStemsWhere, portedAndroidStem } from '../core/android.ts';
12
+ import { maskedOf } from '../core/scan.ts';
13
+ import type { FileScan } from '../core/scan.ts';
14
+ import type { RuleMeta } from '../core/meta.ts';
15
+
16
+ /** Rule metadata (rendered by scripts/gen_rule_docs.mjs). */
17
+ export const meta: RuleMeta[] = [
18
+ {
19
+ id: "self-drawn-sheet-no-drag-dismiss",
20
+ levels: ["GATE", "CAND"],
21
+ invariant: "interaction",
22
+ card: "widgets",
23
+ needs: ["--android"],
24
+ summary: "A direct child of `Stack({ alignContent: Alignment.Bottom* })` is a scrim filling both axes with `.onClick`, with another sibling (the panel), and neither that Stack block nor the `this.X()` @Builder bodies it calls hold a `PanGesture` / `SwipeGesture`. Each Stack is judged on its own: a `bindSheet` or gesture on another overlay in the same file does not exempt this one. GATE needs `--android`, and the Android source this file ports (same file name, or it cites `X.kt`) uses `ModalBottomSheet` / `BottomSheetDialog` / `BottomSheetScaffold`; otherwise CAND only. Known false positive: a full-size tappable layer plus a sibling for another purpose (tap blank space to hide the keyboard + a bottom bar) is reported as GATE too when the matching Android file also has a bottom sheet; close it with the marker once confirmed not a sheet.",
25
+ fix: "An Android Material bottom sheet closes when dragged down; a self-drawn Stack keeps only tap-the-scrim. Prefer `bindSheet(..., { dragBar: false, backgroundColor, ... })` or `UIContext.openBindSheet`, drawing the Android drag handle in the builder (with `dragBar: false` the system draws none, so nothing is drawn twice). When it must be self-drawn, put `PanGesture({ direction: PanDirection.Down })` on the panel, follow the finger and call the dismiss callback past a distance or velocity threshold, and handle the back key. When the source really cannot be dragged closed (`sheetGesturesEnabled = false`, or `confirmValueChange` refuses hiding), write `// SHEET-NO-DRAG: <source evidence>` above the Stack to close this rule.",
26
+ escape: "// SHEET-NO-DRAG:",
27
+ cases: [
28
+ "Measured (CoolMall goods detail, ds-1123): the spec-selection sheet and the coupon sheet both port the ModalBottomSheet in BottomModal.kt. The converter judged that the bindSheet dragBar would draw a second handle beside the 40×4dp one, re-classified the sheet as (a) self-drawn under the part-ownership rule and drew a Stack; tapping the scrim closes it, dragging the panel down does nothing. Build, GATE, smoke and review all passed.",
29
+ ],
30
+ },
31
+ ];
32
+
33
+ /** Android files that show a Material bottom sheet (cached per dir by androidStemsWhere). */
34
+ function sheetStems(dir: string): Set<string> {
35
+ return androidStemsWhere(dir, 'modal-bottom-sheet', 'Sheet',
36
+ (src) => /\bModalBottomSheet\s*\(|\bBottomSheetDialog(?:Fragment)?\b|\bBottomSheetScaffold\s*\(/.test(src));
37
+ }
38
+
39
+ /** Gestures that give a self-drawn panel a drag-to-close. */
40
+ const DRAG: RegExp = /\bPanGesture\s*\(|\bSwipeGesture\s*\(/;
41
+
42
+ /**
43
+ * Whether this sheet's own code adds a drag: the Stack block itself, or the body of a @Builder it calls (`this.Panel()`,
44
+ * the usual home of the panel). A PanGesture or bindSheet elsewhere in the file belongs to another overlay and says
45
+ * nothing about this one.
46
+ */
47
+ function sheetHasDrag(code: string, masked: string, open: number, close: number): boolean {
48
+ const block: string = masked.slice(open, close);
49
+ if (DRAG.test(block)) { return true; }
50
+ for (const c of block.matchAll(/\bthis\.([A-Za-z_$][\w$]*)\s*\(/g)) {
51
+ const decl: RegExpExecArray | null =
52
+ new RegExp('@Builder\\s+(?:(?:private|public|protected)\\s+)*' + c[1].replace(/\$/g, '\\$') + '\\s*\\(').exec(masked);
53
+ if (decl === null) { continue; }
54
+ const paren: number = decl.index + decl[0].length - 1;
55
+ const pclose: number = matchBracket(masked, paren);
56
+ if (pclose < 0) { continue; }
57
+ const bo: number = masked.indexOf('{', pclose);
58
+ const bc: number = bo < 0 ? -1 : matchBracket(masked, bo);
59
+ if (bc > bo && DRAG.test(code.slice(bo, bc))) { return true; }
60
+ }
61
+ return false;
62
+ }
63
+
64
+ export function checkSelfDrawnSheet(scans: FileScan[], androidDir: string): void {
65
+ const stems: Set<string> = androidDir !== '' && fs.existsSync(androidDir) ? sheetStems(androidDir) : new Set();
66
+ for (const s of scans) {
67
+ const masked: string = maskedOf(s);
68
+ if (!/\bStack\s*\(\s*\{[^)]*alignContent\s*:\s*Alignment\.Bottom/.test(masked)) { continue; }
69
+ const rawLines: string[] = s.src.split(/\r?\n/);
70
+ for (const m of masked.matchAll(/(?<![\w$.])Stack\s*\(/g)) {
71
+ const paren: number = (m.index ?? 0) + m[0].length - 1;
72
+ const pclose: number = matchBracket(masked, paren);
73
+ if (pclose < 0) { continue; }
74
+ if (!/alignContent\s*:\s*Alignment\.Bottom(?:Start|End)?\b/.test(s.code.slice(paren + 1, pclose))) { continue; }
75
+ let k: number = pclose + 1;
76
+ while (k < masked.length && /\s/.test(masked[k])) { k++; }
77
+ if (masked[k] !== '{') { continue; }
78
+ const close: number = matchBracket(masked, k);
79
+ if (close < 0) { continue; }
80
+ const kids = directUiChildren(s.code, k, close, undefined, { intoBranches: true });
81
+ // the scrim: fills the Stack on both axes and closes the sheet on tap
82
+ const scrim = kids.find((c) => !c.isBuilderCall && fullOnAxis(c.attrs, 'width') && fullOnAxis(c.attrs, 'height') &&
83
+ hasAttr(c.attrs, 'onClick'));
84
+ // the panel: another child (a builder call or component) besides the scrim
85
+ if (scrim === undefined || kids.filter((c) => c !== scrim).length === 0) { continue; }
86
+ const line: number = lineOfIndex(s.code, m.index ?? 0);
87
+ if (markedAbove(rawLines, line, 'SHEET-NO-DRAG')) { continue; }
88
+ if (sheetHasDrag(s.code, masked, k, close)) { continue; }
89
+ // a Stack that itself hosts or opens a managed sheet (bindSheet on its chain, or in its block) is not a self-drawn one
90
+ if (/\.bindSheet\s*\(|\bopenBindSheet\s*\(/.test(masked.slice(k, close)) ||
91
+ attrsWithArgs(s.code, paren).some((a) => a.name === 'bindSheet' || a.name === 'bindContentCover')) { continue; }
92
+ const stem: string | null = stems.size > 0 ? portedAndroidStem(s.abs, s.src, stems) : null;
93
+ report(stem !== null ? 'GATE' : 'CAND', 'self-drawn-sheet-no-drag-dismiss', s.rel, line,
94
+ 'self-drawn bottom sheet: this Stack(alignContent: Bottom) holds a full-screen scrim that closes on tap ' +
95
+ `(line ${lineOfIndex(s.code, scrim.at)}) and a panel, and neither the Stack nor the @Builder it calls adds a ` +
96
+ 'drag (no PanGesture / SwipeGesture). ' +
97
+ (stem !== null
98
+ ? `${stem}.kt shows a Material bottom sheet, which closes when dragged down; this one cannot be dragged. `
99
+ : 'If the Android source is a Material bottom sheet, it closes when dragged down and this one cannot. ') +
100
+ "Use bindSheet / openBindSheet with dragBar: false and draw the Android drag handle in the builder, or add a " +
101
+ "PanGesture(Down) on the panel that calls the dismiss callback; write // SHEET-NO-DRAG: <source evidence> when " +
102
+ 'the source disables the drag');
103
+ }
104
+ }
105
+ }