Expand description
fdu — a fast, incremental file roll-up engine.
fdu answers, for any directory in a tree: how big is it, how many files does it hold, what changed most recently, and what kinds of files live in it — hierarchically, for every directory at once, from a single walk.
§The shape: three artifacts, one contract
- The index (
Index) — the in-memory hierarchical structure: entry records plus per-directory roll-up state. - The snapshot (
snapshot) — that index, serialized. - The change contract (
ObservationandCommit) — producers submit verified observations; the index commits clocked effective changes.
Everything else is a producer of observations or a consumer of exact commits. The
walker establishes a baseline from upsert observations; the reconciler submits the
conditional diff between indexed state and reality; the watch layer submits verified,
coalesced observations. The index arbitrates them and re-rolls its reducers; a change
feed consumes exact effective changes and state transitions from Commit.
A deliberate consequence: watching is not tied to the roll-up logic. The index
knows apply(Observation) and nothing about filesystem events, so a batch scan, a test
feeding synthetic observations, and a live watcher are indistinguishable to it.
§Freshness is a ladder, not a set of alternatives
open is the conservative, blocking entry point: it loads a compatible snapshot,
reconciles the configured filesystem scope, and only then returns. It does not serve
the loaded baseline concurrently. Applications that want that model can own an
IndexHandle, call the applying reconciliation APIs, and inspect Freshness
while readers continue between short write batches. With the watch feature,
watch::Watcher::apply_next verifies event hints and closes invalidations through
subtree reconciliation; neither open nor the Python binding starts it implicitly.
OpenedIndex is the additive long-lived owner: its clones share one live identity,
cancellation domain, index, and joined shutdown. A cloned Index remains a
detached image and never inherits that authority.
use fdu_core::{CachePolicy, open};
use fdu_core::query::{Basis, Delivery, Scope};
use std::path::Path;
let basis = Basis { root: Path::new(".").into(), scope: Scope::default(), content: Default::default() };
let (index, report) = open(&basis, &Delivery::new(CachePolicy::Auto, None))?;
let total = index.total();
println!("{} files, {} bytes ({:?})", total.files, total.bytes, report.path_taken);§Build features
watch— the OS-native watch layer.
fdu-core has no default build features. The command and Python packages opt into
watch, while embedding consumers can retain the smaller one-shot engine.
.gitignore handling is not a build feature: it has no dependency, so it is always
compiled in, and whether a scan reads control files is decided at runtime by
ScanConfig::read_controls.
Re-exports§
pub use crate::watch_session as session;pub use crate::admission::HiddenPolicy;pub use crate::cache::CachePaths;pub use crate::cache::CacheScope;pub use crate::cache::CacheState;pub use crate::cache::CacheStatus;pub use crate::cache::ClearSummary;pub use crate::cache::ContentInfo;pub use crate::cache::ContentState;pub use crate::cache::ContentStatus;pub use crate::cache::LeftoverKind;pub use crate::cache::SnapshotInfo;pub use crate::cache::StaleReason;pub use crate::cache::cache_status;pub use crate::cache::clear_all_caches;pub use crate::cache::clear_cache;pub use crate::cache::list_caches;pub use crate::control::CONTROL_FILE_NAME;pub use crate::control::ControlAdmission;pub use crate::control::ControlCoverage;pub use crate::control::ControlIdentity;pub use crate::control::ControlLimits;pub use crate::control::ControlMatcher;pub use crate::control::ControlObservation;pub use crate::control::ControlRefusalReason;pub use crate::control::ControlTable;pub use crate::control::DEFAULT_CONTROL_BUDGET;pub use crate::control::DEFAULT_CONTROL_LINE_LIMIT;pub use crate::control::RefusedControl;pub use crate::control::is_control_file;pub use crate::scan::ReconcileReport;pub use crate::scan::ScanConfig;pub use crate::scan::ScanOrder;pub use crate::scan::ScanReport;pub use crate::watch_session::Batch;pub use crate::watch_session::Change;pub use crate::watch_session::ChangeKind;pub use crate::watch_session::SaveOutcome;pub use crate::watch_session::Session;
Modules§
- admission
- Fixed rules that decide which filesystem facts belong in an index.
- cache
- Inspecting and clearing the snapshot cache.
- classify
- File-type recognition.
- content
- Optional, versioned file-content analysis.
- control
- Bounded, removal-aware control state used to classify retained filesystem facts.
- counters
- Low-distortion performance instrumentation for fdu.
- query
- Queries over a built index: what to select, which roll-ups to report, and the value grammars both are written in.
- report_
format - Serializing a
Reportto text, JSON, JSONL, and YAML. - scan
- The scan layer: walking a tree, producing observations, and applying reconciliation.
- snapshot
- Persisting an index to disk and reading it back.
- watch
- Th OS-native watch layer: turning an unreliable event stream into verified observations.
- watch_
session - A live session: an index, a watcher, and the query they answer together.
Structs§
- Analyzer
Provenance - The analyzers a content tier’s records were produced by, and the options they ran with.
- Apply
Outcome - Result of arbitrating and applying one producer observation.
- Apply
Stats - Summary of what one
Index::applycall did. - Attrs
- The stat fields an entry contributes to roll-ups, plus the ones that identify it.
- Change
Poll - Result of one opened-root journal poll.
- Change
Request - Input to one blocking opened-root journal poll.
- Child
Snapshot - One direct child captured from a shared index at a single read boundary.
- Clock
- A monotonic logical clock, in the spirit of Watchman’s clockspec but process-local.
- Commit
- One atomic, exact index transition.
- Content
Admission - Proof that stored content can be projected to one requested identity.
- Content
Tier Identity - Identity of a content tier: the per-file analysis records a sidecar holds.
- Continuation
Id - Opaque identifier for resumable work retained by one opened root.
- Discovery
Budget - Resource bounds applied to progressive discovery.
- Discovery
Progress - Committed, bounded discovery counters.
- Engine
Version - Identity and exact sequence of one committed opened-root state.
- EntryId
- Identifier for an entry within an
Indexarena. - Entry
Scope - Which entries a scan retains: its depth, symlink, filesystem-boundary, hidden-entry, and special-object settings.
- Entry
Tier Identity - Identity of an entry tier: the entries a store holds and the roll-ups derived from them.
- Entry
Value - One immutable retained entry returned by an opened-root read.
- ExtTally
- Per-extension tally within a roll-up.
- Fingerprint
- The fingerprint used to decide whether an entry really changed.
- Flat
Page - One portable flat-entry page.
- Impact
- Bounded invalidation guidance derived from exact effective changes.
- Index
- The in-memory hierarchical index.
- Index
Handle - Shareable owner for serving readers while reconciliation applies short writes.
- Index
State - Coherent public state captured at an index commit boundary.
- Issue
- Bounded diagnostic evidence retained with an index state.
- Issue
Summary - Counts for the bounded issue details captured with a state.
- Observation
- A producer batch awaiting arbitration by the index.
- Observation
Op - One observed operation together with its arbitration precondition.
- Open
Options - Configuration for a long-lived
OpenedIndex. - Open
Report - What
opendid. - Opened
Index - A long-lived, synchronously controlled filesystem index.
- Page
Request - Output and work bounds for one resumable page.
- Partition
Roll Up - The two fixed aggregate partitions maintained for inventory reads.
- Partition
Roll UpSummary - Constant-size totals for the fixed all and unignored partitions.
- Path
Expectation - State and entry revisions captured at one observation boundary.
- Pending
Save - A snapshot write running alongside rendering.
- Performance
Summary - Operational work behind one one-shot report.
- Plan
- Validated policy shared by all engine execution routes.
- Portable
Path - A retained entry’s canonical POSIX-relative name, in the form ordered pages use.
- Progress
- A handle a route reports its progress through.
- Progress
Snapshot - What a route has done so far, as read at one moment.
- Provenance
- Everything a consumer needs to decide how far to trust one value.
- Query
Limit - Typed bounded-query result; no partial calculation is presented as exact.
- Read
Diagnostics - Fixed-size diagnostics captured with a coherent read.
- Read
Request - Input to one coherent opened-root read.
- Read
Response - One coherent opened-root response.
- Refresh
Result - Result of one bounded, multi-path refresh.
- Rejected
Refresh Path - One refresh path that the engine declined, with its typed reason.
- Report
Request - The read half of a request at an opened root, plus one read’s work bound.
- RollUp
- Pre-computed aggregate state for one directory’s entire subtree.
- Roll
UpSummary - Constant-size directory totals suitable for bounded interactive rows.
- Scan
Scope - Semantic inputs that decide which entries and derived values belong in an index.
- Semantic
Identity - Answer-semantics identity derived from validated classification and reducer rules.
- Session
Id - Opaque identity of one opened-root lifetime.
- Since
- Result of
Index::since. - Snapshot
Identity - The identity of every tier a metadata snapshot holds.
- Tree
Page - One structural page of a directory’s descendants, to the requested depth.
- Work
- Bounded work performed while committing producer input or serving engine reads.
Enums§
- Cache
Policy - Whether a request may read and write the snapshot cache.
- Change
Outcome - Journal outcome at one coherent terminal version and state.
- Control
Tier Identity - Identity of a
.gitignorecontrol tier. - Count
Result - Product count whose exactness is explicit.
- Coverage
- Structural coverage of one opened root.
- Coverage
Reason - Why an opened root cannot claim complete structural coverage.
- Effective
Change - One exact fact mutation performed by the index.
- Entry
Kind - What kind of filesystem entry a record describes.
- Error
- Errors the engine can report.
- Expectation
- The condition under which an observation may be committed.
- Freshness
- Trust state for an index or queried subtree.
- Impact
Domain - A stable fdu-native answer domain that one commit may have made stale.
- Invalidate
Reason - Why a producer had to escalate to
Op::InvalidateSubtreeinstead of describing a change precisely. - Issue
Kind - Stable category for one non-fatal condition or terminal provider failure.
- Knowledge
- Three-valued knowledge for a path lookup.
- Lifecycle
Phase - Current activity of one opened root.
- Limited
Projection - Projection whose deterministic work allowance was exhausted.
- Load
- Which persisted state execution may read.
- Op
- A single change to one path.
- Open
Path - Which tier of the freshness ladder an
openactually used. - Outcome
Class - Whether an answer fulfills the caller’s delivery contract.
- Path
State - The complete indexed state of one path at an observation boundary.
- Progress
Phase - Which kind of work a route is doing.
- Projection
Refusal - Why one projection of a read refused, while every other projection still answered.
- Projection
Result - One projection result, in the same position as its request.
- Read
Projection - One fdu-native projection requested under a coherent read boundary.
- Refresh
Rejection - Why one requested refresh path was not verified.
- Route
- The engine lifecycle that will deliver an answer.
- RowShape
- Retained fields copied into portable page rows.
- Serves
- How a stored tier answers a request.
- Source
- Where a value came from, so a consumer can trade speed for certainty knowingly.
- State
Transition - One observable transition that did not change a retained filesystem entry.
- Status
- Whether a value covers everything beneath its path.
- Verify
- Whether execution must verify the filesystem.
Constants§
- DEFAULT_
COUNT_ CAP - Default cap for a selection count not backed by an exact maintained aggregate.
- DEFAULT_
JOURNAL_ CAPACITY_ BYTES - Approximate bytes the exact commit history used by
Index::sincemay retain. - MAX_
CONTINUATION_ RECORD_ BYTES - Maximum retained payload for one handle-local continuation record.
- MAX_
COUNT_ CAP - Maximum caller-selected cap for an on-demand aggregate.
- MAX_
DIRTY_ PATHS - Maximum number of individual dirty paths retained in one commit.
- MAX_
ISSUE_ MESSAGE_ BYTES - Maximum UTF-8 bytes retained in one rendered issue message.
- MAX_
ISSUE_ PATH_ BYTES - Maximum native encoded bytes retained for one issue path.
- MAX_
PAGE_ ROWS - Maximum rows returned by one page projection.
- MAX_
PAGE_ WORK - Maximum deterministic work allowance accepted by one page projection.
- MAX_
PRIORITY_ PATHS - Maximum paths accepted by one best-effort priority request.
- MAX_
READ_ PROJECTIONS - Maximum native projections accepted by one coherent read.
- MAX_
REFRESH_ PATHS - Maximum paths accepted by one refresh operation.
- MAX_
REPORT_ VIEWS - Maximum report sections and reported omissions accepted in one opened read.
- MAX_
RETAINED_ ISSUES - Maximum issue details retained by one index image.
- MIN_
JOURNAL_ CAPACITY_ BYTES - Smallest journal budget, in bytes, an opened root accepts.
Functions§
- default_
cache_ dir - The application cache directory, resolved independently of a scanned root.
- default_
cache_ path - Conventional metadata snapshot path for callers without an explicit destination.
- default_
cache_ path_ in - The conventional metadata snapshot location for a root in the resolved directory.
- open
- Open a tree, using the snapshot cache when one is usable.
- open_
with_ pending_ save - Open a tree, returning the snapshot write for the caller to join.
- plan
- Validate a request and derive the least-retention plan for its delivery and route.
- prepare_
report - Execute a one-shot report, retaining the least state the request needs.
- prepare_
report_ with_ progress - Execute a one-shot report, reporting its progress through
progressas it runs. - prepare_
report_ with_ scan_ diagnostics - Execute a one-shot report and retain scan diagnostics.
- refresh
- Reverify a retained index, refresh requested content, and persist according to delivery.
- serves_
snapshot - Whether a snapshot of the
storedidentity answers a request forwanted. - throughput_
rates - Cumulative walk rates over one actual elapsed sample. The byte rate is binary GiB/s,
rounded to three decimals; the grouped file rate counts complete files per second.
Returns
(files_per_second, gib_per_second)without unit labels, orNonewhen elapsed time is zero. Neither rate estimates storage read bandwidth.
Type Aliases§
- Result
- Result alias for engine operations.