check and fix #9

Open
opened 2026-03-21 04:09:11 +00:00 by despiegk · 3 comments
Owner

first check /code_manage_development_branch

then make sure that we have $servicename_ui and $servicename
the last one is the cli which uses the $servicename_sdk

check all carrefully and fix what needs to be fixed

check /hero_proc_service_selfstart
and that we cleanly start in makefile

can always learn from e.g. ../hero_redis

first check /code_manage_development_branch then make sure that we have $servicename_ui and $servicename the last one is the cli which uses the $servicename_sdk check all carrefully and fix what needs to be fixed check /hero_proc_service_selfstart and that we cleanly start in makefile can always learn from e.g. ../hero_redis
Author
Owner

Implementation Spec for Issue #9 — "check and fix"

Objective

Restructure hero_auth to match the canonical Hero service pattern as demonstrated by hero_redis:

  1. Convert to a workspace with multiple crates.
  2. Produce the correct set of binaries: hero_auth_server (the daemon), hero_auth_ui (web admin UI binary), and hero_auth (the CLI that uses the SDK).
  3. Add a hero_auth_sdk crate (Rust client library for the auth service).
  4. Ensure every binary uses the self-start/self-stop pattern (serve, start, stop, run, status, logs subcommands).
  5. Fix the Makefile so start, stop, run, restart, logs, status targets work cleanly.

Current State

Item Status
Single crate, not a workspace Single Cargo.toml at root, one binary
Binary name hero_auth_server (correct for server)
Self-start/stop HeroUiServer::run() used — lifecycle subcommands already handled
hero_auth_ui binary Missing
hero_auth_sdk crate Missing
hero_auth CLI binary Missing
Makefile start/stop/run/logs targets Missing

Requirements

  1. Convert hero_auth to a Cargo workspace with crates:
    • crates/hero_auth — core library (config, crypto, state, oauth logic, rpc handlers)
    • crates/hero_auth_server — backend daemon binary (JSON-RPC on Unix socket)
    • crates/hero_auth_ui — web admin UI binary (HTML dashboard on separate Unix socket)
    • crates/hero_auth_sdk — Rust client library for talking to hero_auth_server
    • crates/hero_auth_cli — CLI binary (binary name: hero_auth), uses SDK
  2. Each binary implements the HeroLifecycle pattern: serve, start, stop, run, status, logs
  3. buildenv.sh must list all installable binaries: hero_auth_server hero_auth_ui hero_auth
  4. Makefile must add start, stop, restart, logs, logs-ui, status targets

Files to Modify / Create

  • /Volumes/T7/code0/hero_auth/Cargo.toml — Replace with workspace definition
  • /Volumes/T7/code0/hero_auth/src/ → move to crates/hero_auth/src/ (core lib)
  • /Volumes/T7/code0/hero_auth/crates/hero_auth_server/ — New: server binary
  • /Volumes/T7/code0/hero_auth/crates/hero_auth_sdk/ — New: client SDK
  • /Volumes/T7/code0/hero_auth/crates/hero_auth_ui/ — New: web UI binary
  • /Volumes/T7/code0/hero_auth/crates/hero_auth_cli/ — New: CLI binary (name: hero_auth)
  • /Volumes/T7/code0/hero_auth/buildenv.sh — Update BINARIES
  • /Volumes/T7/code0/hero_auth/Makefile — Add service management targets, update to --workspace

Implementation Plan

Step 1: Workspace Conversion

Files: Cargo.toml, crates/hero_auth/

  • Create crates/hero_auth/ library crate (move src/ into it, add lib.rs)
  • Replace root Cargo.toml with workspace definition
  • Dependencies: None

Step 2: Server Crate

Files: crates/hero_auth_server/

  • Create crates/hero_auth_server/ crate depending on core lib
  • Move current src/main.rs logic here
  • Use explicit Lifecycle + Serve subcommand pattern (like hero_redis_server)
  • Dependencies: Step 1

Step 3: SDK Crate

