feat(supervisor): auto-start hero_db on hero_proc startup #99

Merged
ashraf merged 1 commit from development_auto_start_hero_db into development 2026-05-10 18:09:37 +00:00
Member

Summary

  • hero_proc_server now ensures the hero_db service (context core) is up at startup. Idempotent, honours operator intent, surfaces a clear error to the logs DB when hero_db is not registered, and can be opted out of via HERO_PROC_NO_AUTOSTART_DB=1.

Closes #95

Changes

  • crates/hero_proc_server/src/supervisor/auto_start_db.rs (new): ensure_hero_db_autostart(&Supervisor) plus a pure decide_action(db, env_opt_out) -> Option<HeroDbState> for testability. Branches: NotRegistered (error log), NotStartIntent (warn), AlreadyActive (no-op), NeedsStart (calls autostart_one_service).
  • crates/hero_proc_server/src/supervisor/mod.rs: pub mod auto_start_db;, widened autostart_one_service to pub(crate), inserted auto_start_db::ensure_hero_db_autostart(&self).await; in Supervisor::run() after autostart_services() and before autostart_process_jobs().
  • crates/hero_proc_integration_test/tests/hero_db_autostart.rs (new): 2 end-to-end tests — happy path (registered + start → job dispatched) and missing-registration path (no hero_db row → error log entry with source hero_proc.auto_start_db).
  • crates/hero_proc_integration_test/src/harness.rs: added start_with_seed<F>(seed: F) so integration tests can pre-seed the DB after the harness wipes it. Also added a CARGO_TARGET_DIR / .cargo/config.toml lookup branch so the harness picks up the freshly-built binary instead of a stale one on PATH.
  • crates/hero_proc_server/CLAUDE.md: short paragraph noting where the policy lives and that it is additive and non-panicking.

Test Results

cargo test --workspace --no-fail-fast -- --test-threads=1:

  • Total: 411
  • Passed: 410
  • Failed: 1 (pre-existing, unrelated: hero_proc_lib::db::integration_tests::tests::logging_api_end_to_end_filters_and_cleanup — reproduces on clean development)
  • Ignored: 52

7 new tests in this branch, all passing:

  • 5 unit tests in supervisor::auto_start_db::tests covering every branch of decide_action.
  • 2 integration tests in hero_db_autostart covering the happy path and the missing-registration error log.
## Summary - `hero_proc_server` now ensures the `hero_db` service (context `core`) is up at startup. Idempotent, honours operator intent, surfaces a clear error to the logs DB when `hero_db` is not registered, and can be opted out of via `HERO_PROC_NO_AUTOSTART_DB=1`. ## Related Issue Closes https://forge.ourworld.tf/lhumina_code/hero_proc/issues/95 ## Changes - `crates/hero_proc_server/src/supervisor/auto_start_db.rs` (new): `ensure_hero_db_autostart(&Supervisor)` plus a pure `decide_action(db, env_opt_out) -> Option<HeroDbState>` for testability. Branches: NotRegistered (error log), NotStartIntent (warn), AlreadyActive (no-op), NeedsStart (calls `autostart_one_service`). - `crates/hero_proc_server/src/supervisor/mod.rs`: `pub mod auto_start_db;`, widened `autostart_one_service` to `pub(crate)`, inserted `auto_start_db::ensure_hero_db_autostart(&self).await;` in `Supervisor::run()` after `autostart_services()` and before `autostart_process_jobs()`. - `crates/hero_proc_integration_test/tests/hero_db_autostart.rs` (new): 2 end-to-end tests — happy path (registered + start → job dispatched) and missing-registration path (no `hero_db` row → error log entry with source `hero_proc.auto_start_db`). - `crates/hero_proc_integration_test/src/harness.rs`: added `start_with_seed<F>(seed: F)` so integration tests can pre-seed the DB after the harness wipes it. Also added a `CARGO_TARGET_DIR` / `.cargo/config.toml` lookup branch so the harness picks up the freshly-built binary instead of a stale one on `PATH`. - `crates/hero_proc_server/CLAUDE.md`: short paragraph noting where the policy lives and that it is additive and non-panicking. ## Test Results `cargo test --workspace --no-fail-fast -- --test-threads=1`: - Total: 411 - Passed: 410 - Failed: 1 (pre-existing, unrelated: `hero_proc_lib::db::integration_tests::tests::logging_api_end_to_end_filters_and_cleanup` — reproduces on clean `development`) - Ignored: 52 7 new tests in this branch, all passing: - 5 unit tests in `supervisor::auto_start_db::tests` covering every branch of `decide_action`. - 2 integration tests in `hero_db_autostart` covering the happy path and the missing-registration error log.
feat(supervisor): auto-start hero_db on hero_proc startup
Some checks failed
Build and Test / build (pull_request) Failing after 2s
Tests / test (pull_request) Failing after 2s
Tests / test (push) Failing after 2s
Build and Test / build (push) Failing after 3s
c966f3d1db
Ensure the canonical hero_db service (context "core") is brought up by
the supervisor on startup. Idempotent against an already-running
hero_db, surfaces a clear error to logs DB when not registered, honours
operator intent on non-start statuses, and can be opted out of via
HERO_PROC_NO_AUTOSTART_DB=1.

#95
ashraf merged commit c966f3d1db into development 2026-05-10 18:09:37 +00:00
ashraf deleted branch development_auto_start_hero_db 2026-05-10 18:09:37 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
lhumina_code/hero_proc!99
No description provided.