返回 CodeWhale
mod.rs
1 //! Cloud facts (`facts/v1`): a signed, versioned, off-by-default overlay of
2 //! facts CodeWhale wants to move faster than binary releases — model catalog
3 //! deltas, provider defaults, release truth, and one-line announcements.
4 //!
5 //! This module is **network-free and tokio-free**. It owns the payload types,
6 //! the pinned trust anchors, envelope verification, version scoping, the
7 //! process-wide overlay, and the catalog patch semantics. Fetching and the
8 //! disk cache live in the `codewhale-cloud-facts` crate; the TUI wires both.
9 //!
10 //! Invariants:
11 //! - Bundled facts are the floor. Off / unreachable / rejected / inapplicable
12 //! payloads leave the binary exactly as it ships.
13 //! - Nothing here can change an explicitly configured or session-selected
14 //! model, point a provider at a non-official host, or touch safety policy.
15 //! - Verification happens before any payload byte is interpreted.
16
17 pub mod catalog_patch;
18 pub mod keys;
19 pub mod overlay;
20 pub mod provenance;
21 pub mod registry;
22 pub mod scope;
23 pub mod types;
24 pub mod verify;
25
26 pub use keys::{
27 AUTOMATION_CHANNEL_SUFFIX, AUTOMATION_MAX_MODELS, AUTOMATION_MAX_VALIDITY_SECS, DOMAIN,
28 ENVELOPE_VERSION, KeyRole, KeyStatus, MAX_ENVELOPE_BYTES, MAX_PAYLOAD_BYTES,
29 SUPPORTED_SCHEMA_VERSION, TRUSTED_KEYS, TrustedKey,
30 };
31 pub use overlay::{
32 DefaultSource, cloud_default_base_url, cloud_default_model, cloud_default_model_for_route,
33 pulled_registry, pulled_registry_at,
34 };
35 pub use provenance::{CloudFactsState, CloudFactsStatus, FactsOrigin};
36 pub use registry::{
37 AdmittedRegistry, BuiltinNames, CompiledNamingRules, CompiledRegistry, PulledProvider,
38 REGISTRY_CHANNEL, REGISTRY_SCHEMA, Registry, VerifiedRegistry, admit_registry,
39 verify_registry_envelope,
40 };
41 pub use scope::{ScopedFacts, scoped_view};
42 pub use types::{
43 Announcement, AnnouncementLevel, CloudFacts, ModelFact, ModelOp, PricingFact,
44 ProviderDefaultFact, ReleaseFact, Surface,
45 };
46 pub use verify::{
47 Envelope, FactsRejection, MAX_AUTOMATION_WINDOW_SECS, VerifiedFacts,
48 automation_scope_violation, automation_window_violation, check_automation_window,
49 verify_envelope,
50 };
51
52 /// Whether any pinned key can authenticate a release. With none, the layer is
53 /// inert regardless of the feature flag.
54 #[must_use]
55 pub fn has_active_trusted_key() -> bool {
56 TRUSTED_KEYS
57 .iter()
58 .any(|key| key.status == KeyStatus::Active)
59 }
60
61 /// The running binary's version as semver, for `applies_to` evaluation.
62 #[must_use]
63 pub fn current_version() -> semver::Version {
64 semver::Version::parse(env!("CARGO_PKG_VERSION"))
65 .unwrap_or_else(|_| semver::Version::new(0, 0, 0))
66 }
67
68 #[cfg(test)]
69 mod tests;
70
70 lines RUST