Per-function target assignment and validation catch capability mismatches before any backend emits code.
Target planning receives an already-validated lifetime topology. It assigns targets and checks capabilities. It never changes region ownership or source legality.
Semantically valid Moth can still be unhostable on a chosen target. A function that touches the DOM does not belong in a pure Wasm partition that has no DOM. A backend should learn that before it emits half a module.
Target planning is build-owned and assigns each reachable function to a target. Target validation is compiler-owned and checks that finished assignment against capabilities.
The build system supplies validation roots and the completed per-function target assignment from entry or package link planning. The compiler owns validation semantics over that assignment. It judges the partition rather than choosing it.
Distinguish two ideas people conflate:
PackageOrigin says which kind of package it belongs to and PackageBacking says whether real Moth source or an external binding implements it.Neither one is source-visible target identity. Moth source cannot ask which physical target it is being compiled for.
A function can be perfectly typed and still require a capability its assigned target lacks.
For the greeting walkthrough, the entry, greet and any template runtime work arrive with link facts and capability requirements. Even a humble string page exercises the machinery that larger apps need for the DOM and everything around it.
Some functions are born with affinity. A JavaScript-owned entry that must orchestrate page lifecycle wants the JS side. A DOM-touching helper wants JS. Neutral pure computation may default toward Wasm where the design supports it.
Requirements propagate backwards along call edges. If a callee needs the DOM, callers that must reach it inherit the constraint under the accepted propagation rules. Neutral callees can still sit in Wasm when callers bridge correctly.
A clean mental loop:
Determinism matters. The same program should not flip partitions because a hash map iterated in a different order.
Mixed output needs bridges.
JavaScript-to-Wasm calls may use wrappers under explicit ABI rules.
Wasm-to-JavaScript Moth calls remain prohibited after propagation in the accepted model. The planner should push the JS requirement outward rather than leave a forbidden reverse edge for emission to discover.
That asymmetry is deliberate engineering, not an accident of today's engine.
Partitioning is entry-specific. Different entries may need different physical variants of shared logic when their capability sets differ. Variant keys make those physical artefacts addressable.
The check command plans and validates, then stops before writing a full page output set. Tooling overlays extend analysis. They do not become a second artefact builder competing with HTML output.
Unresolved layout requirements are not on that list. Layout and memory-strategy planning happens per variant after target validation, so those failures belong to the memory planner.
Unsupported features in unreachable private functions should not fail validation.
Alternative: compile a whole page to one target, or let emission discover unsupported calls mid-write.
Choice: per-function deterministic partitioning with explicit validation.
Benefit: mixed output can keep browser work in JavaScript and neutral work in Wasm.
Cost: wrappers, ABI rules and assignment reasons add planning machinery.
html_project_backend_wasm_final_implementation_plan.md.You leave with validated target assignments, capabilities, dependencies and physical variants. Next: how lowerers turn these explicit inputs into JavaScript and Wasm without reopening source.