cadrumo.application.flows.checkpoint module

The per-mode checkpoint port.

The substrate defines the port; the domain flow supplies the implementation, and every implementation routes through the owning domain’s existing encrypted persistence authority — never a bespoke store, never flow-owned crypto. The facts are the checkpoint: the port persists the canonical answer map only, and resume rebuilds everything derived (cursor, staleness, validation) from the current definition (resume).

Availability is a per-mode declaration on the FlowDefinition (checkpoint field). UNAVAILABLE is the declared no-op arm: save_checkpoint() refuses rather than silently dropping, and frontends read checkpoint_available() to disable the save-and-exit affordance with an explicit message — an interrupted run in a no-op mode discards staged answers loudly, never silently.

class CheckpointStore(*args, **kwargs)[source]

Bases: Protocol

Domain-supplied persistence port for in-progress flow answers.

Implementations MUST write through the owning domain’s mutation authority (for the profile domain: effective-dated fact writes via the profile lifecycle service) and MUST NOT persist plaintext anywhere. load returns the persisted canonical answer map or None when no in-progress run exists; discard erases through the same authority.

save(_flow_id, answers, /)[source]

Persist the canonical answer map for flow_id.

Return type:

None

Parameters:
load(_flow_id, /)[source]

Return the persisted answer map, or None when absent.

Return type:

Mapping[str, str] | None

Parameters:

_flow_id (str)

discard(_flow_id, /)[source]

Erase the persisted in-progress run.

Return type:

None

Parameters:

_flow_id (str)

checkpoint_available(definition, mode)[source]

Whether the definition declares checkpointing for mode.

Return type:

bool

Parameters:
save_checkpoint(definition, state, store)[source]

Persist the state’s committed answers through the domain store.

Refuses in a mode whose declaration is the no-op arm — the frontend should never have offered the affordance; reaching this refusal means a frontend honesty bug, and the refusal (counts only, never answer values) makes it loud.

Return type:

None

Parameters:
discard_checkpoint(definition, store)[source]

Erase the in-progress run through the domain store.

Return type:

None

Parameters: