Skip to main content

Crate mif_rh

Crate mif_rh 

Source
Expand description

Compiled ontology resolution/review engine for research-harness-template (rht) corpora, in the MIF (Modeled Information Format) ecosystem.

Reimplements the observable behavior of rht’s scripts/resolve-ontology.sh (resolve::resolve_finding) and scripts/ontology-review.sh (review::review) — classifying findings against topic-bound domain ontologies, validating each finding’s entity payload, and aggregating per-topic coverage — without any yq/jq/ajv subprocess dependency.

§Determinism boundary

resolve::resolve_finding and review::review are entirely deterministic and rule-based: exact string matching against an ontology’s declared entity types, regex matching against discovery patterns, and JSON Schema validation. No embeddings are used in this classification path — it must stay deterministic both for byte-for-byte parity with rht’s bash output and because rht’s own fail-closed gate (ADR-0011) consumes ontology-map.json’s basis/valid fields directly to decide whether a finding can ship.

Embeddings and cosine similarity are used only by the hypothesis layer: index::FindingIndex (full-text and embedding search over a corpus) and suggest::suggest_type (tier-annotated entity-type hypotheses per MIF ADR-020’s confidence policy, via mif_ontology::confidence) — both consumed by the mif-rh-mcp server’s search/suggest_type/find_similar tools and by mif-rh-cli’s suggest-type subcommand. That layer is read-only and never-authoritative: it never writes to ontology-map.json, and resolve/review never call into it.

Re-exports§

pub use author::DraftReport;
pub use author::draft_from_clusters;
pub use author::draft_from_topic;
pub use calibrate::CONFUSION_REPRESENTATIVES;
pub use calibrate::CalibrateOptions;
pub use calibrate::CalibrationSample;
pub use calibrate::ConfusionPair;
pub use calibrate::ConfusionReport;
pub use calibrate::collect_topic_samples;
pub use calibrate::confusions;
pub use calibrate::packs_carry_negatives;
pub use calibrate::subsample;
pub use calibrate::sweep;
pub use catalog::Catalog;
pub use config::HarnessConfig;
pub use finding::Finding;
pub use harness_assert_graph::CheckResult;
pub use harness_assert_graph::GraphAssertion;
pub use harness_assert_graph::assert_graph_mif_file;
pub use harness_citation_integrity::CitationIntegrityReport;
pub use harness_citation_integrity::check_citation_integrity;
pub use harness_concordance::build_concordance;
pub use harness_corpus::CorpusSynthesis;
pub use harness_corpus::synthesize_corpus;
pub use harness_falsify::FalsifyResult;
pub use harness_falsify::falsify;
pub use harness_falsify::falsify_with_now;
pub use harness_graph::build_graph;
pub use harness_import::ImportReport;
pub use harness_import::import_corpus;
pub use harness_index::build_index;
pub use harness_membership::MembershipReport;
pub use harness_membership::resolve_membership;
pub use harness_ontology_registry::RegistryValidation;
pub use harness_ontology_registry::validate_ontology_registry;
pub use harness_project::project_report;
pub use harness_reconcile::ReconcileReport;
pub use harness_reconcile::reconcile_session;
pub use harness_reconcile::sort_object_keys;
pub use harness_relationship_targets::Orphan;
pub use harness_relationship_targets::RelationshipTargetsReport;
pub use harness_relationship_targets::check_relationship_targets;
pub use harness_release::BumpOptions;
pub use harness_release::BumpReport;
pub use harness_release::ChangelogLinkChange;
pub use harness_release::ChangelogLinkReport;
pub use harness_release::VersionGateFailure;
pub use harness_release::VersionGateReport;
pub use harness_release::bump_version;
pub use harness_release::check_version_bump;
pub use harness_release::goal_version_id;
pub use harness_render::RenderInputs;
pub use harness_render::render_artifact;
pub use harness_shippable_typing::ShippableTypingReport;
pub use harness_shippable_typing::check_shippable_typing;
pub use harness_synthesize::synthesize_artifact;
pub use harness_toggle::SITE_PLUGINS;
pub use harness_toggle::pack_toggle;
pub use harness_toggle::site_toggle_plugin;
pub use harness_toggle::site_toggle_primary;
pub use harness_topic_metadata::TopicMetadata;
pub use harness_topic_metadata::topic_metadata;
pub use harness_validate_concordance::ConcordanceValidation;
pub use harness_validate_concordance::validate_concordance;
pub use harness_wrap::WrapSourceInputs;
pub use harness_wrap::read_source_content;
pub use harness_wrap::wrap_source;
pub use index::FindingIndex;
pub use index::IndexStats;
pub use index::IndexedFinding;
pub use index::Miss;
pub use index::SearchMatch;
pub use index::SimilarFinding;
pub use lock::ReviewLock;
pub use ontology_pack::OntologyPack;
pub use queue::ClusterMember;
pub use queue::ExpansionCandidate;
pub use queue::SuggestionEntry;
pub use queue::SuggestionQueue;
pub use queue::expansion_candidates;
pub use queue::upsert_suggestions;
pub use resolve::Basis;
pub use resolve::MapRecord;
pub use resolve::ResolveContext;
pub use resolve::build_allowed;
pub use resolve::resolve_finding;
pub use review::FollowupBacklog;
pub use review::FollowupEntry;
pub use review::ReviewOptions;
pub use review::ReviewReport;
pub use review::TopicSummary;
pub use review::review;
pub use review::write_followup;
pub use suggest::TypeSuggestion;
pub use suggest::suggest_type;
pub use vendor::CatalogSyncReport;
pub use vendor::DriftEntry;
pub use vendor::FetchReport;
pub use vendor::LockCheckReport;
pub use vendor::LockEntry;
pub use vendor::LockFile;
pub use vendor::NewlyRequiredField;
pub use vendor::PinSafetyGap;
pub use vendor::PinSafetyReport;
pub use vendor::RegistrySyncReport;
pub use vendor::VendoredOntology;
pub use vendor::check_pin_safety;
pub use vendor::fetch;
pub use vendor::lock_check;
pub use vendor::resolve_source;
pub use vendor::sync_catalog;
pub use vendor::sync_registry;

Modules§

author
Drafts a new domain ontology YAML from research.
calibrate
stamped-quantile-v1 threshold calibration (MIF ADR-020, PDD-2).
catalog
rht’s ontology catalog (.claude/enabled-packs.json).
config
rht’s harness configuration (harness.config.json): topic-to-ontology bindings.
finding
A research-harness-template (rht) finding file: reports/<topic>/findings/<id>.json.
harness_assert_graph
Knowledge-graph MIF-substrate assertion (rht Category B, Story #287).
harness_citation_integrity
Citation-integrity gate (rht Category B, Story #287).
harness_concordance
The ontological spine: one unified, cross-topic concordance (rht Category B, Story #282).
harness_corpus
Cross-topic corpus atlas (rht Category B, Story #282; Epic 2, ontological spine, ADR-0011).
harness_falsify
Falsification gate substrate (rht Category B, Story #287, SPEC §6b).
harness_graph
MIF-native knowledge-graph construction (rht Category B, Story #293).
harness_import
Corpus import with schema/provenance validation (rht Category B, Story #282).
harness_index
Research-index incremental maintenance (rht Category B, Story #293).
harness_markdown
Markdown-rendering text transforms shared by render-artifact.sh’s three output channels (rht Category B, Story #293).
harness_membership
Deterministic goal-version scope resolution (rht Category B, Story #293).
harness_ontology_registry
Whole-registry ontology reference integrity (rht Category B, Story #287).
harness_project
MIF Level-3 report projection/validation (rht Category B, Story #298).
harness_reconcile
Durable session checkpoint + remaining-work plan (rht Category B, Story #282).
harness_relationship_targets
Corpus-wide relationship-target integrity gate (rht Category B, Story #287).
harness_release
Harness-native release/versioning tooling (rht Category B, Story #298).
harness_render
Artifact-to-channel rendering (rht Category B, Story #293).
harness_shippable_typing
Fail-closed pre-synthesis typing gate (rht Category B, Story #287, ADR-0011).
harness_synthesize
Deterministic artifact synthesis from surviving findings (rht Category B, Story #282).
harness_toggle
Harness manifest toggles (rht Category B, Story #302).
harness_topic_metadata
Topic README metadata rollup (rht Category B, Story #282).
harness_validate_concordance
Fail-closed ontology conformance for the concordance (rht Category B, Story #287, SPEC §8d).
harness_wrap
MIF source-envelope wrapping (rht Category B, Story #302).
index
SQLite-backed search index over a corpus’s findings: an FTS5 full-text table (for search) plus embedding vectors (for find_similar).
lock
Exclusive review lock, with stale-PID detection.
ontology_pack
Full ontology-pack YAML parsing: entity_types, relationships, discovery, and the extends chain, beyond what mif_ontology::OntologyMetadata covers.
queue
Tier-2 scored-suggestion queue and tier-3 expansion candidates.
resolve
resolve(): classify one finding against its topic’s bound ontologies.
review
review(): rebuild ontology-map.json for one or more topics and aggregate coverage, matching rht’s ontology-review.sh exactly.
suggest
Embedding-based entity-type suggestion with confidence tiers.
vendor
On-demand ontology vendoring (rht ADR-0012).

Structs§

EntityType
One entity type an ontology declares ($defs/entityType in ontology.schema.json).

Enums§

MifRhError
Errors from mif-rh’s engine core.

Functions§

build_search_index
Rebuilds the search index for topic_ids, embedding every finding’s discovery text (or its entity’s name, for typed findings with no standalone content field) via mif_embed::Embedder.
index_text
The text embedded and indexed for one finding: its discovery text (typically content) if any, otherwise its entity’s name, if any.
write_json_atomic
Serializes value to pretty JSON and atomically writes it to path.