docs: implementation plan (TTY precedents folded in); task decomposition (17 tasks)

Plan updated with the alknet-tty findings: the drainer pattern
(single ordered writer) makes outbound chunk-boundary parsing sound;
TestStdinSink's try_send→Full→Pending is the inbound backpressure
precedent; OQ-01(a) now cites the reference.

Task graph (taskgraph-validated, 17 tasks, 6 generations, no cycles):
- tasks/server/: core-types, auth, healthz-decoy, adapter
- tasks/gateway/: dispatch, routes, publish
- tasks/websocket/: byte-adapter (research POC), upgrade-session, overlay-ops
- tasks/adapters/: from-openapi, from-jsonschema, to-openapi, from-wss, mcp
- tasks/client/: http-host
- tasks/infra/: integration-suite (phase 4)

Critical path runs through server core → adapter → WS session →
overlay tests → integration suite. High-risk tasks are the three WS
tasks, de-risked by the ws-byte-adapter POC blocking upgrade-session.
This commit is contained in:
2026-08-28 06:05:45 +00:00
parent eaf1a203bc
commit 63dc4b6d06
19 changed files with 784 additions and 4 deletions
+54
View File
@@ -0,0 +1,54 @@
---
id: ws-byte-adapter
name: WS ↔ byte-stream adapter (research POC → production shape)
status: pending
depends_on: []
scope: moderate
risk: high
impact: phase
level: research
tags: [websocket, phase-2, poc]
---
## Description
Targeted POC validating the WS↔byte-stream adapter contract (OQ-01)
before the production implementation: wrap axum's `WebSocket` as
`AsyncRead + AsyncWrite` such that alkcall's `ChannelsAdapter` demux
and mux run over it correctly.
Inbound: axum WS messages → shared bounded buffer → `AsyncRead` drains
(backpressure via the alknet-tty precedent: try_send → Full → Pending).
Outbound: `AsyncWrite` accumulates into a pending buffer; a task parses
outgoing 8-byte chunk headers (verified: header+payload are separate
writes; channel 0's write_frame is prefix+body separately) and emits
each complete chunk as one WS binary message; chunks over the WS
message cap (~1 MiB default) split across messages. Close: WS close →
transport EOF (REQ-CH-02); `AsyncWrite::shutdown` → zero-length
sentinel then Close frame (REQ-CH-01).
## Acceptance Criteria
- [ ] POC: adapter + ChannelsAdapter + channel-0 Dispatcher over `tokio::io::DuplexStream` pairs — call round-trip works
- [ ] POC test: 16 MiB chunk splits across WS messages and reassembles
- [ ] POC test: interleaved channel writes preserve chunk integrity (no torn chunks)
- [ ] OQ-01 sub-items (a)-(d) resolved with concrete values, written back into open-questions.md
- [ ] Findings + go/pivot recommendation recorded in this task's Summary
## References
- docs/architecture/websocket.md (§The WS ↔ byte-stream adapter)
- docs/plans/implementation.md (§What the spike established, point 6)
- alknet-tty precedent: `src/adapter.rs` `pump_session` drainer pattern + `TestStdinSink` backpressure
- alkcall: `channels::wire::write_chunk`, `channels::mux::MuxRunner`, REQ-CH-01/02 in `channels-wire.md`
## Notes
> Agent fills during implementation. This is a research task: the POC
> code lands under `.worktrees/research/` or a `#[cfg(test)]` module —
> not as final production code — but the production adapter may grow
> directly from it if the shape holds.
## Summary
> Agent fills on completion.
+44
View File
@@ -0,0 +1,44 @@
---
id: ws-overlay-ops
name: Browser-registered ops — connection-local overlay tests
status: pending
depends_on: [ws-upgrade-session]
scope: narrow
risk: medium
impact: component
level: implementation
tags: [websocket, phase-2]
---
## Description
Port the connection-local Layer 2 overlay verification from
`/workspace/@alkdev/alknet/crates/alknet-http/src/websocket/overlay.rs`
to the channels-over-WS session: a WS client registers ops (via
call-protocol registration on channel 0), the hub reaches them through
the live connection handle's `overlay_env()` — not PeerRef. Tests:
hub→browser call over the same session; overlay ops die on disconnect;
AccessControl gating on browser ops; bidirectional concurrent calls
(both sides initiating on channel 0).
## Acceptance Criteria
- [ ] Hub→browser call test passes (browser registered an op, hub invokes it)
- [ ] Disconnect drops overlay; subsequent reach attempts fail cleanly
- [ ] Concurrent bidirectional calls don't deadlock or cross-correlate
- [ ] `cargo test` passes
## References
- docs/architecture/websocket.md (§Connection-local overlay, §Bidirectionality)
- docs/architecture/decisions/034-outgoing-only-x509-and-three-peer-roles.md (§4)
- alkcall ADR-019 (registry layering)
- Old source: `/workspace/@alkdev/alknet/crates/alknet-http/src/websocket/overlay.rs`
## Notes
> Agent fills during implementation.
## Summary
> Agent fills on completion.
+48
View File
@@ -0,0 +1,48 @@
---
id: ws-upgrade-session
name: WS upgrade route + channels session (server producer half)
status: pending
depends_on: [ws-byte-adapter, server-adapter]
scope: broad
risk: high
impact: phase
level: implementation
tags: [websocket, phase-2]
---
## Description
Implement the WS upgrade handler per ADR-067/websocket.md, production
shape: axum route at `/alk/channels`; bearer auth on the upgrade
request (401 without token); upgrade → adapt the WS stream with the
byte-adapter (ws-byte-adapter) → `Connection::from_bidi(ws_stream,
b"alk/channels")` → run the channels accept path: alkcall
`ChannelsAdapter` in-line demux with the `install_channel_zero` hook
constructing channel 0's `CallConnection` (identity attached) and
running `Dispatcher::run_loop_single_stream`. Text messages rejected
(WS close 1002). Overlay-only session construction mirrors the alknet
`upgrade.rs::run_ws_session` shape but through the channels machinery.
## Acceptance Criteria
- [ ] Upgrade route wired into HttpAdapter's router (reserved-path collision rule respected)
- [ ] End-to-end test: WS client (tokio-tungstenite or axum test client) → upgrade → chunk-framed call.requested on channel 0 → response received
- [ ] Browser-style test: services/list via channel 0, AccessControl-filtered
- [ ] Disconnect mid-call: pending requests failed, overlay dropped, no hang
- [ ] 16 MiB chunk split/reassembly test carried over from the POC
- [ ] `cargo test` passes
## References
- docs/architecture/websocket.md (full spec)
- docs/architecture/decisions/067-websocket-carries-channels.md
- alkcall `channels/client.rs` tests (make_install_channel_zero wiring pattern)
- Old source: `/workspace/@alkdev/alknet/crates/alknet-http/src/websocket/upgrade.rs` (session lifecycle; framing superseded)
## Notes
> Agent fills during implementation.
## Summary
> Agent fills on completion.