ethos_core/lib.rs
1/*
2 * Copyright 2026 The Ethos maintainers
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17//! # ethos-core
18//!
19//! The Ethos product contract in Rust: canonical document model, deterministic
20//! serialization (c14n v1), fingerprints, stable error/warning codes, page-range
21//! configuration, and the trait boundaries between crates.
22//!
23//! Normative references: `schemas/*.json` and `docs/determinism-contract.md`.
24//! Contract changes happen only via `contract-change` PRs with version bumps.
25//!
26//! ## Feature layers (invariant 4: verify portability)
27//!
28//! - `grounding` — the [`grounding::GroundingSource`] trait module alone. `ethos-verify`
29//! depends on `ethos-core` with `default-features = false, features = ["grounding", "verify-types"]`
30//! and therefore can never see parser internals. CI builds it that way to prove it.
31//! - `verify-types` — verification report/config schema types + stable warning codes.
32//! - `full` (default) — canonical model, c14n, fingerprints, geometry, config, traits.
33//! - `crop-element` — source-only pre-alpha crop descriptor API, intentionally opt-in.
34
35#![forbid(unsafe_code)]
36#![warn(missing_docs)]
37
38#[cfg(feature = "grounding")]
39pub mod grounding;
40
41#[cfg(feature = "verify-types")]
42pub mod codes;
43#[cfg(feature = "verify-types")]
44pub mod evidence_anchor;
45#[cfg(feature = "verify-types")]
46pub mod verify_types;
47
48#[cfg(feature = "full")]
49pub mod c14n;
50#[cfg(feature = "full")]
51pub mod config;
52#[cfg(feature = "crop-element")]
53pub mod crop_element;
54#[cfg(feature = "full")]
55pub mod error;
56#[cfg(feature = "full")]
57pub mod fingerprint;
58#[cfg(feature = "full")]
59pub mod geom;
60#[cfg(feature = "full")]
61pub mod ids;
62#[cfg(feature = "full")]
63pub mod model;
64#[cfg(feature = "full")]
65pub mod traits;
66
67/// Canonical schema version emitted by this crate (all five schemas move in lockstep).
68pub const SCHEMA_VERSION: &str = "1.0.0";
69
70/// The deterministic profile this crate is built to honor.
71pub const PROFILE_ID: &str = "ethos-deterministic-v1";
72
73/// c14n algorithm version implemented by [`c14n`] (when the `full` feature is on).
74pub const C14N_VERSION: &str = "c14n-v1";
75
76/// ID scheme version implemented by [`ids`] (when the `full` feature is on).
77pub const ID_SCHEME_VERSION: &str = "ids-v1";