Files: crates/hero_auth_sdk/

  • Create HeroAuthClient with Unix socket HTTP transport
  • Methods: validate(), health(), users_list()
  • Dependencies: Step 1

Step 4: UI Crate

Files: crates/hero_auth_ui/

  • Move HTML/template handler logic out of core lib into UI crate
  • UI axum router proxies RPC to hero_auth_server via SDK
  • Standard lifecycle CLI pattern
  • Binds to ~/hero/var/sockets/hero_auth_ui.sock
  • Dependencies: Steps 1, 3

Step 5: CLI Crate

Files: crates/hero_auth_cli/

  • Binary name: hero_auth
  • Subcommands: health, users list, validate <token>, start, stop
  • Uses hero_auth_sdk
  • Dependencies: Steps 1, 3

Step 6: Build System

Files: buildenv.sh, Makefile

  • Update BINARIES="hero_auth_server hero_auth_ui hero_auth"
  • Add start, stop, restart, run, status, logs, logs-ui targets
  • Update build/check/test/fmt to use --workspace
  • Dependencies: Steps 1–5

Acceptance Criteria

  • make build produces hero_auth_server, hero_auth_ui, and hero_auth binaries
  • make install / make installdev installs all three to ~/hero/bin/
  • hero_auth_server start registers and starts via hero_proc
  • hero_auth_server stop cleanly stops it
  • hero_auth_ui start registers and starts via hero_proc
  • hero_auth health returns successful health check
  • make start starts both server and UI
  • make stop stops both cleanly
  • make run starts server in foreground (streaming logs)
  • make status reports hero_proc status for both services
  • cargo check --workspace passes

Notes

  • Reference implementation: /Volumes/T7/code0/hero_redis/
  • The hero_auth_ui binary should serve on a separate Unix socket (hero_auth_ui.sock)
  • Keep templates under the UI crate, not the core library
  • buildenv.sh BINARIES change is load-bearing for install_binaries in build_lib.sh
