nemo_gym.token_id_capture.store
nemo_gym.token_id_capture.store
Store training TokenEntry records by rollout.
Each rollout uses one <rollout_id>.tokens.jsonl file.
Evaluation records use a separate file.
Every entry line is fsynced before put returns — that is the durability
guarantee. The state index is written atomically but fsynced only on lifecycle
transitions (freeze, mark, drop); it is reconstructible from the JSONL tail.
A per-rollout file lock serializes writers to the same rollout.
Different rollouts can write concurrently.
Module Contents
Classes
Functions
Data
API
Durable, rollout-keyed JSONL sink for TokenEntry records.
Durably record that a captured call is about to be dispatched.
A lost entry leaves a dangling intent.
freeze_now then masks the rollout.
A failure here happens before generation.
Reconcile an entry index with any durable JSONL tail.
The JSONL write is durable before its state update. A process can therefore stop with one unindexed entry. Normal writes use the state index without parsing prior token arrays. Recovery parses only the unindexed tail.
Idempotently append one entry and fsync.
The file store owns no persistent handles.
Unconditionally remove a rollout’s records.
This compatibility helper supports administrative cleanup.
Normal consumers use conditional drop.
The lock file remains so concurrent callers keep using one inode.
Delete snapshot payloads while retaining its tombstone and lock.
Synchronously freeze one rollout and return its stable snapshot.
Sentinel marking that at least one call of this rollout failed to capture.
Return the durable per-call intent path.
Durably record that a call was lost.
Store an entry durably without blocking the event loop.
Await the append so later consumers cannot race a partial file.
Remove retired tombstones older than the cutoff and return the count removed.
Callers choose the retention policy.
drop already removed entries and JSONL payloads.
This removes state, locks, intents, and incomplete markers.
Build the training-token file store.
Return None when capture is disabled.
Return None when no directory resolves.
Return None when a custom sink owns the records.
Reject anything that could escape the store directory or index a bad file.