check self start #2

Open
opened 2026-04-06 04:26:34 +00:00 by despiegk · 4 comments
Owner

check start of

hero_claude_server
and hero_claude_ui

the server is python check we init the uv right, and make sure all is prepared
so we can run the server

put good health checks in mainly for server

use skill /hero_proc_service_selfstart

make sure that in 'make' file
we have make run
to start both components in right way through hero_claude (cmd line)

check start of hero_claude_server and hero_claude_ui the server is python check we init the uv right, and make sure all is prepared so we can run the server put good health checks in mainly for server use skill /hero_proc_service_selfstart make sure that in 'make' file we have make run to start both components in right way through hero_claude (cmd line)
Author
Owner

Implementation Spec — Issue #2: check self start

Objective

Harden the startup sequence for hero_claude_server (Python/uv) and hero_claude_ui (Rust) so that the system is reliably runnable via make run. Three sub-tasks:

  1. Fix Python env bootstrap: replace ad-hoc uv pip install with uv sync from the committed pyproject.toml/uv.lock
  2. Update the installed hero_claude_server wrapper to use uv run so it works without manual venv activation
  3. Forward ANTHROPIC_API_KEY to the server process via ActionBuilder::env() in hero_claude --start
  4. Add check-env guard to make run to fail fast if prerequisites are missing
  5. Add setup Makefile target; make install depend on it

Requirements

  • make run must reliably build, install, and start both components via hero_claude --start
  • Python venv created and populated using uv sync against committed pyproject.toml/uv.lock
  • Installed hero_claude_server shell wrapper must use uv run --project <dir> (no manual venv activation)
  • ANTHROPIC_API_KEY forwarded to hero_claude_server process via hero_proc action env
  • make run fails fast with clear error if ANTHROPIC_API_KEY unset or hero_proc not running
  • make setup target runs uv sync

Files to Modify

File Change
Makefile Add setup target; update install wrapper; add check-env guard; add comments
install.sh Replace uv pip install calls with uv sync
env.sh Add uv sync --quiet before venv activation
crates/hero_claude/src/main.rs Add ANTHROPIC_API_KEY env forwarding; add health check comment

Implementation Plan

Step 1 — Fix crates/hero_claude/src/main.rs

Files: crates/hero_claude/src/main.rs

  • Add .env("ANTHROPIC_API_KEY", std::env::var("ANTHROPIC_API_KEY").unwrap_or_default()) to server action builder
  • Add clarifying comment above server_action.health_checks block confirming hero_proc calls rpc.health
    Dependencies: none

Step 2 — Fix install.sh

Files: install.sh

  • Replace individual uv pip install calls with single uv sync
  • Remove install of packages not in pyproject.toml (anthropic, ipython)
    Dependencies: none

Step 3 — Fix env.sh

Files: env.sh

  • Add uv sync --quiet after uv venv so sourcing env.sh guarantees packages are installed
    Dependencies: none

Step 4 — Update Makefile

Files: Makefile

  • Add setup target that runs uv sync
  • Update install wrapper to use exec uv run --project $(CURDIR) python $(CURDIR)/crates/hero_claude_server/server.py
  • Add check-env guard that verifies ANTHROPIC_API_KEY is set and hero_proc socket exists
  • Make install depend on setup; make run depend on check-env
  • Add setup and check-env to .PHONY
    Dependencies: none

Acceptance Criteria

  • make setup runs uv sync successfully
  • make install depends on setup
  • Installed ~/hero/bin/hero_claude_server uses uv run --project
  • hero_claude --start with ANTHROPIC_API_KEY set → server process receives the key
  • make run fails fast if ANTHROPIC_API_KEY unset or hero_proc not running
  • After make run, both hero_claude_server and hero_claude_ui show as running in hero_proc
  • hero_claude health returns {"status": "ok", ...}
  • make stop terminates both cleanly
  • install.sh uses uv sync only (no uv pip install)
  • env.sh calls uv sync --quiet before activating venv

Notes

  • uv run --project $(CURDIR) points to repo root where pyproject.toml lives
  • exec uv run ... is critical so hero_proc's SIGTERM reaches Python directly
  • ANTHROPIC_API_KEY is captured at --start time; rotate key requires rerun of --start
  • rpc.health is already implemented in server.py — no server changes needed
