Expand description
Stage 7 — placement: inferred from effects, solved against a cost model, verified.
docs/03-type-and-effect-system.md §3.3:
“Placement is not a primitive annotation; it is a constraint solution — with explicit
@on(...) always available and always winning. Purity means unplaced: legal on every tier,
compiled to each tier that needs it.”
Phase 1 shipped the verification half. Phase 2 adds the other two thirds of §3.3 and all of
§3.4: candidates come from the inferred effect row, the choice among them comes from a cost
model (crate::cost), and every guardrail §3.4 calls non-negotiable is here —
- determinism — integer costs, a fixed enumeration order and a total tie-break, so the same program always yields the same solution;
- stability — the previous solution is persisted in
beck.lockand preferred on a tie, and churn against it is reported rather than absorbed; - explainability — every candidate’s cost survives the solve, so
beck explain placecan print the derivation rather than the conclusion; - assertability —
beck check --assert-place page=clientfails the build on a change.
§What is actually being decided
Less than it first appears, and that is the design working rather than the solver shirking. Three rules pin most of a program before the solver runs, and each is a statement about meaning rather than about cost:
@on(...)wins (§3.3).- A pure definition is unplaced —
Tier::Any— and is compiled into every tier that calls it. “That duplication is the payoff, not waste.” - A
Signal[Html]is the browser’s subscription (§4.3), so it is pinned to the client. Where the view function runs — Mode A server-side rendering versus Mode B in the browser — is the05§5.1 decision that §3.4 also mentions, and it is Phase 3’s: Mode B does not exist, so the cost model has nothing to choose between and should not pretend otherwise.
What is left is genuinely open, and the corpus exercises it: which tier holds a durable fold,
where decide sits, and where an effectful definition that more than one tier could discharge
ends up — net.out(origin) being the sharp case, since a browser and a server can both make
that call and only the callers decide which is cheaper.
Structs§
- Explanation
- Why a node’s placement is what it is — the content of
beck explain place. - Lock
- The persisted previous solution — §3.4’s stability guardrail.
- Solution
- The solved placement of a whole program.
Enums§
Functions§
- apply
- Write the solved tiers back into the program.
- check_
placement - Verify every placement in a checked program, annotated or solved.
- mentions
- Every top-level name an expression mentions — the placement graph’s edges.
- solve
- Solve the placement of every definition and signal in a checked program.