Skip to main content

cratefield_core/
lib.rs

1//! `cratefield-core` is the runtime-agnostic kernel of the Factory Zero harness:
2//! the [`Module`] contract, the [`Harness`] builder, port traits, RFC 9457
3//! problem+json errors, the request [`Scope`], an in-process [`EventBus`] and
4//! a [`TemplateRegistry`] (ADR 0001, 0002, 0007).
5//!
6//! Core depends only on `http`, `axum` (default features off), `serde`,
7//! `tracing`, `sea-query` and pure-Rust crypto. It must never depend on
8//! `worker`, `wasm-bindgen`, `tokio`, `reqwest`, `sqlx` or `rusqlite`, and
9//! never touches `std::fs` or `std::net` — CI enforces this with a
10//! `cargo tree` check and the wasm build of `examples/venture`.
11
12#![doc = include_str!("../README.md")]
13#![forbid(unsafe_code)]
14
15mod admin;
16mod config;
17mod csv;
18mod email;
19mod events;
20mod harness;
21mod http;
22mod lint;
23mod logging;
24mod module;
25mod ports;
26mod problem;
27mod problems;
28mod rate_limit;
29mod scope;
30mod sidecar;
31mod signer;
32mod surface;
33mod template;
34mod venture;
35
36pub use admin::{bearer_token, constant_time_eq, require_admin};
37pub use config::{Config, ConfigError, EmptyConfig, HarnessConfig, MapConfig, ModuleConfig};
38pub use csv::{FORMULA_PREFIXES, escape as csv_escape, row as csv_row};
39pub use email::{
40    MAX_EMAIL_BYTES, MAX_LOCAL_BYTES, invalid_email_problem, is_valid,
41    normalize as normalize_email, validation_error,
42};
43pub use events::{AnyError, EventBus, EventHandler, EventName};
44pub use harness::{Harness, HarnessBuilder, Runtime};
45pub use http::{Form, Json, MAX_BODY_BYTES, X_REQUEST_ID, rate_limited, request_id_is_valid};
46pub use lint::{card_data_hit, lint_card_data, lint_portable_sql};
47pub use logging::{
48    RedactingVisitor, is_email_field, is_secret_field, redacted_value, set_error_forwarder,
49    subject_hash,
50};
51pub use module::{
52    BoxFuture, HARNESS_API, Migrations, Module, ModuleContext, SqlMigration, harness_api_mismatch,
53    migration_checksum, migration_edited,
54};
55pub use ports::{
56    Blob, BlobError, BlobObject, Captcha, CaptchaError, Charge, CheckoutRequest, CheckoutSession,
57    Clock, ConnectAccountLink, ConnectAccountLinkRequest, Database, DbError, Decision, Defer,
58    DispatchError, Dispatcher, HttpClient, HttpError, IdGen, KeyValue, Kid, KvError, LineItem,
59    MailError, Mailer, Message, Money, NoopDefer, Notification, Payload, Payments, PaymentsError,
60    Port, Ports, Priority, Push, PushError, PushOutcome, RateLimitError, RateLimiter, Refund,
61    RefundRequest, Row, Rows, ScopedBlob, SendOutcome, SignatureError, Signer, Statement,
62    SubscriptionCheckoutRequest, SystemClock, TransferCharge, TryFromValue, UlidIdGen, Verdict,
63    WebhookEvent, timeout,
64};
65pub use problem::Problem;
66pub use problems::{ProblemDef, SLUGS, registry as problem_registry};
67pub use rate_limit::{client_ip, rate_limit_keys};
68pub use scope::Scope;
69pub use sidecar::{HARNESS_SIDECARS, SidecarMount, SidecarMounts, X_HARNESS_API, X_HARNESS_MODULE};
70pub use signer::{HmacSigner, MIN_SECRET_BYTES, SignerError};
71pub use surface::{
72    Action, Audience, Column, HINT_KEYWORDS, ModuleSurface, Outcome, RenderedSurface, SURFACE_API,
73    Surface, SurfaceDocument, SurfaceSource, UiContext, UiMount, VentureSurface, View, hint_field,
74    schema_for,
75};
76pub use template::{Rendered, Template, TemplateError, TemplateRegistry};
77pub use venture::{Brand, Venture, VentureEnv};