pub struct CodexAnchorScanner { /* private fields */ }Expand description
What a client has already taken from each rollout it watches.
This is the shared half of the anchor lane’s state: which anchors are still
owed, and whether a rollout is worth re-reading. Both answers are
statements about Codex’s file format — rollouts are append-only, so a stable
size+mtime fingerprint means no new anchors, and each anchor’s identity is
its SubAgentAnchor::dedup_key — and a client that re-derived them would
be re-deriving how much of a session’s causal skeleton gets uploaded.
Everything around it stays with the client: the tick, the HTTP call, the credential, the failure backoff, and the scope rule that decides which rollouts are handed here at all.
A scanner is only ever as large as the live rollout set — call
Self::retain_live each tick with the current snapshot.
Implementations§
Source§impl CodexAnchorScanner
impl CodexAnchorScanner
Sourcepub fn retain_live<'a, I>(&mut self, live: I)where
I: IntoIterator<Item = &'a Path>,
pub fn retain_live<'a, I>(&mut self, live: I)where
I: IntoIterator<Item = &'a Path>,
Drop bookkeeping for every rollout not in live.
Codex’s rollout directory is retention-bounded and a watcher snapshot only reports recent files, so without this the map grows for the life of a long-running client.
Sourcepub fn needs_read(
&self,
rollout: &Path,
fingerprint: Option<FileFingerprint>,
) -> bool
pub fn needs_read( &self, rollout: &Path, fingerprint: Option<FileFingerprint>, ) -> bool
Whether rollout is worth reading, given its current fingerprint.
false when the file could not be fingerprinted (vanished, or stat
failed — skip this tick) or when it has not moved since the last clean
scan. Rollouts are append-only, so an unchanged fingerprint cannot hide
a new anchor.
Sourcepub fn undelivered(&self, rollout: &Path, raw: &[u8]) -> Vec<SubAgentAnchor>
pub fn undelivered(&self, rollout: &Path, raw: &[u8]) -> Vec<SubAgentAnchor>
The anchors in raw that have not been reported delivered for
rollout, in file order.
Sourcepub fn record_delivered(&mut self, rollout: &Path, anchor: &SubAgentAnchor)
pub fn record_delivered(&mut self, rollout: &Path, anchor: &SubAgentAnchor)
Record that the server accepted anchor’s row (including a dedup — the
bytes are stored either way).
Sourcepub fn record_clean_scan(
&mut self,
rollout: &Path,
fingerprint: Option<FileFingerprint>,
)
pub fn record_clean_scan( &mut self, rollout: &Path, fingerprint: Option<FileFingerprint>, )
Record a scan that left nothing owed, so rollout is not re-read until
it grows.
A client must NOT call this after a partial failure: leaving the fingerprint behind is what makes the next tick re-read and retry.
Sourcepub fn delivered_count(&self, rollout: &Path) -> usize
pub fn delivered_count(&self, rollout: &Path) -> usize
How many anchors have been reported delivered for rollout.