Skip to main content

dsfb_gpu_debug_core/
lib.rs

1//! Deterministic CPU reference and semantic authority for
2//! `dsfb-gpu-debug` --- the court half of the **densorial /
3//! tekmeric inference** posture.
4//!
5//! **Front-door identity (panel-locked)**: DSFB-GPU implements
6//! densorial / tekmeric inference (deterministic inference
7//! over evidence densors + evidence-based deterministic
8//! adjudication), not neural inference over learned-weight
9//! tensors. This crate hosts the CPU reference path, the
10//! Q16.16 fixed-point primitive that pins CPU/GPU byte-
11//! equality, and the bank module that owns admission
12//! authority for `Episode` (the Semantic Non-Bypass Axiom:
13//! only the bank's private `BankAdmissionToken` constructor
14//! can mint admitted episodes; the GPU never does).
15//!
16//! ```text
17//! neural inference:
18//!   tensor → learned weights → probabilistic output
19//!
20//! densorial / tekmeric inference:
21//!   densor → deterministic witness court → replayable case file
22//! ```
23//!
24//! This crate is intentionally `#![no_std]` and dependency-free. It contains:
25//!
26//! * The Q16.16 fixed-point primitive (`fixed::Q16`) used by both the CPU
27//!   reference and the CUDA kernels, so CPU↔GPU byte-equality is achievable
28//!   per stage of the pipeline.
29//! * A hand-rolled SHA-256 implementation in `hash` so that intermediate
30//!   artifact hashes can be computed in a `no_std` context without pulling in
31//!   external dependencies.
32//!
33//! As the workspace grows, additional modules (canonical serialization,
34//! pipeline stages, heuristics bank, episode collapse, case file emission)
35//! will live alongside these two foundations. Sections are added one at a
36//! time so each is independently auditable.
37
38#![cfg_attr(not(feature = "std"), no_std)]
39#![forbid(unsafe_code)]
40#![deny(missing_docs)]
41// Tests legitimately use `.unwrap()` and `.unwrap_err()` to assert
42// reachability; allowing those clippy lints under `cfg(test)` keeps the
43// production code strict while letting test bodies stay concise.
44#![cfg_attr(test, allow(clippy::unwrap_used, clippy::expect_used))]
45
46#[cfg(test)]
47extern crate std;
48
49pub mod event;
50pub mod fixed;
51pub mod grammar;
52pub mod hash;
53pub mod motif;
54pub mod verdict;
55
56#[cfg(feature = "std")]
57pub mod bank;
58#[cfg(feature = "std")]
59pub mod candidate;
60#[cfg(feature = "std")]
61pub mod casefile;
62#[cfg(feature = "std")]
63pub mod casefile_v2;
64#[cfg(feature = "std")]
65pub mod consensus;
66#[cfg(feature = "std")]
67pub mod contract;
68#[cfg(feature = "std")]
69pub mod detector;
70#[cfg(feature = "std")]
71pub mod fixture;
72#[cfg(feature = "std")]
73pub mod residual;
74#[cfg(feature = "std")]
75pub mod serialize;
76#[cfg(feature = "std")]
77pub mod sign;
78#[cfg(feature = "std")]
79pub mod window;
80
81#[cfg(feature = "std")]
82pub use bank::{bank_hash, BankMotif, Episode, HeuristicEntry, CANONICAL_BANK};
83#[cfg(feature = "std")]
84pub use candidate::{CandidateConfig, CandidateInterval};
85#[cfg(feature = "std")]
86pub use casefile::{
87    build_cpu, build_cpu_throughput, build_from_artifacts_with_mode, compare as compare_case_files,
88    emit as emit_case_file, CaseFile, EmissionMode, IntermediateHashes, COMPACT_INPUT_DOMAIN,
89    TRACE_EVENT_LAYOUT_TAG,
90};
91#[cfg(feature = "std")]
92pub use consensus::ConsensusCell;
93#[cfg(feature = "std")]
94pub use contract::{Contract, KernelSequence, NumericMode};
95#[cfg(feature = "std")]
96pub use detector::{DetectorCell, DetectorThresholds};
97pub use event::TraceEvent;
98pub use fixed::Q16;
99pub use grammar::{GrammarState, ReasonCode};
100pub use hash::{sha256, Sha256};
101pub use motif::{registry_hash, MotifClass, MOTIF_CATALOG};
102#[cfg(feature = "std")]
103pub use residual::{Baseline, ResidualCell};
104#[cfg(feature = "std")]
105pub use sign::SignCell;
106pub use verdict::FinalVerdict;
107#[cfg(feature = "std")]
108pub use window::WindowFeature;