Skip to main content

Module ctx_read

Module ctx_read 

Source

Structs§

DeltaExplicitDecision
Outcome of resolve_explicit_delta_mode: the (possibly rewritten) read mode plus an optional advisory note to surface to the agent.
ReadOutput
Pre-counted read output carrying the output string, resolved mode, and token count computed during mode processing.

Functions§

handle
Reads a file through the cache and applies the requested compression mode.
handle_fresh
Like handle, but invalidates the cache first to force a fresh disk read.
handle_fresh_with_task
Fresh read with task-aware filtering (invalidates cache first).
handle_fresh_with_task_resolved
Fresh read with task-aware filtering, also returns the resolved mode name and pre-counted tokens.
handle_fresh_with_task_resolved_tuned
Fresh-read variant of handle_with_task_resolved_tuned (#714).
handle_with_task
Reads a file with task-aware filtering to prioritize task-relevant content.
handle_with_task_resolved
Like handle_with_task, also returns the resolved mode name and pre-counted tokens.
handle_with_task_resolved_tuned
Like handle_with_task_resolved but with an explicit per-call aggressiveness (the ctx_read aggressiveness arg, #714). None falls back to the LEAN_CTX_AGGRESSIVENESS env var / config field.
is_instruction_file
read_file_lossy
Reads a file as UTF-8 with lossy fallback, enforcing binary detection and max read size limit. Defense-in-depth: verifies that the canonical path stays within the process’s project root (if determinable) even though callers SHOULD have already jail-checked the path.
resolve_explicit_delta_mode
Decide whether an explicit full/lines:N-M re-read of a session-cached file should be served as a delta instead of re-emitting content the model already holds (the delta_explicit opt-in; env LCTX_DELTA_EXPLICIT).
try_stub_hit_readonly
Attempt to serve a mode="full" cache hit ([unchanged …]) using only a shared borrow of the cache.