Skip to content

feat(acp): transport hardening — WebSocket lifecycle, bearer auth, discovery manifest (#936)#951

Merged
bug-ops merged 5 commits intomainfrom
feat/acp-936-transport-hardening
Feb 26, 2026
Merged

feat(acp): transport hardening — WebSocket lifecycle, bearer auth, discovery manifest (#936)#951
bug-ops merged 5 commits intomainfrom
feat/acp-936-transport-hardening

Conversation

@bug-ops
Copy link
Owner

@bug-ops bug-ops commented Feb 26, 2026

Summary

Implements Epic 7 from the ACP gap analysis (#936): three transport hardening gaps closed.

G15 — WebSocket lifecycle

  • Atomic slot reservation (CAS on AtomicUsize) before upgrade handshake eliminates TOCTOU race between max_sessions check and DashMap insertion
  • 30s ping / 90s pong-timeout keepalive
  • Binary frame rejection with close code 1003 (RFC 6455)
  • 1s write-task drain window on disconnect ensures close frame delivery before sink drop
  • 1 MiB max message size enforced at upgrade

G16 — Bearer token authentication

  • New Tower middleware (auth.rs) with constant-time comparison via subtle::ConstantTimeEq
  • Applied to /acp and /acp/ws; discovery endpoint is exempt
  • Configured via acp.auth_bearer_token / ZEPH_ACP_AUTH_TOKEN env / --acp-auth-token CLI
  • Open mode (no token) for unauthenticated local access
  • AcpConfig uses custom impl Debug that redacts auth_token as [REDACTED]

G17 — Agent discovery manifest

  • GET /.well-known/acp.json returns name, version, supported transports, and auth type
  • Always unauthenticated (clients must discover before presenting credentials)
  • Controlled by acp.discovery_enabled (default true) / ZEPH_ACP_DISCOVERY_ENABLED

Test plan

  • cargo nextest run --workspace --lib --bins — 2855/2855 passed (+9 new tests)
  • Bearer auth: valid token passes, missing/wrong token → 401, no-auth open mode
  • Discovery: JSON fields present, bearer type reflected, disabled → 404
  • AcpConfig debug output contains [REDACTED], not the token value
  • cargo clippy --workspace --features acp-http -- -D warnings — clean
  • cargo +nightly fmt --check — clean

…scovery manifest (#936)

G15 — WebSocket lifecycle:
- Atomic slot reservation (CAS on AtomicUsize) before upgrade handshake eliminates
  TOCTOU race between max_sessions check and DashMap insertion
- 30s ping / 90s pong-timeout keepalive with tokio::select!
- Binary frame rejection with close code 1003 per RFC 6455
- 1s write-task drain window on disconnect ensures close frame delivery
- 1 MiB max message size enforced at upgrade

G16 — Bearer token authentication:
- New Tower middleware (auth.rs) with constant-time comparison via subtle::ConstantTimeEq
- Applied to /acp and /acp/ws routes; discovery endpoint exempt
- Configured via acp.auth_bearer_token / ZEPH_ACP_AUTH_TOKEN env / --acp-auth-token CLI
- Open mode (no token) for unauthenticated local access

G17 — Agent discovery manifest:
- GET /.well-known/acp.json returns name/version/transports/authentication type
- Always unauthenticated; controlled by acp.discovery_enabled / ZEPH_ACP_DISCOVERY_ENABLED

Security:
- AcpConfig uses custom impl Debug redacting auth_token as [REDACTED]

Tests: 2855 passed (+9 new: bearer auth valid/missing/wrong/none, discovery json/bearer/disabled,
debug-redaction, atomic slot reservation)
@github-actions github-actions bot added documentation Improvements or additions to documentation rust core dependencies enhancement New feature or request size/XL labels Feb 26, 2026
@bug-ops bug-ops enabled auto-merge (squash) February 26, 2026 03:10
@bug-ops bug-ops merged commit 55524cb into main Feb 26, 2026
28 checks passed
@bug-ops bug-ops deleted the feat/acp-936-transport-hardening branch February 26, 2026 03:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core dependencies documentation Improvements or additions to documentation enhancement New feature or request rust size/XL

Projects

None yet

1 participant