T07: Cargo workspace scaffold — cb-kernel/cb-events/cb-game-runtime/games-ground/cb-sim, HashMap deny-lint, scenario format + runner stub, Criterion skeleton, Makefile, CI
Some checks failed
ci / check (push) Has been cancelled
Some checks failed
ci / check (push) Has been cancelled
This commit is contained in:
parent
396990539a
commit
467e2c561d
23 changed files with 1625 additions and 0 deletions
45
crates/cb-kernel/src/ids.rs
Normal file
45
crates/cb-kernel/src/ids.rs
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
//! Canonical identifiers (GameKernel §2.1): newtyped, copyable, ordered.
|
||||
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
macro_rules! id_type {
|
||||
($(#[$doc:meta])* $name:ident($inner:ty)) => {
|
||||
$(#[$doc])*
|
||||
#[derive(
|
||||
Debug, Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Serialize, Deserialize,
|
||||
)]
|
||||
#[serde(transparent)]
|
||||
pub struct $name(pub $inner);
|
||||
|
||||
impl core::fmt::Display for $name {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
write!(f, "{}", self.0)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
id_type!(
|
||||
/// A single game instance.
|
||||
GameId(u64)
|
||||
);
|
||||
id_type!(
|
||||
/// Seat index within a game (0-based).
|
||||
PlayerId(u8)
|
||||
);
|
||||
id_type!(
|
||||
/// Semantic entity: problem, token, relation, card.
|
||||
EntityId(u32)
|
||||
);
|
||||
id_type!(
|
||||
/// Client-assigned command identifier for idempotency (GameKernel K2).
|
||||
CommandId(u64)
|
||||
);
|
||||
id_type!(
|
||||
/// Monotonic per-game event sequence number (GameKernel K4).
|
||||
EventSeq(u64)
|
||||
);
|
||||
id_type!(
|
||||
/// Deterministic game seed (GameKernel K5).
|
||||
Seed(u64)
|
||||
);
|
||||
Loading…
Add table
Add a link
Reference in a new issue