# Implementation Spec — Issue #2: check self start ## Objective Harden the startup sequence for `hero_claude_server` (Python/uv) and `hero_claude_ui` (Rust) so that the system is reliably runnable via `make run`. Three sub-tasks: 1. Fix Python env bootstrap: replace ad-hoc `uv pip install` with `uv sync` from the committed `pyproject.toml`/`uv.lock` 2. Update the installed `hero_claude_server` wrapper to use `uv run` so it works without manual venv activation 3. Forward `ANTHROPIC_API_KEY` to the server process via `ActionBuilder::env()` in `hero_claude --start` 4. Add `check-env` guard to `make run` to fail fast if prerequisites are missing 5. Add `setup` Makefile target; make `install` depend on it ## Requirements - `make run` must reliably build, install, and start both components via `hero_claude --start` - Python venv created and populated using `uv sync` against committed `pyproject.toml`/`uv.lock` - Installed `hero_claude_server` shell wrapper must use `uv run --project <dir>` (no manual venv activation) - `ANTHROPIC_API_KEY` forwarded to `hero_claude_server` process via hero_proc action env - `make run` fails fast with clear error if `ANTHROPIC_API_KEY` unset or hero_proc not running - `make setup` target runs `uv sync` ## Files to Modify | File | Change | |------|--------| | `Makefile` | Add `setup` target; update `install` wrapper; add `check-env` guard; add comments | | `install.sh` | Replace `uv pip install` calls with `uv sync` | | `env.sh` | Add `uv sync --quiet` before venv activation | | `crates/hero_claude/src/main.rs` | Add `ANTHROPIC_API_KEY` env forwarding; add health check comment | ## Implementation Plan ### Step 1 — Fix `crates/hero_claude/src/main.rs` Files: `crates/hero_claude/src/main.rs` - Add `.env("ANTHROPIC_API_KEY", std::env::var("ANTHROPIC_API_KEY").unwrap_or_default())` to server action builder - Add clarifying comment above `server_action.health_checks` block confirming hero_proc calls `rpc.health` Dependencies: none ### Step 2 — Fix `install.sh` Files: `install.sh` - Replace individual `uv pip install` calls with single `uv sync` - Remove install of packages not in `pyproject.toml` (anthropic, ipython) Dependencies: none ### Step 3 — Fix `env.sh` Files: `env.sh` - Add `uv sync --quiet` after `uv venv` so sourcing env.sh guarantees packages are installed Dependencies: none ### Step 4 — Update `Makefile` Files: `Makefile` - Add `setup` target that runs `uv sync` - Update `install` wrapper to use `exec uv run --project $(CURDIR) python $(CURDIR)/crates/hero_claude_server/server.py` - Add `check-env` guard that verifies `ANTHROPIC_API_KEY` is set and hero_proc socket exists - Make `install` depend on `setup`; make `run` depend on `check-env` - Add `setup` and `check-env` to `.PHONY` Dependencies: none ## Acceptance Criteria - [ ] `make setup` runs `uv sync` successfully - [ ] `make install` depends on `setup` - [ ] Installed `~/hero/bin/hero_claude_server` uses `uv run --project` - [ ] `hero_claude --start` with `ANTHROPIC_API_KEY` set → server process receives the key - [ ] `make run` fails fast if `ANTHROPIC_API_KEY` unset or hero_proc not running - [ ] After `make run`, both `hero_claude_server` and `hero_claude_ui` show as `running` in hero_proc - [ ] `hero_claude health` returns `{"status": "ok", ...}` - [ ] `make stop` terminates both cleanly - [ ] `install.sh` uses `uv sync` only (no `uv pip install`) - [ ] `env.sh` calls `uv sync --quiet` before activating venv ## Notes - `uv run --project $(CURDIR)` points to repo root where `pyproject.toml` lives - `exec uv run ...` is critical so hero_proc's SIGTERM reaches Python directly - `ANTHROPIC_API_KEY` is captured at `--start` time; rotate key requires rerun of `--start` - `rpc.health` is already implemented in `server.py` — no server changes needed
Author
Owner

Test Results

  • Status: FAIL
  • Total: 0 run (compilation failed before tests could execute)
  • Passed: 0
  • Failed: 0 (build errors prevented test execution)

Build Errors Summary

The project failed to compile with 15 errors in hero_claude_examples. No tests were executed.

