Expand description
§mant-protocol
mant-protocol is ManT’s versioned structured interaction boundary. It
defines the request and response DTOs shared by in-process hosts, CLI JSON,
request JSON, and MCP without owning any transport. It owns schema markers,
logical catalog addresses, pagination, outline, excerpt, search, tldr-update
results, and JSON Schema generation. The mant crate separately composes host
callbacks, process framing, and MCP transport.
Use this crate whenever a Rust host or process consumer needs stable structured inputs and projections. The same DTO may cross an in-memory callback or a serialized transport; serialization is a supported representation, not the crate’s sole purpose. It contains data contracts only: it performs no document discovery, parsing, query execution, rendering, terminal I/O, or MCP transport.
§Contract families
QueryRequest ──> host / mant-engine ──┬─> QueryBundle
├─> QueryOutline
├─> QueryExcerpt
└─> QuerySearch
CatalogQuery ──> host ──────────────────> DocumentCatalog| Family | Current discriminator | Purpose |
|---|---|---|
| Process framing | mant.cli/v7 | Advertised by the mant executable |
| Request | mant.request/v7 | Closed input accepted by --request-json |
| Full query | mant.query/v7 | Document plus optional tldr content |
| Document | mant.document/v7 | Versioned projection of the normalized document |
| Catalog | mant.catalog/v7 | Registered Markdown and native-manual discovery |
| Outline, excerpt, search | mant.outline/v7, mant.excerpt/v7, mant.search/v7 | Focused query projections |
The schemas generated from the Rust types are authoritative. Request schemas are generated for deserialization so closed-object and default behavior match what the process accepts; response schemas are generated for serialization.
§Basic use
Construct requests with the typed tagged unions and discover the exact JSON Schema rather than copying a shape by hand:
use mant_protocol::{
NATIVE_API_VERSION, OutlineDetail, QueryInput, QueryRequest, QueryView,
RequestSchema, query_request_json_schema,
};
let request = QueryRequest {
schema: RequestSchema::V7,
input: QueryInput::Document {
selector: "git".to_owned(),
source: None,
manual_section: None,
},
view: QueryView::Outline {
detail: OutlineDetail::Entries,
},
};
assert_eq!(NATIVE_API_VERSION, "7");
assert_eq!(request.schema, RequestSchema::V7);
let _schema = query_request_json_schema();Adding or changing a Rust field does not by itself authorize a wire change.
Each schema family advances only when its serialized contract requires it;
clients must compare complete discriminators rather than infer compatibility
from the ManT package version.
mant-protocol deliberately reuses the semantic Block, Section, Inline,
DefinitionIdentity, DocumentAddress, source, metadata, diagnostic, and tldr
types from mant-ir. Those types form the wire-bearing semantic subset: a
Serde change to any of them is also a protocol change. CI compares every
generated structural schema with the checked-in v7 snapshot, so an accidental
IR representation change fails until compatibility is restored or the
affected protocol discriminator is advanced explicitly. Rustdoc descriptions
and schema titles are excluded from that structural comparison.
Normalized document content is defined separately by
mant-ir. Parsing, lookup, projection, and
rendering live in mant-engine.
The complete wire contract is documented by
mant-protocol(5).
§License
Apache-2.0.
Structs§
- Catalog
Query - Bounded filtering and pagination shared by CLI, TUI, and MCP discovery.
- Document
Catalog - Deterministically ordered page of discoverable local documents.
- Document
Response - Serializable v7 envelope around
ManT’s protocol-independent document IR. - Document
Summary - One catalog row identified entirely by logical names.
- Engine
- Parser implementation recorded at the process boundary.
- Node
Path - Canonical structural address emitted for a node in a projected outline.
- Node
Selector - User-supplied outline selector interpreted as a path, node ID, or entry alias.
- Outline
Reference - Compact ancestor identity attached to an excerpt selection.
- Producer
- Identifies
ManTand the parser used to build a wire document. - Query
Bundle - Versioned full-query result emitted at JSON and MCP boundaries.
- Query
Excerpt - One or more independently selected nodes from a complete query.
- Query
Outline - A block-free tree used to discover selectable query content.
- Query
Request - Native use-case input. The engine validates semantic constraints before I/O.
- Query
Search - Complete, paginatable search result returned to agents and scripts.
- Search
Context Line - One rendered Markdown line surrounding a match.
- Search
Markdown Range - Half-open byte range plus one-based human coordinates in full Markdown.
- Search
Match - One exact occurrence and both of its structural and rendered locations.
- Search
Query - Normalized search configuration echoed in a search response.
- Search
Render - Description of the deterministic document whose Markdown coordinates are reported.
- Search
Section Reference - Addressable containing section for a non-tldr match.
- Tldr
Cache Update - Result of an explicit
mant --update-tldroperation.
Enums§
- Catalog
Document Kind - Optional family filter for catalog discovery.
- Catalog
Match Rank - Stable relevance tier for literal catalog matching.
- Catalog
Schema - Exact schema marker for a local document catalog.
- Document
Address - Stable selector for one discoverable document candidate.
- Document
Schema - Exact schema marker for a normalized structured document response.
- Excerpt
Schema - Exact schema marker for selected query content.
- Excerpt
Selection - One selected document node together with its location in the complete outline.
- Input
Format - Parser selected for an explicit physical input.
- Markdown
Origin - Storage identity of one registered Markdown document.
- Markdown
Schema - Markdown contract used as the coordinate space for every search format.
- Outline
Detail - Amount of semantic detail included in an outline projection.
- Outline
Node - One uniquely addressable node in a query outline.
- Outline
Schema - Exact schema marker for a query outline response.
- Query
Input - Source selected by one public query request.
- Query
Schema - Exact schema marker for a complete
ManTquery result. - Query
View - Projection requested after loading one complete structured document.
- Request
Schema - Exact schema marker for a native query request.
- Search
Case - Case-folding policy applied when compiling the matcher.
- Search
Node - Nearest node accepted by
mant --nodefor a matching occurrence. - Search
Render Format - Canonical render format used for search coordinates.
- Search
Render Scope - Amount of the query included in the coordinate-bearing render.
- Search
Schema - Exact schema marker for structure-aware search results.
- Search
Scope - Text representation searched while Markdown remains the coordinate basis.
- Search
Syntax - Pattern language used for one search.
- Tldr
Cache Action - How an explicit tldr cache refresh changed local state.
Constants§
- DEFAULT_
SEARCH_ LIMIT - Default maximum number of search matches returned in one page.
- NATIVE_
API_ VERSION - Native API version negotiated independently from document schema versions.
Functions§
- catalog_
literal_ match_ rank - Rank one document name or slash-delimited path using the catalog’s literal-search case policy.
- default_
catalog_ limit - Return the default maximum number of catalog rows.
- default_
search_ limit - Return
DEFAULT_SEARCH_LIMIT. - document_
catalog_ json_ schema - Generate the local document-catalog JSON representation.
- query_
bundle_ json_ schema - Generate the complete-query JSON representation emitted by
mant. - query_
excerpt_ json_ schema - Generate the selected-excerpt JSON representation emitted by
mant. - query_
json_ schema_ catalog - Generate every public request and query-response contract in stable order.
- query_
outline_ json_ schema - Generate the outline JSON representation emitted by
mant. - query_
request_ json_ schema - Generate the JSON representation accepted when deserializing a request.
- query_
search_ json_ schema - Generate the structure-aware search result emitted by
mant.