Skip to content

feat(cli): expose gateway serve command#78

Merged
anhermon merged 3 commits into
devfrom
feature/anga-353-websocket-gateway
Apr 25, 2026
Merged

feat(cli): expose gateway serve command#78
anhermon merged 3 commits into
devfrom
feature/anga-353-websocket-gateway

Conversation

@anhermon

@anhermon anhermon commented Apr 18, 2026

Copy link
Copy Markdown
Owner

Closes ANGA-353

Thinking Path

  1. ANGA-353 requires a minimal operator-facing WebSocket gateway path for Anvil.
  2. The existing harness-gateway crate already owns the Axum WebSocket server, /health, ping/pong, event broadcast, and control-command plumbing.
  3. The missing piece is a CLI surface that lets operators start that gateway without writing Rust or needing an LLM API key.
  4. The CLI crate is the right integration point because it already exposes operator commands such as run, eval, memory, and paperclip.
  5. Keeping the change in crates/cli avoids touching provider traits, Paperclip API adapter behavior, or gateway wire semantics.
  6. anvil gateway serve should print the actual health and WebSocket URLs so users can verify the selected port, including OS-assigned port 0.
  7. Startup event emission is opt-in via --emit-hello, preserving the default behavior as a passive local gateway.
  8. --emit-hello should wait until a WebSocket client is subscribed, otherwise the broadcast channel correctly drops the smoke event before any operator can observe it.
  9. CLI validation should reject invalid event-buffer values before server startup, so --event-buffer 0 cannot panic inside the broadcast channel.
  10. Control commands sent through WebSocket must be drained while the standalone CLI server runs so the bounded command channel cannot fill and stall socket tasks.

What Changed

  • Added a gateway top-level CLI command and gateway serve subcommand.
  • Wired harness-gateway into harness-cli and starts Gateway::new(config).start() from the CLI.
  • Added --port, --event-buffer, and --emit-hello options for local gateway startup.
  • Prints /health and /ws URLs after successful bind, including the actual bound address.
  • Drains and logs forwarded control commands while the CLI gateway is running.
  • Defers --emit-hello startup events until the first WebSocket client has subscribed.
  • Added CLI surface tests for the new command and for rejecting --event-buffer 0.
  • Added gateway regression tests for subscriber counting and late-subscriber hello delivery.

Verification

  • cargo fmt --check passes
  • cargo test --workspace passes
  • cargo clippy --workspace -- -D warnings clean
  • cargo test -p harness-cli --test cli_surface passes
  • cargo test -p harness-gateway passes
  • Manual smoke: anvil gateway serve --port 19157; GET /health returned {"status":"ok"} and WebSocket {"cmd":"ping"} returned {"kind":"pong"}
  • Pre-push hook passed (cargo test --workspace)

Risks

Low risk. The change only exposes an existing gateway crate through the CLI, adds argument validation, drains existing control-command traffic, and makes opt-in hello emission wait for a subscribed WebSocket client. The new server command binds to localhost through the existing gateway implementation and does not change provider traits, Paperclip adapter behavior, or gateway wire semantics.

Checklist

  • Tests pass locally
  • No new warnings from clippy
  • Code is formatted with cargo fmt
  • Commit messages follow conventional format
  • Co-Authored-By trailer included for agent commits

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 4f9fbba917

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/src/commands/gateway.rs Outdated
Co-Authored-By: Paperclip <noreply@paperclip.ing>
@anhermon anhermon force-pushed the feature/anga-353-websocket-gateway branch from 4f9fbba to af72cea Compare April 18, 2026 07:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: af72cea86f

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/src/commands/gateway.rs Outdated
Co-Authored-By: Paperclip <noreply@paperclip.ing>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 417723491a

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/cli/src/commands/gateway.rs Outdated
Co-Authored-By: Paperclip <noreply@paperclip.ing>
@anhermon anhermon merged commit 3fc7693 into dev Apr 25, 2026
4 checks passed
@anhermon anhermon deleted the feature/anga-353-websocket-gateway branch April 25, 2026 17:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant