0.1.0-0-pre.5-fix.1

This commit is contained in:
2026-09-16 01:26:41 +02:00
parent 8451d09da0
commit 4a5471c5f4
11 changed files with 336 additions and 108 deletions

View File

@@ -1,10 +1,9 @@
# file: Cargo.toml
# version: 8
# version: 9
[workspace]
resolver = "3"
members = [
"crates/common/game-logging-lib",
"crates/engines/engine-v1-common",
"crates/engines/engine-v1-platform-api",
"crates/engines/engine-v1-sdl",
@@ -12,15 +11,44 @@ members = [
"crates/games/game-snake-poc",
"crates/apps/game-reflex-poc-desktop",
"crates/apps/game-snake-poc-desktop",
"crates/common/game-logging-lib",
]
[workspace.package]
version = "0.1.0-0-pre.5"
version = "0.1.0-0-pre.5.fix.1"
edition = "2024"
license = "MIT"
repository = "https://git.sasedev.com/Sasedev/games"
authors = ["Sasedev <games@sasedev.com>"]
publish = false
[workspace.dependencies]
sdl3 = "0.16"
tracing = "0.1"
tracing-appender = "0.2"
tracing-subscriber = "0.3"
sdl3 = { version = "0.16.1", features = ["build-from-source"] }
tracing = "0.1.44"
tracing-appender = "0.2.5"
tracing-subscriber = { version = "0.3.23", features = ["fmt"] }
[workspace.lints.rust]
missing_docs = "warn"
unreachable_pub = "deny"
unsafe_code = "forbid"
[workspace.lints.clippy]
unwrap_used = "deny"
expect_used = "deny"
implicit_return = "deny"
needless_return = "allow"
useless_vec = "deny"
question_mark = "deny"
question_mark_used = "deny"
needless_match = "allow"
manual_ok_err = "allow"
manual_unwrap_or = "allow"
manual_map = "allow"
match_like_matches_macro = "allow"
single_match = "allow"
manual_unwrap_or_default = "allow"
manual_find = "allow"
explicit_counter_loop = "allow"
get_first = "allow"
implicit_saturating_sub = "allow"

View File

@@ -1,18 +1,22 @@
# file: crates/apps/game-reflex-poc-desktop/Cargo.toml
# version: 2
# version: 4
[package]
name = "game-reflex-poc-desktop"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
publish.workspace = true
[dependencies]
engine-v1-common = { path = "../../engines/engine-v1-common" }
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
game-logging-lib = { path = "../../common/game-logging-lib" }
game-reflex-poc = { path = "../../games/game-reflex-poc" }
tracing.workspace = true
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"
[lints]
workspace = true

View File

@@ -1,14 +1,30 @@
// file: crates/apps/game-reflex-poc-desktop/src/main.rs
// version: 3
// version: 4
use engine_v1_sdl::SdlRuntime;
use game_reflex_poc::ReflexGame;
#![warn(missing_docs)]
#![deny(unreachable_pub)]
#![forbid(unsafe_code)]
fn main() -> Result<(), String> {
let _guard = game_logging_lib::init_default_tracing("games::runner").map_err(|error| error.to_string())?;
tracing::info!(game = "reflex", "desktop SDL3 runner started");
//! SDL3 Desktop development runner for the Reflex POC game library.
let runtime = SdlRuntime::new("Reflex POC", 720, 1280, 16);
let mut game = ReflexGame::default();
return runtime.run(&mut game);
fn main() {
let _logging_guard = match game_logging_lib::init_console_tracing() {
std::result::Result::Ok(guard) => guard,
std::result::Result::Err(error) => {
eprintln!("failed to initialize tracing: {error}");
return;
},
};
tracing::info!(target: "games::runner", game = "reflex", "desktop SDL3 runner started");
let _monetization = engine_v1_platform_api::MonetizationCapabilities::disabled();
let runtime = engine_v1_sdl::SdlRuntime::new("Reflex POC", 720, 1280, std::time::Duration::from_millis(16));
let mut state = game_reflex_poc::ReflexState::new();
match runtime.run(&mut state) {
std::result::Result::Ok(()) => {},
std::result::Result::Err(error) => {
tracing::error!(target: "games::runner", game = "reflex", %error, "desktop SDL3 runner failed");
eprintln!("Reflex POC desktop runner failed: {error}");
},
}
return;
}

View File

@@ -1,18 +1,22 @@
# file: crates/apps/game-snake-poc-desktop/Cargo.toml
# version: 2
# version: 4
[package]
name = "game-snake-poc-desktop"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
publish.workspace = true
[dependencies]
engine-v1-common = { path = "../../engines/engine-v1-common" }
engine-v1-platform-api = { path = "../../engines/engine-v1-platform-api" }
engine-v1-sdl = { path = "../../engines/engine-v1-sdl" }
game-logging-lib = { path = "../../common/game-logging-lib" }
game-snake-poc = { path = "../../games/game-snake-poc" }
tracing.workspace = true
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"
[lints]
workspace = true

View File

@@ -1,14 +1,30 @@
// file: crates/apps/game-snake-poc-desktop/src/main.rs
// version: 3
// version: 4
use engine_v1_sdl::SdlRuntime;
use game_snake_poc::SnakeGame;
#![warn(missing_docs)]
#![deny(unreachable_pub)]
#![forbid(unsafe_code)]
fn main() -> Result<(), String> {
let _guard = game_logging_lib::init_default_tracing("games::runner").map_err(|error| error.to_string())?;
tracing::info!(game = "snake", "desktop SDL3 runner started");
//! SDL3 Desktop development runner for the Snake POC game library.
let runtime = SdlRuntime::new("Snake POC", 720, 1280, 16);
let mut game = SnakeGame::default();
return runtime.run(&mut game);
fn main() {
let _logging_guard = match game_logging_lib::init_console_tracing() {
std::result::Result::Ok(guard) => guard,
std::result::Result::Err(error) => {
eprintln!("failed to initialize tracing: {error}");
return;
},
};
tracing::info!(target: "games::runner", game = "snake", "desktop SDL3 runner started");
let _monetization = engine_v1_platform_api::MonetizationCapabilities::disabled();
let runtime = engine_v1_sdl::SdlRuntime::new("Snake POC", 720, 1280, std::time::Duration::from_millis(16));
let mut state = game_snake_poc::SnakeState::new();
match runtime.run(&mut state) {
std::result::Result::Ok(()) => {},
std::result::Result::Err(error) => {
tracing::error!(target: "games::runner", game = "snake", %error, "desktop SDL3 runner failed");
eprintln!("Snake POC desktop runner failed: {error}");
},
}
return;
}

View File

@@ -1,17 +1,22 @@
# file: crates/engines/engine-v1-sdl/Cargo.toml
# version: 2
# version: 3
[package]
name = "engine-v1-sdl"
version.workspace = true
edition.workspace = true
license.workspace = true
repository.workspace = true
authors.workspace = true
publish.workspace = true
[dependencies]
engine-v1-common = { path = "../engine-v1-common" }
sdl3.workspace = true
tracing.workspace = true
[lints.rust]
missing_docs = "warn"
unsafe_code = "forbid"
[lints]
workspace = true
[dev-dependencies]
game-logging-lib = { path = "../../common/game-logging-lib" }

View File

@@ -1,11 +1,14 @@
// file: crates/engines/engine-v1-sdl/src/lib.rs
// version: 2
// version: 3
#![warn(missing_docs)]
#![deny(unreachable_pub)]
#![forbid(unsafe_code)]
//! SDL3 integration for engine generation V1.
mod runtime;
#[cfg(test)]
mod unit_tests;
pub use crate::runtime::SdlRuntime;
/// Re-export of the minimal SDL3 runtime used by Desktop POC runners.
pub use self::runtime::SdlRuntime;

View File

@@ -1,84 +1,68 @@
// file: crates/engines/engine-v1-sdl/src/runtime.rs
// version: 1
use sdl3::event::Event;
use sdl3::keyboard::Keycode;
use sdl3::pixels::Color;
use engine_v1_common::{Action, EngineGame, FixedStepRunner, InputState};
// version: 2
/// Minimal SDL3 runtime used by Desktop POC runners.
pub struct SdlRuntime {
title: String,
title: std::string::String,
width: u32,
height: u32,
frame_duration_ms: u64,
frame_duration: std::time::Duration,
}
impl SdlRuntime {
/// Creates a minimal SDL3 runtime configuration.
#[must_use]
pub fn new(title: impl Into<String>, width: u32, height: u32, frame_duration_ms: u64) -> Self {
return Self {
title: title.into(),
width,
height,
frame_duration_ms,
};
pub fn new(title: impl std::convert::Into<std::string::String>, width: u32, height: u32, frame_duration: std::time::Duration) -> Self {
return Self { title: title.into(), width, height, frame_duration };
}
/// Runs a game until the user closes the window or presses Escape.
pub fn run<G: EngineGame>(&self, game: &mut G) -> Result<(), String> {
let sdl = sdl3::init().map_err(|error| error.to_string())?;
let video = sdl.video().map_err(|error| error.to_string())?;
let window = video
.window(&self.title, self.width, self.height)
.position_centered()
.build()
.map_err(|error| error.to_string())?;
pub fn run<G>(&self, game: &mut G) -> std::result::Result<(), std::string::String>
where
G: engine_v1_common::EngineGame,
{
let sdl = match sdl3::init() {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error.to_string()),
};
let video = match sdl.video() {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error.to_string()),
};
let window = match video.window(&self.title, self.width, self.height).position_centered().build() {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error.to_string()),
};
let mut canvas = window.into_canvas();
let mut events = sdl.event_pump().map_err(|error| error.to_string())?;
let mut runner = FixedStepRunner::new(self.frame_duration_ms);
tracing::info!(
title = %self.title,
width = self.width,
height = self.height,
"SDL3 runtime started"
);
let mut events = match sdl.event_pump() {
std::result::Result::Ok(value) => value,
std::result::Result::Err(error) => return std::result::Result::Err(error.to_string()),
};
let mut runner = engine_v1_common::FixedStepRunner::new(self.frame_duration);
tracing::info!(title = %self.title, width = self.width, height = self.height, "SDL3 runtime started");
'running: loop {
let mut input = InputState::default();
let mut input = engine_v1_common::InputState::none();
for event in events.poll_iter() {
match event {
Event::Quit { .. } => {
break 'running;
}
Event::KeyDown {
keycode: Some(Keycode::Escape),
..
} => {
break 'running;
}
Event::KeyDown {
keycode: Some(Keycode::Space),
..
} => {
input.set(Action::Primary, true);
}
_ => {}
sdl3::event::Event::Quit { .. } => break 'running,
sdl3::event::Event::KeyDown { keycode: Some(sdl3::keyboard::Keycode::Escape), .. } => break 'running,
sdl3::event::Event::KeyDown { keycode: Some(sdl3::keyboard::Keycode::Space), .. } => {
input = input.with_action(engine_v1_common::GameAction::Primary, true);
},
_ => {},
}
}
runner.tick(game, &input);
canvas.set_draw_color(Color::RGB(18, 18, 24));
runner.tick(game, input);
canvas.set_draw_color(sdl3::pixels::Color::RGB(18, 18, 24));
canvas.clear();
canvas.present();
std::thread::sleep(self.frame_duration);
}
tracing::info!(frames = runner.next_frame_index(), "SDL3 runtime stopped");
return std::result::Result::Ok(());
}
}
tracing::info!("SDL3 runtime stopped");
return Ok(());
}
}
#[cfg(test)]
#[path = "../unit_tests/runtime.rs"]
mod tests;

