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 verify_types;
45
46#[cfg(feature = "full")]
47pub mod c14n;
48#[cfg(feature = "full")]
49pub mod config;
50#[cfg(feature = "crop-element")]
51pub mod crop_element;
52#[cfg(feature = "full")]
53pub mod error;
54#[cfg(feature = "full")]
55pub mod fingerprint;
56#[cfg(feature = "full")]
57pub mod geom;
58#[cfg(feature = "full")]
59pub mod ids;
60#[cfg(feature = "full")]
61pub mod model;
62#[cfg(feature = "full")]
63pub mod traits;
64
65/// Canonical schema version emitted by this crate (all five schemas move in lockstep).
66pub const SCHEMA_VERSION: &str = "1.0.0";
67
68/// The deterministic profile this crate is built to honor.
69pub const PROFILE_ID: &str = "ethos-deterministic-v1";
70
71/// c14n algorithm version implemented by [`c14n`] (when the `full` feature is on).
72pub const C14N_VERSION: &str = "c14n-v1";
73
74/// ID scheme version implemented by [`ids`] (when the `full` feature is on).
75pub const ID_SCHEME_VERSION: &str = "ids-v1";