v0.1.0-pre.020
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# file: kb-config/Cargo.toml
|
||||
# version: 1
|
||||
# version: 2
|
||||
|
||||
[package]
|
||||
name = "kb-config"
|
||||
@@ -10,6 +10,10 @@ publish.workspace = true
|
||||
|
||||
[dependencies]
|
||||
kb-core = { path = "../kb-core" }
|
||||
jsonschema.workspace = true
|
||||
serde.workspace = true
|
||||
serde_json.workspace = true
|
||||
ts-rs.workspace = true
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
||||
68
kb-config/README.md
Normal file
68
kb-config/README.md
Normal file
@@ -0,0 +1,68 @@
|
||||
<!-- file: kb-config/README.md -->
|
||||
<!-- version: 6 -->
|
||||
|
||||
# kb-config
|
||||
|
||||
Ce crate définit le contrat de configuration commun du workspace.
|
||||
|
||||
## Rôle dans l'écosystème
|
||||
|
||||
`kb-config` charge, valide et sérialise un fichier JSON contenant plusieurs profils. Un seul profil est actif à l'exécution grâce au champ `active_profile`.
|
||||
|
||||
Le crate fournit les structures typées runtime pour :
|
||||
|
||||
- l'application et l'environnement ;
|
||||
- les sorties de logs console, fichier humain, fichier JSON et fichier erreurs ;
|
||||
- les filtres de targets `tracing` ;
|
||||
- les stores PostgreSQL et SQLite ;
|
||||
- les endpoints HTTP JSON-RPC et WebSocket Solana ;
|
||||
- les rôles et limites par endpoint ;
|
||||
- les listeners Solana standards ;
|
||||
- le wallet temporaire géré par profil ;
|
||||
- les permissions d'envoi localnet/devnet/testnet/mainnet ;
|
||||
- les plafonds de dépense, frais, priorité et fraîcheur du blockhash ;
|
||||
- les pages de démonstration Tauri.
|
||||
|
||||
## Wallet temporaire
|
||||
|
||||
Le profil `local_devnet` active un wallet persistant de laboratoire sous :
|
||||
|
||||
```text
|
||||
wallets/temporary/local_devnet/local-devnet-operator.json
|
||||
```
|
||||
|
||||
Les profils mainnet conservent `temporary_wallet_enabled = false`. La validation typée refuse un wallet temporaire actif sur `mainnet-beta`, une persistance sans activation et les alias pouvant produire un chemin arbitraire.
|
||||
|
||||
## Exécution
|
||||
|
||||
La configuration sépare :
|
||||
|
||||
- le dry-run par défaut ;
|
||||
- l'obligation de simulation ;
|
||||
- la confirmation opérateur ;
|
||||
- les plafonds de dépense localnet, devnet, testnet et mainnet ;
|
||||
- le plafond de frais ;
|
||||
- le plafond de prix par compute unit ;
|
||||
- l'âge maximal du recent blockhash.
|
||||
|
||||
Un cluster dont l'envoi est activé doit disposer d'un plafond de dépense positif. Toute dépense configurée exige la simulation et toute dépense mainnet exige la confirmation opérateur. Les paramètres de confirmation sont bornés et le plafond d’airdrop Devnet est interdit dans les profils d’un autre cluster.
|
||||
|
||||
## Validation
|
||||
|
||||
La validation se fait en deux étapes :
|
||||
|
||||
1. validation JSON brute via `config/schema.config.json` et `jsonschema` ;
|
||||
2. validation typée après désérialisation Rust.
|
||||
|
||||
## Secrets et placeholders
|
||||
|
||||
Le fichier versionné doit rester sans secret. Les placeholders restent directement dans les URLs. Les keypairs générés par `kb_wallet` vivent hors du fichier de configuration et sous un répertoire ignoré par Git.
|
||||
|
||||
## Exports TS-rs
|
||||
|
||||
Les structures exposées à Tauri utilisent `TS` avec un chemin `export_to` explicite. Les fichiers générés servent uniquement au partage des types Rust/TypeScript et ne remplacent pas le schéma JSON runtime.
|
||||
|
||||
```bash
|
||||
cargo test export_bindings -p kb-config
|
||||
cargo test -p kb-config settings::tests::
|
||||
```
|
||||
@@ -1,23 +1,70 @@
|
||||
// file: kb-config/src/lib.rs
|
||||
// version: 1
|
||||
// version: 3
|
||||
|
||||
#![forbid(unsafe_code)]
|
||||
#![deny(unreachable_pub)]
|
||||
//! Khadhroony Bot3 workspace configuration contract and loading helpers.
|
||||
#![warn(missing_docs)]
|
||||
#![deny(unreachable_pub)]
|
||||
#![forbid(unsafe_code)]
|
||||
|
||||
//! Configuration contracts for Khadhroony Bot3.
|
||||
mod settings;
|
||||
|
||||
/// Minimal application configuration used during the migration.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct AppConfig {
|
||||
/// Active profile name.
|
||||
pub active_profile: std::string::String,
|
||||
}
|
||||
|
||||
impl std::default::Default for AppConfig {
|
||||
fn default() -> Self {
|
||||
return Self {
|
||||
active_profile: std::string::String::from("development"),
|
||||
};
|
||||
}
|
||||
}
|
||||
/// Exposes the account listener configuration type.
|
||||
pub use self::settings::AccountListenerConfig;
|
||||
/// Exposes the root application configuration type.
|
||||
pub use self::settings::AppConfig;
|
||||
/// Exposes the application section configuration type.
|
||||
pub use self::settings::AppSectionConfig;
|
||||
/// Exposes the local data configuration type.
|
||||
pub use self::settings::DataConfig;
|
||||
/// Exposes the database configuration type.
|
||||
pub use self::settings::DatabaseConfig;
|
||||
/// Exposes the demo application configuration type.
|
||||
pub use self::settings::DemoConfig;
|
||||
/// Exposes the endpoint role configuration type.
|
||||
pub use self::settings::EndpointRoleConfig;
|
||||
/// Exposes the execution configuration type.
|
||||
pub use self::settings::ExecutionConfig;
|
||||
/// Exposes the HTTP endpoint configuration type.
|
||||
pub use self::settings::HttpEndpointConfig;
|
||||
/// Exposes the listener configuration type.
|
||||
pub use self::settings::ListenerConfig;
|
||||
/// Exposes the log listener configuration type.
|
||||
pub use self::settings::LogListenerConfig;
|
||||
/// Exposes the logging target configuration type.
|
||||
pub use self::settings::LogTargetConfig;
|
||||
/// Exposes the logging target filter configuration type.
|
||||
pub use self::settings::LogTargetFilterConfig;
|
||||
/// Exposes the logging configuration type.
|
||||
pub use self::settings::LoggingConfig;
|
||||
/// Exposes the PostgreSQL configuration type.
|
||||
pub use self::settings::PostgresConfig;
|
||||
/// Exposes the profile configuration type.
|
||||
pub use self::settings::ProfileConfig;
|
||||
/// Exposes the program listener configuration type.
|
||||
pub use self::settings::ProgramListenerConfig;
|
||||
/// Exposes the Solana configuration type.
|
||||
pub use self::settings::SolanaConfig;
|
||||
/// Exposes the SQLite configuration type.
|
||||
pub use self::settings::SqliteConfig;
|
||||
/// Exposes the wallet configuration type.
|
||||
pub use self::settings::WalletConfig;
|
||||
/// Exposes the WebSocket endpoint configuration type.
|
||||
pub use self::settings::WsEndpointConfig;
|
||||
/// Exposes the active profile resolver.
|
||||
pub use self::settings::active_profile;
|
||||
/// Exposes the embedded JSON Schema text.
|
||||
pub use self::settings::config_json_schema_text;
|
||||
/// Exposes the embedded JSON Schema value parser.
|
||||
pub use self::settings::config_json_schema_value;
|
||||
/// Exposes the configuration parser from a JSON string.
|
||||
pub use self::settings::parse_config_json;
|
||||
/// Exposes the configuration loader from a filesystem path.
|
||||
pub use self::settings::read_config_json_file;
|
||||
/// Exposes the compact JSON serializer for configuration values.
|
||||
pub use self::settings::serialize_config_json;
|
||||
/// Exposes the pretty JSON serializer for configuration values.
|
||||
pub use self::settings::serialize_config_json_pretty;
|
||||
/// Exposes the typed configuration validator.
|
||||
pub use self::settings::validate_config;
|
||||
/// Exposes the JSON Schema validator for raw JSON configuration.
|
||||
pub use self::settings::validate_config_json_schema;
|
||||
|
||||
1530
kb-config/src/settings.rs
Normal file
1530
kb-config/src/settings.rs
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user