Skip to main content

Crate mandible_core

Crate mandible_core 

Source
Expand description

mandible-core: the shared intermediate representation (IR) every mandible extraction tier normalizes into, and the merge logic that combines several tiers’ output for the same node into one.

See spec §4. This crate has no knowledge of any specific tool, tier, or terminal library — it is pure data model plus the sanitization and merge rules that keep that data model trustworthy.

Modules§

audit
The audit/<seed>.toml manifest schema: one sampled tool’s entry, its pre-tag suggestions, and its verdict — plus the load/save/parse helpers that let every reader and writer of the file agree on what’s in it.

Structs§

Authority
The two-axis trust level a Source carries. See spec §4.4’s authority table — the tier with the best structure is frequently not the tier with the best prose, so merge resolves each axis independently rather than by a single priority order.
CommandNode
One command or subcommand in the tree: git, git rebase, git rebase --onto’s parent, and so on.
Confession
A truncation confession a tool’s own --help text printed, and what this extraction did about it (spec §6 rule 2b).
ConfessionSnapshot
Snapshot form of crate::node::Confession.
Example
A worked example: a command line plus an optional explanation.
ExampleSnapshot
Snapshot form of Example.
Flag
A single flag/option, e.g. -i, --interactive.
FlagSnapshot
Snapshot form of Flag. Field order matches Flag’s own declaration; every Option/Vec field is omitted when empty, every bool field is omitted when false.
NodeSnapshot
Snapshot form of CommandNode. See this module’s doc comment for the normalization rules; in short, Option/Vec fields are omitted when empty, provenance.confidence is rounded, and subcommands order is preserved exactly as CommandNode stored it.
Positional
A positional argument, e.g. <pathspec>....
PositionalSnapshot
Snapshot form of Positional.
Provenance
Which extraction source(s) contributed to an item, in contribution order, plus a confidence score set only by heuristic tiers.
ProvenanceSnapshot
Snapshot form of Provenance: sources rendered through Source::label (already the human-readable form used by --doctor and the detail pane’s footer, so this introduces no second vocabulary) and confidence rounded per [round_confidence]. Both fields are omitted when empty/None.
Text
Sanitized, display-safe text.

Enums§

Axis
One axis of Authority: structural facts (names, nesting, arity, which flags exist) vs. prose (descriptions, summaries, examples).
FlagKey
Identifies a flag within a node’s flag list.
ManFormat
Which man page macro package produced a Source::ManPage item.
MergeError
Errors merge can return.
NodeRef
A reference to a command or a specific flag within the tree, by name path.
Source
The origin of a piece of extracted data. See spec §4.2 and §7.
ValueKind
Whether a flag takes a value, and if so, whether it’s required.

Constants§

MAX_TEXT_CHARS
Hard cap on sanitized text length, in chars. Applied after all other normalization. Generous enough for any legitimate flag description or man page section, small enough that a pathological multi-megabyte string from a misbehaving tool cannot make its way into a render buffer.

Functions§

is_command_name_shaped
True if s looks like a real command/subcommand name: lowercase, starting with a letter, and otherwise only letters/digits/_/./- (^[a-z][a-z0-9_.-]*$, spec §7 Tier B rule 3).
merge_flag_lists
Merge flags by identity (long name, else short letter, else description-as-fallback) across several already alias-paired flag lists, applying the same two-axis authority resolution per field.
merge_nodes
Merge several same-node extraction results into one, per spec §4.4.
merge_positional_lists
Merge positionals across candidate lists by name identity.
merge_subcommand_lists
Merge subcommand lists recursively by name (spec §4.4: “Subcommands merge recursively by name”).
pair_aliases
Unify flags that arrived as separate short/long rows from the same source, per spec §4.4: sources legitimately emit a flag’s short and long forms as distinct items (e.g. gh __complete pr - returns --repo and -R as separate rows with identical descriptions). Within one node’s flag list, items whose descriptions match exactly and whose short/long slots are complementary unify into one Flag. Must run before merge.
resolve
Resolve a name path to the CommandNode it addresses, starting from root. path includes root’s own name as its first element.
resolve_flag
Resolve a NodeRef to the flag it addresses, if any.
resolve_mut
Mutable counterpart of resolve, used by the extraction runner to splice a newly-extracted subtree into the cached tree in place.
to_snapshot
Build a NodeSnapshot from a CommandNode, applying this module’s normalization rules (confidence rounding, omission of empty/None fields) without touching anything order-sensitive. This is the one function a corpus runner or a snapshot test needs.