Expand description
§mant-loader
Read-only local document discovery and bounded acquisition for ManT. The loader
resolves logical document names, explicitly supplied files and typed linked
document scopes into owned mant-ir content. It uses mant-codec for decoding
and mant-sources for installed Markdown registration; it does not execute
semantic queries, render reports or update sources.
§Features
The default feature set supports Markdown and installed tldr caches without
libmandoc or a C compiler. Enable roff to load native manuals, including
bounded gzip/zstd decompression and indexed .so redirects. Manual catalog
discovery itself does not require a parser. A missing native capability is not
permission to invoke a host formatter, download content or run an updater.
§Loading and ownership
DocumentLoader captures the host manual roots and lazily builds registered
Markdown, native-manual and unified-catalog snapshots. Reuse the same loader
when discovery and loading must share precedence; construct another to refresh
local discovery. Snapshot reuse does not freeze external file contents or make
the filesystem transactional.
For an on-demand host, prepare PreparedCatalogQuery before constructing the
loader. It validates filters and compiles the matcher without discovery;
DocumentLoader::discover_prepared then reuses that matcher and the loader’s
snapshot. Applying a prepared query to an already materialized catalog also
performs no IO. Neither preparation nor reuse refreshes the host environment.
LoadSpec borrows an explicit logical selector or input path. It carries no
serialized query schema, search expression, output format or query view.
Loading errors are separate from the application’s view-validation errors.
Only the composition layer accepts a complete request and joins loading with
semantic query execution.
use mant_loader::{DocumentLoader, LoadSpec, LoadPolicy};
use mant_protocol::InputFormat;
let loader = DocumentLoader::from_system();
let content = loader.load(
LoadSpec::File { path: "notes.md", format: InputFormat::Markdown },
LoadPolicy::Combined,
)?;
assert!(content.document.is_some());§Boundaries
- Registered documents and native manuals retain deterministic source priority, exact logical identities and explicit ambiguity. A failed logical selector never becomes a physical path.
- Direct inputs are separately authorized by their caller. Source-byte and decoded-byte limits are enforced while reading, not inferred from file size.
- Linked-document loading is bounded, breadth-first and source ordered. A single admission operation commits content, graph positions, traversal work and byte accounting together; failed candidates do not consume a document slot or leave half a graph node.
- Negative resolution caching is request-local and qualified by policy, source and manual section. A frontier is a coverage boundary, not proof that a document does not exist.
- Tldr cache discovery may inspect executable availability but never starts a program. Cache updates and host process execution belong to the application.
The source, configuration and metadata safety contracts are documented in
the architecture
and sources guide.
ManT-authored code is Apache-2.0; optional native parsing remains in the
separately licensed and attributed libmandoc-rs package.
Structs§
- Available
Document - One document discoverable by name through the ordinary query boundary.
- Document
Loader - One explicit local document-environment snapshot.
- Executable
Lookup - Read-only executable lookup against a caller-owned environment snapshot.
- Loaded
Document Scope - A logical scope together with the loaded documents in matching order.
- Manual
Index - Immutable index shared by discovery and exact manual lookup.
- Manual
Page - One effective local manual page after path and locale precedence.
- Manual
Path Diagnostic - One rejected entry in the host manual-path configuration.
- Manual
Request - One validated manual lookup independent from CLI token syntax.
- Manual
Root Discovery - Effective manual roots plus non-fatal host-configuration findings.
- Prepared
Catalog Query - Validated filters and one compiled matcher, prepared without source discovery.
- Resolved
Content - One materialized document query before any versioned process projection.
Enums§
- Available
Document Kind - Source family used to resolve one available document.
- Available
Document Origin - Precedence class and storage family for one available document.
- Catalog
Error - Invalid document-catalog filter or regular expression.
- Host
Platform - Native host families supported by
ManTdistributions. - Load
Error - Invalid loading input or failure to acquire readable local content.
- Load
Policy - Closed content-resolution policy kept outside the serialized request contract.
- Load
Spec - Borrowed loading input without a protocol schema or a query view.
- Locate
Error - Expected source-discovery failures suitable for a user-facing CLI error.
- Manual
Error - Failure produced by
ManT’s source policy or by the underlying roff parser. - Manual
Error Kind - Stable category for a native manual failure.
- Manual
Load Error - Native-manual resolution or lowering failed after candidate selection.
- Scope
Load Error - Invalid loading scope or failure to acquire any initial document.
- Tldr
Cache Error - Offline cache discovery or page-read failure.
Constants§
- MAX_
MANUAL_ BYTES - Upper bound on both the stored and decoded form of one manual source chain.
- MAX_
MARKDOWN_ BYTES - Upper bound on a single Markdown source, shared by every input path.
Functions§
- discover_
documents - Load and query the current local document catalog.
- discover_
manual_ roots - Discover effective manual hierarchy roots for the current host.
- find_
host_ executable - Locate one directly runnable program using the current host’s
PATHand native executable-suffix rules without spawning it. - get_
system_ tldr_ cache_ dirs - Return known installed-client cache roots in priority order.
- get_
tldr_ cache_ dir - Resolve the
ManT-owned fallback checkout for an explicit environment. - get_
tldr_ languages - Resolve locale candidates, retaining first occurrence priority.
- get_
tldr_ platforms - Resolve host, common, then cross-platform fallback page directories.
- get_
tldr_ read_ cache_ dirs - Select installed-client caches followed by
ManT’s private fallback. - inspect_
manual_ roots - Inspect effective native-manual roots without mutating host state.
- is_
command_ manual_ section - Return whether a manual section belongs to a command-page family.
- is_
manual_ section - Return whether a value is a conventional native manual section.
- list_
available_ documents - List every registered document candidate and locally indexed manual page.
- load_
markdown_ text - Parse in-memory Markdown for the direct
mant -command. - load_
roff_ bytes - Parse one bounded roff stream without consulting MANPATH or following
.so. - locate_
manual_ source_ in - Locate a manual in an explicit immutable index.
- normalize_
tldr_ topic - Convert a multi-word query to the tldr filename convention.
- parenthesized_
manual_ reference - Split the
name(section)spelling accepted by manual readers. - parse_
manual_ bytes - Parse one already bounded, uncompressed standalone roff input.
- parse_
manual_ page - Parse an indexed manual, resolving
.soredirects against its discovered manual hierarchy without falling back to the process working directory. - parse_
manual_ source - Parse and normalize one standalone man or mdoc source file.
- parse_
manual_ source_ with_ report - Parse through the production file pipeline, retaining its native witness.
- query_
available_ documents - Filter the unified local catalog using one shared CLI, TUI, and MCP policy.
- read_
cached_ tldr_ page - Read one cached tldr page using current host conventions; never updates it.
- validate_
document_ scope - Validate source selection and traversal bounds without inspecting a query view.
- validate_
load_ spec - Validate source-selection constraints before any host access.