- Workspace root uses
Cargo.tomlwith shared dependencies; build artifacts live undertarget/. crates/common: shared data types and constants (e.g.,Heartbeat,HB_SUBJECT_PREFIX).crates/worker: Actix-based worker binary that connects to NATS/JetStream, sends heartbeats, and serves/pingand/metrics; configuration defaults fromworker.tomlandKAGAMI_*env vars.crates/supervisor: starting point for coordination logic; currently a minimal crate with sample tests.worker.tomlserves as a local template for provider lists and optionalnats_url.
cargo build --workspace— compile all crates.cargo fmt --all— format with rustfmt defaults.cargo clippy --workspace --all-targets --all-features— lint; fix warnings before submitting.cargo test --workspace— run unit/integration tests across crates.cargo run -p worker— start the worker; override config withKAGAMI_NATS_URLor editworker.toml.
- Rust 2024 edition; keep imports ordered, 4-space indentation, and rely on
cargo fmt. - Prefer
snake_casefor functions/modules,PascalCasefor types, andSCREAMING_SNAKE_CASEfor constants. - Use
tracingfor structured logs andanyhowfor error contexts; propagate errors instead of panicking in async paths. - Keep shared types in
crates/common; avoid duplicating heartbeat schema elsewhere.
- Co-locate unit tests with modules via
#[cfg(test)] mod testsor add integration tests undertests/. - Use descriptive test names (
publishes_heartbeat_on_interval) and table-driven cases when feasible. - For async/actor code, use
#[actix_rt::test]or spawn test runtimes explicitly to avoid timer flakiness. - Add tests when touching message handling, NATS publishing, or metrics endpoints; ensure
cargo test --workspacepasses.
- No established history yet; follow Conventional Commits (e.g.,
feat: add worker heartbeat metrics) with imperative, ≤72-char subjects. - Keep PRs focused; include a short summary, manual test commands executed, and linked issues/tasks.
- Call out config changes (
worker.toml, env expectations), breaking behavior, and any required NATS/local stack steps. - Add screenshots or logs when modifying HTTP endpoints or metrics output for easier review.
- Default config reads
worker.toml; environment overrides use theKAGAMI_prefix (KAGAMI_PROVIDERS,KAGAMI_NATS_URL). - The worker listens on
0.0.0.0:8080; ensure NATS is reachable before running locally. - Do not commit secrets or host-specific settings; keep local overrides in untracked files.