Skip to main content

Module refinement

Module refinement 

Source
Expand description

Rotation / batch-order scheduling — the deterministic substrate the verify sampler (E3b) reuses. The refinement-as-writer brief (the scout/writer two-phase flow and its temp findings file) is deleted (D1/D9/AC10): refinement mode is gone from the vocabulary and no renderer remains. What survives, unrendered, is the rotation machinery — a batch_size-at-a-time walk over a source facet’s files in a reproducibly-shuffled order that resets each rotation.

One rotation of next_batch walks the source files in batch_size batches, covering the whole set once before reshuffling for the next rotation. Deterministic state (rotation, cursor, shuffled file order) lives engine-side under <workspace>/.memstead.cache/ingest/refinement/ — the same engine-internal cache the mtime memo and backoff use.

Port note. The original plugin shuffled the file order with Math.random; this uses a small rotation-seeded PRNG so the order still varies across rotations but is reproducible (no rand dependency). The behaviour preserved is “each rotation covers the whole source set in a different batch order”; the exact permutation is not load-bearing.

Structs§

Batch
One batch: the files to review plus its position in the rotation.

Constants§

ROTATION_ANCHOR_ADJUDICATION
The rotation key the verify anchor-adjudication sampler walks under (D2) — a distinct cursor from ROTATION_UNCOVERED_FILES, so the cap-sized adjudication window rotates over the anchor set independently of the uncovered-file sample.
ROTATION_UNCOVERED_FILES
The rotation key the verify uncovered-artifact sampler walks under. Named so independent verify samples (uncovered files, anchor spot-checks) each get their own rotation cursor within one binding’s state without interfering.

Functions§

bump_verify_runs
Increment and return the persisted verify-run counter for a binding — the level-trigger clock the full_resync_every schedule reads (D3). Independent of the rotation cursors: it ticks every verify run, including a run whose source enumerates to nothing (a non-enumerable medium), so the schedule can refuse on time rather than silently never firing. Returns the new (post-increment, 1-based) run count.
next_batch
Advance the uncovered-artifact file sample (D2) — the retained rotation over a source facet’s enumerated files, one batch_size window at a time. A thin wrapper over next_rotation_batch keyed ROTATION_UNCOVERED_FILES. None when the binding has no source files (e.g. a non-enumerable medium).
next_rotation_batch
Advance one named rotation over an arbitrary item set — the generalized rotation core the verify samplers (D2) repurpose. items is the full set to cover (sorted + de-duplicated by the caller for determinism); rotation_key namespaces this rotation within the binding’s state file so independent samples rotate on their own cursor. One rotation walks the whole set once in a reproducibly-shuffled order before reshuffling for the next; same persisted state → same sequence. None when items is empty.