swactor/CLAUDE/notes/progress.md
Developer bf79d63be4 feat: command interface — frontend-agnostic dispatch crate
Add swactor-command crate that decouples command dispatch from the
dashboard, enabling the same commands from REPL, REST, TUI, or any
future frontend.

- CommandRouter with dispatch(), CommandHandler trait, CommandMeta
- CommandRequest/CommandResponse (serde-serializable JSON protocol)
- CommandContext with Arc<Runtime> + optional StatsEnricher trait
- 9 built-in commands extracted from investigate.rs:
  help, overview, workers, worker, actors, actor, hot, phases, diff,
  shutdown
- REPL line parser (parse_line) with positional arg mapping
- REST adapter (from_query_params) for HTTP query parameters
- Dashboard integration: StatsEnricher impl for StatsCollector,
  investigate.rs refactored to thin CommandRouter wrapper,
  server.rs updated to share CommandRouter across handler threads
- 18 behavioral tests in crates/command/tests/command_api.rs

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-13 07:25:50 +00:00

51 lines
2.7 KiB
Markdown

# Progress
## Completed
### Feature 1: Actor Watching (local only) — `docs/os-design/01-actor-watching.md`
- Added `ExitReason` enum (Stopped, Panicked, NodeDown) and `ActorExited` struct to `src/actor.rs`
- Extended `ContextInner` trait with `watch()`/`unwatch()` methods
- Added `Ctx::watch(target)` and `Ctx::unwatch(target)` typed API
- Added `on_actor_exit()` default method to `ActorInterface` trait
- Updated `AnyActor::handle_any` with system message fallback (tries `ActorExited` after `Incoming`)
- Implemented `WatchRegistry` in `src/worker.rs` (bidirectional HashMap tracking)
- Integrated death notification dispatch as phase 5b in `tick_once`
- Implemented `watch`/`unwatch` on `Runtime`'s `ContextInner` impl
- Added `watch_registry` field to `TickContext` in `src/delivery.rs`
- 10 behavioral tests in `tests/watch_api.rs` — all passing
### Feature 2: Command Interface — `docs/os-design/04-command-interface.md`
- Created `crates/command/` crate (`swactor-command`) with core types:
- `CommandRequest`, `CommandResponse` (serde-serializable)
- `CommandHandler` trait + `CommandMeta`
- `CommandRouter` with `dispatch()` and `with_builtins()`
- `CommandContext` with `Arc<Runtime>` + optional `StatsEnricher`
- `StatsEnricher` trait (decouples command crate from dashboard)
- Built-in read commands: overview, workers, worker, actors, actor, hot, phases, diff
- Built-in write command: shutdown
- REPL line parser (`parse_line`) with positional arg mapping and `--flag value` support
- REST adapter (`from_query_params`) for HTTP query parameters
- Refactored `investigate.rs` to delegate to CommandRouter (thin wrapper)
- Updated `server.rs` to use CommandRouter for `/api/investigate` endpoint
- Implemented `StatsEnricher for StatsCollector` in dashboard crate
- 18 behavioral tests in `crates/command/tests/command_api.rs` — all passing
- All 53 swactor core tests pass, all 18 command tests pass
## Next Steps
1. **Cluster Registry** — `docs/os-design/02-cluster-registry.md`
- LWW-Register CRDT per name binding
- Propagation via SWIM piggyback
- `ClusterRegistry` struct in `crates/distribution/src/registry.rs`
- API: register_name, unregister_name, resolve_name
2. **Node Capabilities** — `docs/os-design/03-node-capabilities.md`
- New `crates/capabilities/` crate with auto-detection
3. **Remote Watching** — extends actor watching with wire protocol
4. **Supervision** — `docs/os-design/05-supervision.md`
## Open Questions
- Custom actor commands (via `Ctx::register_command()`) deferred to a later PR
- Distribution-aware commands (nodes, registry, resolve) deferred until cluster registry is implemented
- Write commands (spawn, stop, drain) deferred — need factory registry and actor stop mechanism
## Blockers
- None