Errors in crates/hero_claude_examples/tests/integration.rs:

  1. E0599 as_deref() called on String (not Option<String>) — lines 184, 229, 240
    • Fix: use .as_ref() instead of .as_deref()
  2. E0277 Type mismatch: comparing bool with Option<bool> — line 201
    • removed.ok is a bool, not Option<bool>. Fix: assert!(removed.ok) or assert_eq!(removed.ok, true)
  3. E0308 Mismatched types: serde_json::json!({...}) passed where TaskSubmission expected — line 221
    • Fix: construct a TaskSubmission struct directly
  4. E0599 .expect() called on String (not Option<String>) — line 228
    • Fix: remove .expect() or change field type to Option<String>
  5. E0599 .unwrap_or(0) called on i64 (not Option<i64>) — line 247
    • Fix: remove .unwrap_or(0) since list.total is already an i64
  6. E0599 .unwrap_or_default() called on Vec<MetricPoint> (not Option<Vec<MetricPoint>>) — line 274
    • Fix: use metrics.items directly

Errors in crates/hero_claude_examples/examples/tasks.rs:

  1. E0599 as_deref() called on String (not Option<String>) — line 94
    • Fix: use .as_ref() instead of .as_deref()

Root Cause

The integration tests and examples were written expecting fields to be Option<T> types (e.g., Option<String>, Option<bool>, Option<i64>, Option<Vec<...>>), but the SDK structs define them as plain T types. Either the SDK structs need to wrap these fields in Option<>, or the test/example code needs to be updated to match the actual types.


Run on 2026-04-06 via Claude Code CI agent

## Test Results - **Status:** FAIL - **Total:** 0 run (compilation failed before tests could execute) - **Passed:** 0 - **Failed:** 0 (build errors prevented test execution) ### Build Errors Summary The project failed to compile with **15 errors** in `hero_claude_examples`. No tests were executed. #### Errors in `crates/hero_claude_examples/tests/integration.rs`: 1. **E0599** `as_deref()` called on `String` (not `Option<String>`) — lines 184, 229, 240 - Fix: use `.as_ref()` instead of `.as_deref()` 2. **E0277** Type mismatch: comparing `bool` with `Option<bool>` — line 201 - `removed.ok` is a `bool`, not `Option<bool>`. Fix: `assert!(removed.ok)` or `assert_eq!(removed.ok, true)` 3. **E0308** Mismatched types: `serde_json::json!({...})` passed where `TaskSubmission` expected — line 221 - Fix: construct a `TaskSubmission` struct directly 4. **E0599** `.expect()` called on `String` (not `Option<String>`) — line 228 - Fix: remove `.expect()` or change field type to `Option<String>` 5. **E0599** `.unwrap_or(0)` called on `i64` (not `Option<i64>`) — line 247 - Fix: remove `.unwrap_or(0)` since `list.total` is already an `i64` 6. **E0599** `.unwrap_or_default()` called on `Vec<MetricPoint>` (not `Option<Vec<MetricPoint>>`) — line 274 - Fix: use `metrics.items` directly #### Errors in `crates/hero_claude_examples/examples/tasks.rs`: 7. **E0599** `as_deref()` called on `String` (not `Option<String>`) — line 94 - Fix: use `.as_ref()` instead of `.as_deref()` #### Root Cause The integration tests and examples were written expecting fields to be `Option<T>` types (e.g., `Option<String>`, `Option<bool>`, `Option<i64>`, `Option<Vec<...>>`), but the SDK structs define them as plain `T` types. Either the SDK structs need to wrap these fields in `Option<>`, or the test/example code needs to be updated to match the actual types. --- *Run on 2026-04-06 via Claude Code CI agent*
Author
Owner

Test Results

  • Status: pass (compilation)
  • Unit tests: 0 (integration tests require live hero_proc + server)
  • Build errors fixed: 15 compile errors in integration.rs corrected to match actual SDK types

Fixes applied to integration.rs

  • pong.ok / removed.ok: Option<bool>bool
  • pong.service: Option<String>String
  • h.status: Option<String>String (removed .as_deref().unwrap_or())
  • h.uptime_seconds: Option<i64>i64
  • reg.agent_id: Option<String>String (removed .expect())
  • list.total / sub.task_id / info.task_id: removed Option wrappers
  • AcpAgentRegisterInput: replaced serde_json::json! with AgentRegistration { .. } struct
  • AcpTaskSubmitInput: replaced serde_json::json! with TaskSubmission { .. } struct
  • metrics.items: Option<Vec<_>>Vec<_> (removed .unwrap_or_default())