View File

@@ -1,5 +1,6 @@
// file: crates/engines/engine-v1-sdl/src/unit_tests.rs
// version: 1
// version: 2
#[cfg(test)]
#[path = "../unit_tests/runtime.rs"]
mod runtime;
mod tests;

View File

@@ -1,11 +1,12 @@
// file: crates/engines/engine-v1-sdl/unit_tests/runtime.rs
// version: 1
//! Unit tests for SDL runtime configuration.
use engine_v1_sdl::SdlRuntime;
// version: 2
#[test]
fn runtime_configuration_constructs() {
let _runtime = SdlRuntime::new("test", 320, 240, 16);
game_logging_lib::with_test_tracing("runtime_configuration_constructs", || {
let _runtime = crate::SdlRuntime::new("test", 320, 240, std::time::Duration::from_millis(16));
tracing::info!("SDL3 runtime configuration constructed");
return;
});
return;
}

View File

@@ -0,0 +1,166 @@
<!-- file: deltas/0.1.0/0-pre.5.fix.1.md -->
<!-- version: 1 -->
# Delta 0.1.0-0-pre.5.fix.1
## Base
Base déclarée : `0.1.0-0-pre.5`, non validée.
## Validation du delta précédent
L'utilisateur a exécuté les gates de `0.1.0-0-pre.5` le 2026-09-16.
La validation a échoué avant toute compilation SDL3 exploitable.
### Échec Cargo metadata
Le `Cargo.toml` racine livré par `0-pre.5` avait remplacé des métadonnées workspace existantes au lieu de les préserver.
Erreur observée :
```text
error inheriting `authors` from workspace root manifest's `workspace.package.authors`
`workspace.package.authors` was not defined
```
Cette erreur empêchait :
- `cargo fmt --all` ;
- `cargo fmt --all -- --check` ;
- `cargo check --workspace` ;
- Clippy ;
- les tests ciblés ;
- les runners Desktop.
### Échec des audits Rust
L'audit Rust a relevé 31 violations dans les nouveaux fichiers de `0-pre.5`, notamment :
- attributs crate-root manquants ;
- rustdoc de réexport manquante ;
- `use` ordinaires interdits par les règles du projet ;
- réexport interne non préfixé par `self::` ;
- groupement d'import interdit ;
- ordre/imports non conformes ;
- lignes blanches interdites dans les fonctions.
L'audit Markdown était propre : `1 table(s), 39 file(s)`.
`0.1.0-0-pre.5` n'est donc pas considéré validé.
## Correctifs
### Workspace Cargo
Le manifest racine est reconstruit à partir de la dernière baseline validée et conserve :
- `repository` ;
- `authors` ;
- `publish` ;
- les versions déjà retenues pour `tracing`, `tracing-appender` et `tracing-subscriber` ;
- les lints Rust et Clippy du workspace.
SDL3 est ajouté sans supprimer ces métadonnées :
```toml
sdl3 = { version = "0.16.1", features = ["build-from-source"] }
```
L'option `build-from-source` évite de dépendre obligatoirement d'une installation système préalable de SDL3 sur la machine Desktop.
### engine-v1-sdl
Le runtime SDL3 est corrigé pour respecter les API réelles déjà présentes dans le workspace :
- `FixedStepRunner::new` reçoit un `std::time::Duration` ;
- `InputState::none()` est utilisé comme snapshot initial ;
- `GameAction::Primary` est activé via `with_action` ;
- aucun `?`, `unwrap()` ou `expect()` n'est utilisé ;
- les erreurs SDL3 sont propagées explicitement ;
- aucun `use` ordinaire n'est nécessaire ;
- le réexport crate-root est documenté et passe par `self::runtime::SdlRuntime` ;
- la boucle limite provisoirement sa cadence avec `std::thread::sleep`.
### Runners Desktop
Les manifests existants sont étendus au lieu d'être remplacés.
Les runners utilisent les types réels :
- `game_reflex_poc::ReflexState` ;
- `game_snake_poc::SnakeState`.
Ils conservent également :
- `engine-v1-common` ;
- `engine-v1-platform-api` ;
- `game-logging-lib` ;
- `tracing` ;
- la désactivation explicite de la monétisation Desktop pour ce POC.
### Tests
Le test de configuration SDL3 reste sous `unit_tests/`.
Le glue de test sous `src/` ne contient aucun corps de test et référence explicitement le fichier externe conformément aux règles du workspace.
Le test utilise le helper de tracing commun.
## Vérifications effectuées avant livraison du fix
Dans l'environnement de génération :
```text
General Rust rule audit: clean
Rust export completeness audit: 0 candidate(s)
games.sasedev workspace audit: clean
Markdown table audit: clean (1 table(s), 39 file(s))
Cargo.toml parsing: clean
```
Les commandes Cargo finales restent volontairement à exécuter par l'utilisateur.
## Validation à exécuter par l'utilisateur
Ce fix modifie du code Rust :
```bash
cargo fmt --all
cargo fmt --all -- --check
python3 scripts/audit_rust_workspace_rules.py
python3 scripts/audit_markdown_tables.py README.md RULES.md ROADMAP.md CHANGELOG.md docs prompts crates Android deltas history
cargo check --workspace
cargo clippy --workspace --all-targets --all-features -- -D warnings
```
Tests ciblés :
```bash
cargo test -p engine-v1-sdl --all-targets --all-features
cargo test -p game-reflex-poc --all-targets --all-features
cargo test -p game-snake-poc --all-targets --all-features
```
Smokes Desktop interactifs :
```bash
cargo run -p game-reflex-poc-desktop
cargo run -p game-snake-poc-desktop
```
Pour chaque runner :
- une fenêtre SDL3 doit s'ouvrir ;
- `Escape` doit fermer proprement la fenêtre ;
- le bouton de fermeture système doit fermer proprement la fenêtre ;
- `Space` doit être capturé comme `GameAction::Primary` sans panic ;
- les événements de démarrage/arrêt doivent apparaître via `tracing`.
## Règle de transition
Si toutes ces validations sont propres, `0.1.0-0-pre.5.fix.1` est accepté et le travail passe automatiquement à `0.1.0-0-pre.6`.
Si une gate échoue, rester sur `0-pre.5` et produire `0.1.0-0-pre.5.fix.2`.