gordon-kernel
Purpose
Shared kernel for the Gordon trading platform. Provides the error taxonomy (GordonError, ErrorKind, ErrorCode) and the validated W3C TraceId scalar — the narrow, frozen-ish leaf that every v7 service depends on. Carved out of gordon-contracts at the 7.0 split (2026-05-15) to isolate the stable, never-churning surface from higher-frequency domain types and bus wire payloads.
Version + status
2.0.0 — frozen-ish. Minor bumps on new ErrorCode / ErrorKind variants. Major bumps on renames, removals, or boundary shifts. Every consumer pins ^2 since the DP-15a batch (2026-05-17).
Public surface
error—GordonError,ErrorKind,Result<T>.From<sqlx::Error>,From<reqwest::Error>,From<serde_json::Error>(orphan-rule forces these to live here).ErrorKind::ColumnDecodeFailed { column: String }added at 2.0.errors—ErrorCodeenum,ErrorCategory,ErrorSeverity, remediation URL accessor, the unifiedgordon_log!macro plusgordon_error!/gordon_warn!thin shims that emit stable structured logs.trace—TraceId: validated W3C 32-hex scalar. ManualDeserializeroutes every wire value throughTraceId::new, so garbage payloads fail decode at the type boundary.
2.0 changes (DP-15a, 2026-05-17)
TraceContextmoved togordon-platform::trace. Runtime plumbing now lives in the runtime crate.TraceIdstays here as a pure value-type wire scalar sogordon-protocolis not forced to depend on a runtime-libs crate.#[non_exhaustive]dropped onErrorCode. Major-pinning (^2) is the new contract. New variants arrive as part of explicit major bumps, not opportunistic minors.gordon_error!/gordon_warn!collapsed ontogordon_log!. Single primitive macro parametric overtracing::Level; the two named macros survive as thin level-pinned shims so call sites remain greppable in Loki.ErrorKind::ColumnDecodeFailed { column: String }added.sqlx::Error::ColumnDecoderoutes here instead of the opaqueSchemaMismatchsentinel.
Macros
gordon_log! is the primitive. gordon_error! / gordon_warn! pin tracing::Level::ERROR / Level::WARN. All three are #[macro_export]'d at the crate root. Every consumer crate that calls any of these macros must have tracing as a direct dependency (not just transitive).
use gordon_kernel::{gordon_log, gordon_error, gordon_warn};Dependencies of note
serde—TraceIdderivesSerialize; the manualDeserializeenforces W3C format validation.sqlx,reqwest,serde_json— minimal, default-features-off; only theirErrortypes are touched for theFrom<>impls.tracing— underpinsgordon_log!.
Invariants
- Frozen-ish. Drift ceiling: 1 minor max. Lagging consumers signal a fix-now obligation.
- No domain types. Litmus: could this code be lifted into another trading platform? If not, it leaks domain.
- Zero
#[allow(...)]. - Every
ErrorCodevariant has a non-test constructor OR aVestigial since vX.Ydocstring. Enforced byscripts/check-errorcode-construction.sh(workspace pre-push Gate 10). A variant with no constructor and no vestigial annotation is treated as a safety claim the runtime does not honour.
Adding a new ErrorCode variant
- Add the variant to
src/errors/codes.rs. - Implement the four accessor arms in
src/errors/accessors.rs. - Add a row in the workspace
docs/reference/error-codes.md. - Run
cargo test—it_errors_taxonomy.rsenforces exhaustiveness. - Wire a non-test constructor within one cycle.
- Commit with
feat:for minor;feat!:(withBREAKING CHANGE:footer) for major.
Where it lives
- Repo:
gordon-kernel/ - kellnr:
https://kellnr.lepaux.com/crates/gordon-kernel(LAN-only) - Not on crates.io.
Related
- gordon-domain — consumes
GordonError,ErrorKindfor domain type results. - gordon-protocol — consumes
TraceIdas a wire scalar in bus payloads. - gordon-platform — holds
TraceContextsince kernel 2.0. - Reference: Error Codes