cargo check and cargo test --lib pass cleanly.

## Test Results - Status: **pass** (compilation) - Unit tests: 0 (integration tests require live hero_proc + server) - Build errors fixed: 15 compile errors in `integration.rs` corrected to match actual SDK types ### Fixes applied to `integration.rs` - `pong.ok` / `removed.ok`: `Option<bool>` → `bool` - `pong.service`: `Option<String>` → `String` - `h.status`: `Option<String>` → `String` (removed `.as_deref().unwrap_or()`) - `h.uptime_seconds`: `Option<i64>` → `i64` - `reg.agent_id`: `Option<String>` → `String` (removed `.expect()`) - `list.total` / `sub.task_id` / `info.task_id`: removed `Option` wrappers - `AcpAgentRegisterInput`: replaced `serde_json::json!` with `AgentRegistration { .. }` struct - `AcpTaskSubmitInput`: replaced `serde_json::json!` with `TaskSubmission { .. }` struct - `metrics.items`: `Option<Vec<_>>` → `Vec<_>` (removed `.unwrap_or_default()`) `cargo check` and `cargo test --lib` pass cleanly.
Author
Owner

Implementation Summary

Changes Made

install.sh

  • Replaced 4 individual uv pip install calls with single uv sync
  • Removed packages not in pyproject.toml (anthropic, ipython were being installed ad-hoc)
  • Added uv run python --version confirmation step

env.sh

  • Added uv sync --quiet after venv creation so sourcing env.sh guarantees dependencies are installed

Makefile

  • Added setup target (uv sync) for explicit Python env setup
  • install now depends on setup
  • Updated hero_claude_server shell wrapper to use exec uv run --project $(CURDIR) python ... — eliminates manual venv activation, exec ensures SIGTERM reaches Python directly
  • Simplified run target: just calls hero_claude --start (no env guard in Makefile — the SDK handles process management)

crates/hero_claude/src/main.rs

  • Added conditional ANTHROPIC_API_KEY forwarding: forwarded to server process only if set in environment; otherwise Claude Max OAuth is used
  • Added clarifying comment above health check config confirming hero_proc calls rpc.health

crates/hero_claude_examples/tests/integration.rs

  • Fixed 15 compile errors: all field types updated to match actual generated SDK structs (bool not Option<bool>, String not Option<String>, i64 not Option<i64>, Vec<_> not Option<Vec<_>>)
  • AcpAgentRegisterInput now uses proper AgentRegistration { .. } struct
  • AcpTaskSubmitInput now uses proper TaskSubmission { .. } struct

Build Status

cargo check and cargo test --lib pass cleanly.

## Implementation Summary ### Changes Made **`install.sh`** - Replaced 4 individual `uv pip install` calls with single `uv sync` - Removed packages not in `pyproject.toml` (anthropic, ipython were being installed ad-hoc) - Added `uv run python --version` confirmation step **`env.sh`** - Added `uv sync --quiet` after venv creation so sourcing `env.sh` guarantees dependencies are installed **`Makefile`** - Added `setup` target (`uv sync`) for explicit Python env setup - `install` now depends on `setup` - Updated `hero_claude_server` shell wrapper to use `exec uv run --project $(CURDIR) python ...` — eliminates manual venv activation, `exec` ensures SIGTERM reaches Python directly - Simplified `run` target: just calls `hero_claude --start` (no env guard in Makefile — the SDK handles process management) **`crates/hero_claude/src/main.rs`** - Added conditional `ANTHROPIC_API_KEY` forwarding: forwarded to server process only if set in environment; otherwise Claude Max OAuth is used - Added clarifying comment above health check config confirming hero_proc calls `rpc.health` **`crates/hero_claude_examples/tests/integration.rs`** - Fixed 15 compile errors: all field types updated to match actual generated SDK structs (`bool` not `Option<bool>`, `String` not `Option<String>`, `i64` not `Option<i64>`, `Vec<_>` not `Option<Vec<_>>`) - `AcpAgentRegisterInput` now uses proper `AgentRegistration { .. }` struct - `AcpTaskSubmitInput` now uses proper `TaskSubmission { .. }` struct ### Build Status `cargo check` and `cargo test --lib` pass cleanly.
Sign in to join this conversation.
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_claude#2
No description provided.