refactor(services): pilot service_whiteboard as selfstart CLI delegator #101

Closed
mahmoud wants to merge 1 commit from development_issue_100_delegator_pilot into development
Owner

Summary

Introduces the delegator pattern for service_*.nu modules. start/stop now delegate to the service's selfstart CLI (hero_whiteboard --start / --stop); the Rust CLI's build_service_definition() is the canonical source of truth for the action spec instead of every nu module hand-transcribing it.

  • lib.nu: +svc_cli_start, +svc_cli_stop (shared private dispatcher svc_cli_invoke handles the three --root cases — non-root, root-as-root via with-env { HOME: "/root" }, root-as-user via sudo -E HOME=/root).
  • service_whiteboard.nu: 317 → 85 lines (−232). Removed svx_server_action, svx_ui_action, svx_service_config, svx_drop_registration, the "already running → skip" precheck, the 13-line summary block, and the redundant svc_require_proc in start. install and status unchanged.

Pilot scope

One module only. The remaining 11 non-blocked modules (os, books, collab, biz, db, indexer, voice, aibroker, foundry + four yet-to-be-created: agent, claude, compute, shrimp) will be mass-applied in a follow-up PR once this shape is validated. service_office + service_osis remain blocked on hero_office#2 and hero_osis#32.

Smoke test (Hetzner, --root)

All 8 assertions green — install short-circuit, start cold + warm, both sockets bound, curl ui.sock /health → 200, status record shape intact, stop clean, post-stop status, stop with hero_proc down. Full matrix on the sub-issue.

Behavioural note

Post-stop status returns {state: exited, pid: 0} instead of pre-refactor's "service not found". The CLI's stop_service stops without deleting the record; pre-refactor called proc service delete additionally. Net-positive — hero_proc keeps the history row; no callers in hero_skills rely on the old shape.

Refs #100

## Summary Introduces the delegator pattern for `service_*.nu` modules. `start`/`stop` now delegate to the service's selfstart CLI (`hero_whiteboard --start` / `--stop`); the Rust CLI's `build_service_definition()` is the canonical source of truth for the action spec instead of every nu module hand-transcribing it. - **`lib.nu`**: `+svc_cli_start`, `+svc_cli_stop` (shared private dispatcher `svc_cli_invoke` handles the three `--root` cases — non-root, root-as-root via `with-env { HOME: "/root" }`, root-as-user via `sudo -E HOME=/root`). - **`service_whiteboard.nu`**: 317 → 85 lines (−232). Removed `svx_server_action`, `svx_ui_action`, `svx_service_config`, `svx_drop_registration`, the "already running → skip" precheck, the 13-line summary block, and the redundant `svc_require_proc` in `start`. `install` and `status` unchanged. ## Pilot scope One module only. The remaining 11 non-blocked modules (`os`, `books`, `collab`, `biz`, `db`, `indexer`, `voice`, `aibroker`, `foundry` + four yet-to-be-created: `agent`, `claude`, `compute`, `shrimp`) will be mass-applied in a follow-up PR once this shape is validated. `service_office` + `service_osis` remain blocked on [hero_office#2](https://forge.ourworld.tf/lhumina_code/hero_office/issues/2) and [hero_osis#32](https://forge.ourworld.tf/lhumina_code/hero_osis/issues/32). ## Smoke test (Hetzner, `--root`) All 8 assertions green — `install` short-circuit, `start` cold + warm, both sockets bound, `curl ui.sock /health` → 200, `status` record shape intact, `stop` clean, post-stop `status`, `stop` with hero_proc down. Full matrix on the sub-issue. ## Behavioural note Post-`stop` `status` returns `{state: exited, pid: 0}` instead of pre-refactor's "service not found". The CLI's `stop_service` stops without deleting the record; pre-refactor called `proc service delete` additionally. Net-positive — hero_proc keeps the history row; no callers in `hero_skills` rely on the old shape. ## Related Refs #100
Introduces the delegator pattern for service_*.nu modules. Instead of
hand-transcribing the hero_proc action spec in Nushell, start/stop now
delegate to the service's selfstart CLI (hero_whiteboard --start/--stop),
whose build_service_definition() in the Rust crate owns the canonical
spec. install and status stay local — install owns cargo build + copy,
status returns the structured hero_proc record that downstream skills
depend on.

New lib.nu helpers:
- svc_cli_start / svc_cli_stop dispatch the CLI with correct sudo/HOME
  handling for --root (three cases: non-root, root-as-root, root-as-user).
- Private svc_cli_invoke shares the dispatch logic. CLI stdout/stderr
  flow through to the terminal; non-zero exit raises with stderr attached.

Pilot scope: lib.nu helpers + service_whiteboard.nu only. The remaining
11 non-blocked modules (os, books, collab, biz, db, indexer, voice,
aibroker, foundry — plus the yet-to-be-created agent, claude, compute,
shrimp) will be mass-applied in a follow-up PR once the delegator shape
is validated.

service_whiteboard.nu: 317 → 85 lines (-232).

Smoke-tested end to end on Hetzner with --root — all 8 assertions green
(install short-circuit, start cold/warm, socket + /health probes, status
record shape, stop, post-stop status, hero_proc-down stop warning).

One behavioural nuance: post-stop `status` now returns {state: exited,
pid: 0} instead of "service not found" — the CLI's stop_service stops
without deleting the record. Net-positive (hero_proc keeps history row);
no callers in hero_skills rely on the old "not found" shape.

Refs: #100
Author
Owner

Closing unmerged — direction reversed based on upstream architectural feedback.

The pivot: instead of making the Rust CLI (--start/--stop) the canonical source of truth and the nu module a delegator, we are going the opposite way. Nushell owns full lifecycle management, service_*.nu stays the canonical spec, and the --start/--stop flags should eventually be removed from every hero_* binary (they add no value beyond what the nu layer already does — they are redundant glue).

The recent 5df145f Refactor service lifecycle management into shared lib.nu helpers on development is aligned with this direction (~1,700 lines of duplication removed; each service_*.nu calls proc service set / proc service start directly via the SDK, not through a binary flag).

Follow-up tracked in new issue #. Referencing #100 (also being closed) and replacing it.

Closing unmerged — direction reversed based on upstream architectural feedback. **The pivot**: instead of making the Rust CLI (`--start`/`--stop`) the canonical source of truth and the nu module a delegator, we are going the opposite way. Nushell owns full lifecycle management, `service_*.nu` stays the canonical spec, and the `--start`/`--stop` flags should eventually be removed from every `hero_*` binary (they add no value beyond what the nu layer already does — they are redundant glue). The recent `5df145f Refactor service lifecycle management into shared lib.nu helpers` on `development` is aligned with this direction (`~1,700` lines of duplication removed; each `service_*.nu` calls `proc service set` / `proc service start` directly via the SDK, not through a binary flag). Follow-up tracked in new issue #<TBD>. Referencing #100 (also being closed) and replacing it.
mahmoud closed this pull request 2026-04-21 12:01:40 +00:00
Author
Owner

Successor: #102refactor: remove --start/--stop from hero_* binaries; nushell owns full lifecycle.

Successor: #102 — `refactor: remove --start/--stop from hero_* binaries; nushell owns full lifecycle`.

Pull request closed

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_skills!101
No description provided.