# HMOS Precheck Architecture

## Directory ownership

- `index.mjs`: executable entry only.
- `invocation.mjs`: CLI lifecycle, configuration, doctor and command routing.
- `backends/`: the local ArkTS checker, ArkTS changed-line scope seam, CodeLinter
  adapter, local ArkTS project rules, and static result orchestration. The
  former upstream checker is an external parity reference only and is not a
  production dependency.
- `core/`: shared execution mechanics: process execution, SDK/project context,
  scope planning, diagnostic scope and agent-facing result projection.
- `rules/`: semantic rule governance: stable rule IDs, aliases, grouping,
  enabled/shadow/disabled modes, confidence and fix policy. It does not launch
  SDK tools or orchestrate checks.
- `runtime-risk/`: independent ArkUI V1/V2 AST risk analyzer. It is not loaded
  by the default static precheck and is excluded from the published package.
- `tests/`: nine responsibility-grouped suites covering core foundation,
  project analysis, output contracts, rule contracts, rule accuracy, backend
  adapters, precheck orchestration, runtime-risk and performance.
- Process task records are not part of this deliverable. Durable runtime-risk
  design and promotion constraints live in `runtime-risk/DESIGN.md`.

## Dependency direction

`index -> invocation -> backends -> core/rules`. Backends acquire diagnostics
and orchestrate execution; core supplies reusable mechanics; rules normalize
the resulting diagnostics and decide their policy. Core and rules do not
import backends, and rules do not import core. Runtime-risk owns its facts and
rules and has no dependency from the default entry path.

## Evidence policy

Backend or capability absence is `not_checked`/unavailable, never success.
Malformed structured reports fail closed. Heuristic project and ArkUI rules
remain shadow until an independent oracle supports promotion. Source mutation
is not implemented and the CLI rejects `--fix`.
