Skip to main content

Module selection

Module selection 

Source
Expand description

Ingest selection + backoff — pick the next due (binding, operation) pair in a --all rotation, skipping pairs whose destination is unchanged and whose sources have not moved. Engine-side generalization of the plugin’s nextIngest / shouldSkip / backoff state from “next due binding (build)” to a per-operation rotation.

Eligibility (per pair): an operation participates in the rotation only when its operations.<op> block exists in the binding and declares trigger: loop — consent to unattended rotation lives in the declaration. A one-shot build that already ran stays excluded.

Due-checks (cheap, per pair, before backoff): build is always due (unchanged semantics — backoff alone decides); sync is due when a source moved past its #synced baseline or open findings exist under the binding’s current (hash(D), source_head) key; verify is due when a source moved past its #verified baseline (a never-verified source with a live token counts as moved — the first verify is due). A pair that is not due is passed over without touching its backoff state.

The deterministic state (round-robin cursor, per-pair backoff, one-shot ran-set) lives engine-side under <workspace>/.memstead.cache/ingest/ — the same engine-internal bookkeeping location the mtime memo uses. This is not mem-repo / graph state; selection mutates it as its job. Cursor and backoff entries are keyed by the pair id <binding>#<op>; pre-pair single-key entries (plain binding ids) are discarded — the cache is disposable, and the cost is at most one lost backoff step per binding.

Backoff shape (mirrors the plugin exactly): a linear-ramp per-pair skip counter. A destination-snapshot change or a moved source resets it to zero and runs; otherwise each unproductive pass grows the cooldown by one (capped at MAX_SKIP_LEVEL). A one-shot build never skips. For sync / verify pairs the moved-source override is not applied: the due-check already encodes source movement, and a productive run mutates the destination mem, which resets the pair’s backoff by itself — so an un-acted-on brief ramps instead of being re-rendered every pass.

Structs§

BackoffEntry
Per-ingest destination-snapshot backoff state.
Cursor
The round-robin cursor — the (binding, operation) pair the last rotation advanced to, stored as the pair id <binding>#<op>. A pre-pair value (a plain binding id) never matches a pair id, so the first op-aware pass simply restarts the rotation from the top — the cache is disposable.

Enums§

OperationFilter
Which operations a --all rotation considers. Only(op) restricts the eligible set to that operation’s pairs (the CLI default is Only(Build) — byte-stable for the ingest router); Self::Any rotates across every eligible pair.
OperationKind
One operation of a binding — the second half of a --all rotation pair.

Constants§

MAX_SKIP_LEVEL
The backoff cooldown ceiling — after this many consecutive unproductive passes the skip count stops growing. Mirrors the plugin’s MAX_SKIP_LEVEL.

Functions§

apply_backoff
Apply the destination-snapshot backoff to entry, mutating it, and return whether to skip this pass. current is the destination mem’s current snapshot token (empty when none). Mirrors the backoff block of the plugin’s shouldSkip:
select_next_due
Select the next due ingest (build operation) for a --all rotation — the build-only compatibility form of select_next_due_operation. Returns the selected binding id, or None when nothing is due this pass.
select_next_due_operation
Select the next due (binding, operation) pair for a --all rotation, advancing the round-robin cursor and the per-pair backoff state. Returns the selected binding id and operation, or None when nothing eligible is due (or everything due is backing off) this pass.
should_skip
Whether a binding should be skipped this rotation. A one-shot build never skips (one-shots are excluded from the eligible set once run). Discovery: a moved source overrides backoff; otherwise the destination-snapshot apply_backoff.