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
+47
View File
@@ -0,0 +1,47 @@
---
id: gateway-dispatch
name: GatewayDispatch — shared dispatch spine (invoke + streaming)
status: pending
depends_on: [server-core-types]
scope: moderate
risk: medium
impact: component
level: implementation
tags: [gateway, phase-1]
---
## Description
Port the dispatch spine from
`/workspace/@alkdev/alknet/crates/alknet-http/src/gateway/dispatch.rs`
to alkcall's API: `GatewayDispatch::new(registry, identity_provider)`,
`invoke()` (identity resolve → root OperationContext →
`OperationRegistry` invoke → ResponseEnvelope), and `invoke_streaming()`
(`BoxStream<ResponseEnvelope>` for Sub ops). The security invariants
must hold identically across both: `External`-only (Internal →
NOT_FOUND), `AccessControl::check` gating, no env-var reads. Port the
error mapping (`gateway/error.rs`) too: CallError → HTTP status per
docs/architecture/http-server.md §Error Mapping (NOT_FOUND→404,
FORBIDDEN→401/403, INVALID_INPUT→422, TIMEOUT→504, INTERNAL→500,
`HTTP_<status>` passthrough, retryable→Retry-After hint).
## Acceptance Criteria
- [ ] `invoke()` + `invoke_streaming()` ported against alkcall dispatch
- [ ] Error mapping table ported with unit tests per row
- [ ] Internal ops → 404 before ACL; ACL failure → 401/403 distinction preserved
- [ ] `cargo test` passes
## References
- docs/architecture/http-server.md (§HTTP-to-call dispatch, §Error Mapping)
- docs/architecture/decisions/023-operation-error-schemas.md
- alkcall ADR-016 (error schemas), ADR-017 (privilege model)
## Notes
> Agent fills during implementation.
## Summary
> Agent fills on completion.
+46
View File
@@ -0,0 +1,46 @@
---
id: gateway-publish
name: POST /publish endpoint for Pub operations
status: pending
depends_on: [gateway-routes]
scope: narrow
risk: medium
impact: component
level: implementation
tags: [gateway, phase-3]
---
## Description
Implement `POST /publish` per ADR-068: NDJSON request body (each line =
one published chunk) dispatched through `invoke_sink()` (alkcall
ADR-046); handler's final ResponseEnvelope → 200 JSON or mapped error
status. Resolve OQ-02 during this task: first line carries
`{ "operation": "/{service}/{op}", "chunk": {...} }` (subsequent lines
`chunk`-only); terminal errors are plain HTTP status + JSON body (not
an NDJSON line). Client disconnect drops the body stream → sink
cancelled (PublishStream sees EOF). Non-Pub target → 400
INVALID_OPERATION_TYPE. Tests: multi-chunk publish round-trip against a
SinkHandler over DuplexStream, early-disconnect, error mapping.
## Acceptance Criteria
- [ ] /publish wired; OQ-02 convention implemented and documented in ADR-068
- [ ] Sink round-trip test (3+ chunks → final envelope)
- [ ] Disconnect mid-stream cancels the handler (no hang)
- [ ] to_openapi gateway doc gains /publish; gateway `info.version` minor bump
- [ ] `cargo test` passes
## References
- docs/architecture/decisions/068-gateway-publish-endpoint.md
- docs/architecture/open-questions.md (OQ-02)
- alkcall ADR-046 (Pub/invoke_sink/PublishStream)
## Notes
> Agent fills during implementation.
## Summary
> Agent fills on completion.
+45
View File
@@ -0,0 +1,45 @@
---
id: gateway-routes
name: The 5 core gateway routes wired into the router
status: pending
depends_on: [gateway-dispatch, server-adapter]
scope: moderate
risk: medium
impact: component
level: implementation
tags: [gateway, phase-1]
---
## Description
Port `server/gateway_routes.rs` from
`/workspace/@alkdev/alknet/crates/alknet-http/src/server/gateway_routes.rs`:
`GET /search` (AccessControl-filtered services/list), `GET /schema`,
`POST /call` (`{operation, input}`), `POST /batch`, and `POST /subscribe`
(SSE projection: `text/event-stream`, `call.responded``data:` frames,
terminal error event, abort on client disconnect). Auth middleware
applied to all five. The route set intentionally excludes `/publish`
(separate task). Integration tests over DuplexStream: search filtering
by identity scopes, call round-trip, subscribe stream of multiple
events, batch correlation.
## Acceptance Criteria
- [ ] 5 routes ported and wired in server-adapter's router
- [ ] SSE framing tests (multi-event, error-terminates, client-disconnect)
- [ ] /search returns only ops the caller's identity can invoke
- [ ] Full request→dispatch→response test over DuplexStream
- [ ] `cargo test` passes
## References
- docs/architecture/http-server.md (§router list, §Streaming projection)
- docs/architecture/decisions/042-openapi-gateway-pattern.md, 047-remove-direct-call-http-surface.md
## Notes
> Agent fills during implementation.
## Summary
> Agent fills on completion.