Expand description
Suspend + resume plumbing for the Postgres backend.
Wave 4 Agent D (RFC-v0.7 v0.7 migration-master).
This module is the landing pad for the 4 suspend-family trait
methods (suspend, observe_signals, list_suspended,
claim_resumed_execution). The current tranche ships the
composite-condition evaluator as a pure-Rust helper (evaluate)
and the parititon-slot helper (slot_of); the SQL bodies for
the trait methods land together with the Wave-4 claim/lease
plumbing being built in parallel (Wave 4 Agents A/B/C).
§Composite evaluator placement
Q11 pinned composite-condition evaluation at one of the three SERIALIZABLE sites; we run the evaluator Rust-side inside the SERIALIZABLE transaction (not as a plpgsql stored proc) because:
- The declarative
ResumeCondition+CompositeBodytypes already live inff-core::contracts; replicating the logic in plpgsql would double-maintain a non-trivial tree walker. - SERIALIZABLE already serializes reads + writes on the
satisfied_set/member_mapJSONB columns the evaluator touches, so moving the eval into pg buys no isolation. - Rust-side eval keeps the evaluator unit-testable without a
live Postgres (see
evaluatetests below).
The Valkey backend runs the equivalent logic in Lua; this is the only evaluator divergence and is deliberate per the rationale above.
Functions§
- evaluate
- Evaluate a
ResumeConditionagainst the set of signals delivered so far. Returnstrueiff the condition is satisfied. - slot_of
- Map an
ExecutionIdto its partition slot under the deployment’sPartitionConfig. Thei16return matches the column type on every partitioned table inmigrations/0001_initial.sql. - slot_
of_ partition_ key - Convert a
PartitionKeyto its slot index for schema-partition keying. ReturnsNoneif the key is malformed.
Type Aliases§
- Signals
ByWaitpoint - Map from
waitpoint_key→ list of signals delivered to it. This is the shape [ff_suspension_current.member_map] deserialises into on the Postgres side — signals are keyed by their target waitpoint, so the evaluator can answer “did this waitpoint fire?” without a per-signal wp lookup.