Skip to content

[M1.2c3] Maintain authenticated agent streams and enforce revocation - #34

Merged
samuelmbabhazi merged 1 commit into
mainfrom
feat/m1.2c3-gateway-stream
Nov 5, 2026
Merged

samuelmbabhazi merged 1 commit into
mainfrom
feat/m1.2c3-gateway-stream

Conversation

@samuelmbabhazi

Copy link
Copy Markdown
Collaborator

Implements M1.2c3: authenticated agents can keep a bidirectional Connect stream open. Depends on #33 and targets its branch.

The first frame must identify the authenticated node and current epoch. The gateway replies with Welcome and a five-second heartbeat interval. Duplicate streams replace the previous connection; idle peers time out after 15 seconds. Certificate registration, revocation, expiry and node removal are checked at every frame and once per second during silence. Database failures close the stream with sanitized errors. Stream deadlines are separate from unary deadlines; message sizes remain bounded to 64 KiB.

Validation: TypeScript lint/typecheck and unit tests; 22 PostgreSQL/TLS integration tests, including forged identities, stale epochs, live revocation without another request and duplicate connections. Fake-timer tests cover idle expiry and timer cleanup. An asynchronous socket-rejection regression found during testing was fixed by observing pending reads immediately.

Scope: this is transport only. Durable leases, action dispatch and state reports remain in their planned milestones. No lease is granted by Welcome yet; unsupported frames fail explicitly. ExecStream remains authenticated and Unimplemented until session authorization exists. No persistent state changes or unaudited database writes are introduced.

  • M1.2c3 acceptance and security tests
  • Specification and threat model updated
  • No new dependencies, shell execution or secret logging
  • CI and maintainer review

The Go daemon's connection loop and real cross-language restart test follow in M1.2c4. No merge requested.

@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m1.2c2-agent-enrollment branch from d5bce5e to f342eb2 Compare November 5, 2026 13:37
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m1.2c3-gateway-stream branch from 4d2ceb8 to 02ea7c9 Compare November 5, 2026 13:37
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m1.2c2-agent-enrollment branch from f342eb2 to ac31d21 Compare November 5, 2026 14:27
@samuelmbabhazi
samuelmbabhazi changed the base branch from feat/m1.2c2-agent-enrollment to main November 5, 2026 14:28
@samuelmbabhazi
samuelmbabhazi force-pushed the feat/m1.2c3-gateway-stream branch from 02ea7c9 to 8257f06 Compare November 5, 2026 14:29
@samuelmbabhazi
samuelmbabhazi merged commit f6fd10f into main Nov 5, 2026
2 of 11 checks passed
@samuelmbabhazi
samuelmbabhazi deleted the feat/m1.2c3-gateway-stream branch November 5, 2026 14:29
samuelmbabhazi added a commit that referenced this pull request Nov 5, 2026
Implements the connection runner portion of M1.2c4, split from daemon
wiring and the cross-language integration test to keep review focused.
Depends on #34 and targets its branch.

The runner sends Hello, validates the returned node/epoch and heartbeat
interval, and owns the receive goroutine through cancellation.
Control-plane interruptions reconnect with bounded exponential backoff
and jitter. Certificates rotate at two thirds of validity and are
persisted atomically before reconnecting. Explicit authentication/epoch
rejection and renewal persistence failure halt connection attempts
without silently re-enrolling. Dead connections use TLS/gRPC keepalive;
remote error text is excluded from logs.

Validation: Go race tests over real TLS/gRPC cover reconnect,
heartbeats, renewal persistence, authentication error propagation,
shutdown and backoff bounds; golangci-lint passes. Existing TypeScript
and protobuf checks are unchanged. This runner dispatches no actions and
grants no leases; unsupported frames fail explicitly pending their
planned handlers.

- [x] M1.2c4a behavior and tests
- [x] No new dependency, shell invocation or secret exposure
- [x] Plan, specification and threat model updated
- [ ] CI and maintainer review

Daemon integration and the NestJS-to-Go restart/revocation test remain
M1.2c4b. No merge requested.
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