## Implementation Spec for Issue #9 — "check and fix" ### Objective Restructure `hero_auth` to match the canonical Hero service pattern as demonstrated by `hero_redis`: 1. Convert to a **workspace** with multiple crates. 2. Produce the correct set of binaries: `hero_auth_server` (the daemon), `hero_auth_ui` (web admin UI binary), and `hero_auth` (the CLI that uses the SDK). 3. Add a `hero_auth_sdk` crate (Rust client library for the auth service). 4. Ensure every binary uses the self-start/self-stop pattern (`serve`, `start`, `stop`, `run`, `status`, `logs` subcommands). 5. Fix the Makefile so `start`, `stop`, `run`, `restart`, `logs`, `status` targets work cleanly. --- ### Current State | Item | Status | |---|---| | Single crate, not a workspace | Single `Cargo.toml` at root, one binary | | Binary name | `hero_auth_server` (correct for server) | | Self-start/stop | `HeroUiServer::run()` used — lifecycle subcommands already handled | | `hero_auth_ui` binary | **Missing** | | `hero_auth_sdk` crate | **Missing** | | `hero_auth` CLI binary | **Missing** | | Makefile `start`/`stop`/`run`/`logs` targets | **Missing** | --- ### Requirements 1. Convert `hero_auth` to a Cargo workspace with crates: - `crates/hero_auth` — core library (config, crypto, state, oauth logic, rpc handlers) - `crates/hero_auth_server` — backend daemon binary (JSON-RPC on Unix socket) - `crates/hero_auth_ui` — web admin UI binary (HTML dashboard on separate Unix socket) - `crates/hero_auth_sdk` — Rust client library for talking to `hero_auth_server` - `crates/hero_auth_cli` — CLI binary (binary name: `hero_auth`), uses SDK 2. Each binary implements the `HeroLifecycle` pattern: `serve`, `start`, `stop`, `run`, `status`, `logs` 3. `buildenv.sh` must list all installable binaries: `hero_auth_server hero_auth_ui hero_auth` 4. Makefile must add `start`, `stop`, `restart`, `logs`, `logs-ui`, `status` targets --- ### Files to Modify / Create - `/Volumes/T7/code0/hero_auth/Cargo.toml` — Replace with workspace definition - `/Volumes/T7/code0/hero_auth/src/` → move to `crates/hero_auth/src/` (core lib) - `/Volumes/T7/code0/hero_auth/crates/hero_auth_server/` — New: server binary - `/Volumes/T7/code0/hero_auth/crates/hero_auth_sdk/` — New: client SDK - `/Volumes/T7/code0/hero_auth/crates/hero_auth_ui/` — New: web UI binary - `/Volumes/T7/code0/hero_auth/crates/hero_auth_cli/` — New: CLI binary (name: `hero_auth`) - `/Volumes/T7/code0/hero_auth/buildenv.sh` — Update BINARIES - `/Volumes/T7/code0/hero_auth/Makefile` — Add service management targets, update to `--workspace` --- ### Implementation Plan #### Step 1: Workspace Conversion Files: `Cargo.toml`, `crates/hero_auth/` - Create `crates/hero_auth/` library crate (move `src/` into it, add `lib.rs`) - Replace root `Cargo.toml` with workspace definition - Dependencies: None #### Step 2: Server Crate Files: `crates/hero_auth_server/` - Create `crates/hero_auth_server/` crate depending on core lib - Move current `src/main.rs` logic here - Use explicit `Lifecycle + Serve` subcommand pattern (like hero_redis_server) - Dependencies: Step 1 #### Step 3: SDK Crate Files: `crates/hero_auth_sdk/` - Create `HeroAuthClient` with Unix socket HTTP transport - Methods: `validate()`, `health()`, `users_list()` - Dependencies: Step 1 #### Step 4: UI Crate Files: `crates/hero_auth_ui/` - Move HTML/template handler logic out of core lib into UI crate - UI axum router proxies RPC to `hero_auth_server` via SDK - Standard lifecycle CLI pattern - Binds to `~/hero/var/sockets/hero_auth_ui.sock` - Dependencies: Steps 1, 3 #### Step 5: CLI Crate Files: `crates/hero_auth_cli/` - Binary name: `hero_auth` - Subcommands: `health`, `users list`, `validate <token>`, `start`, `stop` - Uses `hero_auth_sdk` - Dependencies: Steps 1, 3 #### Step 6: Build System Files: `buildenv.sh`, `Makefile` - Update `BINARIES="hero_auth_server hero_auth_ui hero_auth"` - Add `start`, `stop`, `restart`, `run`, `status`, `logs`, `logs-ui` targets - Update `build`/`check`/`test`/`fmt` to use `--workspace` - Dependencies: Steps 1–5 --- ### Acceptance Criteria - [ ] `make build` produces `hero_auth_server`, `hero_auth_ui`, and `hero_auth` binaries - [ ] `make install` / `make installdev` installs all three to `~/hero/bin/` - [ ] `hero_auth_server start` registers and starts via hero_proc - [ ] `hero_auth_server stop` cleanly stops it - [ ] `hero_auth_ui start` registers and starts via hero_proc - [ ] `hero_auth health` returns successful health check - [ ] `make start` starts both server and UI - [ ] `make stop` stops both cleanly - [ ] `make run` starts server in foreground (streaming logs) - [ ] `make status` reports hero_proc status for both services - [ ] `cargo check --workspace` passes --- ### Notes - Reference implementation: `/Volumes/T7/code0/hero_redis/` - The `hero_auth_ui` binary should serve on a **separate** Unix socket (`hero_auth_ui.sock`) - Keep templates under the UI crate, not the core library - `buildenv.sh` BINARIES change is load-bearing for `install_binaries` in `build_lib.sh`
Author
Owner

Test Results

cargo check --workspace

PASS — no errors or warnings

cargo test --workspace

  • Status: PASS
  • 4 tests passed, 0 failed, 1 ignored across 11 test suites
  • All test suites reported test result: ok
test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s
test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s
## Test Results ### cargo check --workspace PASS — no errors or warnings ### cargo test --workspace - Status: PASS - 4 tests passed, 0 failed, 1 ignored across 11 test suites - All test suites reported `test result: ok` ``` test result: ok. 4 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 0.00s test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 0.00s ```
Author
Owner

Implementation Complete ✓

Changes Made

Workspace conversion — converted single-crate project to a Cargo workspace with 5 crates:

Crate Binary Purpose
crates/hero_auth — (library) Core logic: config, crypto, state, oauth, rpc handlers
crates/hero_auth_server hero_auth_server Backend daemon on Unix socket (hero_auth_server.sock)
crates/hero_auth_sdk — (library) Rust client SDK for talking to the server over Unix socket
crates/hero_auth_ui hero_auth_ui Web admin dashboard on separate Unix socket (hero_auth_ui.sock)
crates/hero_auth_cli hero_auth CLI that uses the SDK for health/validate/users commands

Self-start/stop patternhero_auth_server and hero_auth_ui both implement HeroLifecycle with serve, start, stop, run, status, logs subcommands.

Makefile — added start, stop, restart, status, logs, logs-ui targets; updated build, check, test, fmt, lint to use --workspace.

buildenv.sh — updated BINARIES="hero_auth_server hero_auth_ui hero_auth" so make install installs all three binaries to ~/hero/bin/.

Test Results

  • cargo check --workspace: ✓ PASS
  • cargo test --workspace: ✓ PASS (4 tests, 0 failures)

Usage

make start        # Start both server and UI via hero_proc
make stop         # Stop both
make restart      # Restart both
make status       # Check hero_proc status for both
make logs         # Stream server logs
make logs-ui      # Stream UI logs
make run          # Foreground run (Ctrl-C to stop)
make rundev       # Direct debug run (no hero_proc)

hero_auth health             # Check server health
hero_auth users list         # List users
hero_auth validate <token>   # Validate a JWT token
## Implementation Complete ✓ ### Changes Made **Workspace conversion** — converted single-crate project to a Cargo workspace with 5 crates: | Crate | Binary | Purpose | |---|---|---| | `crates/hero_auth` | — (library) | Core logic: config, crypto, state, oauth, rpc handlers | | `crates/hero_auth_server` | `hero_auth_server` | Backend daemon on Unix socket (`hero_auth_server.sock`) | | `crates/hero_auth_sdk` | — (library) | Rust client SDK for talking to the server over Unix socket | | `crates/hero_auth_ui` | `hero_auth_ui` | Web admin dashboard on separate Unix socket (`hero_auth_ui.sock`) | | `crates/hero_auth_cli` | `hero_auth` | CLI that uses the SDK for health/validate/users commands | **Self-start/stop pattern** — `hero_auth_server` and `hero_auth_ui` both implement `HeroLifecycle` with `serve`, `start`, `stop`, `run`, `status`, `logs` subcommands. **Makefile** — added `start`, `stop`, `restart`, `status`, `logs`, `logs-ui` targets; updated `build`, `check`, `test`, `fmt`, `lint` to use `--workspace`. **buildenv.sh** — updated `BINARIES="hero_auth_server hero_auth_ui hero_auth"` so `make install` installs all three binaries to `~/hero/bin/`. ### Test Results - `cargo check --workspace`: ✓ PASS - `cargo test --workspace`: ✓ PASS (4 tests, 0 failures) ### Usage ```bash make start # Start both server and UI via hero_proc make stop # Stop both make restart # Restart both make status # Check hero_proc status for both make logs # Stream server logs make logs-ui # Stream UI logs make run # Foreground run (Ctrl-C to stop) make rundev # Direct debug run (no hero_proc) hero_auth health # Check server health hero_auth users list # List users hero_auth validate <token> # Validate a JWT token ```
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_auth#9
No description provided.