Remote / Declared writes
Asking before sending: Data.can
Data.can evaluates held may flags, when preconditions, and invariants in memory—matching the server's check order—to guide button states:
ts
import { Can } from 'foldkit-remote'
const answer = Data.can(model, Publish, { id: 'p1', status: 'published' })
const label = Can.match(answer, {
Yes: () => 'Publish',
No: ({ refusal }) => `Cannot publish: ${refusal._tag}`,
Undecided: ({ reasons }) => `Publish (unchecked: ${reasons.join('; ')})`,
})Can.Yes: Held data passes all checks.Can.No({ refusal }): Returns the exactForbidden,Unmet, orInvalidrefusal shape the server returns.Can.Undecided({ reasons }): Returned when rows, fields, operators, input keys, ormayflags are missing locally.
Data.can is strictly an advisory UI hint (Data.mutate still sends Unmet writes in case local data is stale) and throws on non-declared mutations.