docs(tasks): decompose review-002 into 24 tasks (23 implementation + 1 bracketed follow-up)

Decomposition of docs/reviews/002-post-remediation-review.md per its
5-unit remediation plan:

- Unit 1 (security-critical): gw15-publish-body-cap,
  prj16-schema-via-call (CF-004 filed alkcall-side), fwd13-dot-segments,
  fwd16-missing-capability, oai11-ref-memoization
- Unit 2 (timeout/terminality): ws13-idle-progress,
  fwd15-stream-timeout, cli01-retry-after-budget, con17-mcp-pagination,
  con18-wss-sweep-exit
- Unit 3 (projection/docs): projection-truthfulness, mcp-batch-cap,
  gw16-status-drift
- Unit 4 (spec-import): yaml-normalization, oai13-path-item-wildcards,
  import-loudness-cluster, js01-placeholder-check,
  fwd17-19-contract-decisions
- Unit 5 (WS polish + tests): con18b-ws-polish,
  client-policy-wire-tests, cov-deployment-knobs, cov13-dead-code,
  srv11-srv12-router-ordering
- review-002-bracketed-followup: tentatively planned post-bulk pass
  (stale-check, OQA-18 enforcement decision, CON-08/09 close() lever,
  cross-crate re-checks) — deliberately not serialized against the
  bulk

Also: review-002 numbering repair (CON-14 was double-booked; MCP
pagination now CON-14, from_wss monitor renumbered CON-18, missing
CON-14 section added).

taskgraph: 66 valid, no cycles; 24 pending (all review-002);
gen-1/gen-2 parallel waves identified; workflow-cost hotspots are
prj16 (12.8) and ws13 (11.1), both carrying the reviewed slicing
guidance in their Notes.
This commit is contained in:
2026-08-30 10:50:34 +00:00
parent 5452785f0d
commit e2c255d40c
25 changed files with 1679 additions and 10 deletions
@@ -0,0 +1,73 @@
---
id: review-002-con18b-ws-polish
name: WS small fixes — pre-send cap check, close reasons, custom-route knobs, axum-flavor tests (WS-14/15/17/18/19)
status: pending
depends_on: [review-002-ws13-idle-progress]
scope: moderate
risk: low
impact: component
level: implementation
tags: [websocket, review-002]
---
## Description
Five review-002 minor WS findings that all live in the two WS files
(`byte_adapter.rs`, `upgrade.rs`) — batched because each is small and
they share the review-002-ws13-idle-progress refactor context
(sequence after it; do not parallelize on the same file):
- **WS-14**: the byte-cap check can trip only *after* `poll_write` has
accepted into the channel (`byte_adapter.rs:326-334, 585-586`) — the
mux committed the chunk, then the pump 1011s and truncates. Move the
size check into `poll_write` **before** `try_send` so the mux sees
the write error instead of the wire.
- **WS-15**: `WriteMsg::CloseWith` hardcodes the reason "text messages
not supported" for idle-timeout (1001), inbound-size (1011), and text
(1002) closes (`:316-324`). Carry the reason in the variant; tests
assert numeric codes today, keep them and add reason asserts where
cheap.
- **WS-17**: bare-registry WS routes get no knob surface
(`upgrade.rs:104-111` hardcodes 60 s idle + private 64-session
semaphore). Add a `WsIdleTimeout`-style request extension mirroring
`ChannelsPolicy` (or document the fixed values in the module doc —
implementer's choice, but `upgrade.rs` docs must match reality).
- **WS-18**: write-side stall is unbounded (peer stops reading → write
pump parks in `ws_sink.send`, 64×16 MiB bounded but time-unbounded).
Add a write-progress timeout to the write pump (same knob family as
the read side — share the config surface WS-17 touches).
- **WS-19**: axum-flavor `AxumFraming` arms have no direct unit test
(cap-trip closes + idle-1001 are asserted on tungstenite only, via
shared generic code). Mirror one text→1002 and one cap-trip test
over `AxumFraming`.
## Acceptance Criteria
- [ ] WS-14: over-cap write rejected in `poll_write` pre-`try_send`;
test asserts the *stream* error, not a wire-level 1011
- [ ] WS-15: close reasons distinct per cause (idle / oversized /
text); existing close-frame tests updated with reason asserts
- [ ] WS-17: knob surface exists (extension or documented-fixed) and
`upgrade.rs` module docs match the implementation
- [ ] WS-18: write-progress timeout lands with the same config family;
test: a peer that stops reading (clog the sink) is evicted
within the knob (scaled test, tungstenite path)
- [ ] WS-19: two `AxumFraming` unit tests (text→1002, cap-trip) pass
- [ ] `cargo test`, `cargo clippy --all-targets -- -D warnings`,
`cargo fmt --check` pass
## References
- docs/reviews/002-post-remediation-review.md (Part B', WS-14/15/17/18/19)
- src/websocket/byte_adapter.rs:326-334 (WS-14), :316-324 (WS-15), :584-597 (WS-18), :782-1206 (WS-19 test target)
- src/websocket/upgrade.rs:104-111 (WS-17), :308-317 (the ChannelsPolicy extension pattern to mirror)
- tasks/websocket/review-001-ws-pump-consolidation.md (the generic pump these extend)
## Notes
Slice suggestion (per the review-001 lesson on WS agents): one slice
per finding with its own commit, in the order above (WS-14 is the only
behavior-correctness one; WS-18 is the only new mechanism). If WS-13
(chief-risk task) changed the read-loop shape, rebase-verify the cap
accounting comments before this task's slices — they cite
pre/post-extend order explicitly.
@@ -0,0 +1,74 @@
---
id: review-002-ws13-idle-progress
name: Idle deadline off demux progress + slow-legitimate-stream decision (WS-13)
status: pending
depends_on: []
scope: moderate
risk: high
impact: component
level: implementation
tags: [websocket, review-002]
---
## Description
Review 002 WS-13 [major]. The WS-01 remediation's idle timer
(`byte_adapter.rs:229-244`) wraps only the next-message await, so it
fails in both directions:
1. **The attack it exists for defeats it.** WS-01's dribble (declare a
16 MiB chunk, deliver one byte per WS message per minute) keeps
arriving messages → the deadline resets on every dribble → the demux
still parks forever with the partial chunk. The doc (:117) claims
"a peer that drips bytes cannot park the single demux loop longer
than this without traffic" — under the actual attack the peer
supplies traffic forever.
2. **Legitimate slowness is killed.** A >60 s-silent-but-alive session
(long handler compute, quiet subscription) is disconnected with
1001 mid-flight — no ping/pong keepalive exists, and chunk progress
does not reset the timer.
The existing test (`idle_read_timeout_resets_on_traffic`) enshrines
reset-on-message as correct — it codifies the gap.
## Acceptance Criteria
- [ ] Decide + implement the progress semantics: the deadline resets
on **demux progress** (bytes actually forwarded into `read_tx`),
not message arrival — a peer that dribbles a chunk forever hits
the deadline; a peer delivering complete chunks (even slowly
per-message but productively) keeps the connection
- [ ] Decide + document the legitimate-silence stance (choose one and
record it in the module doc + http-server/websocket.md):
(a) add WS ping/pong keepalive so app-silence ≠ transport-silence,
or (b) document that 60 s of *no progress* is an intentional
eviction line even for silent subscriptions
- [ ] Acceptance test 1: chunk header `[ch][len=N]` dribbled in small
messages with per-message gaps < timeout → connection closed
(progress deadline fires)
- [ ] Acceptance test 2: scaled-down silent-but-alive session with a
pending response is NOT disconnected when the knob's spirit says
it should survive (e.g. messages flowing that make progress)
- [ ] The WS-01 knob surface (`with_ws_idle_timeout`) is unchanged;
the semantics change is doc'd against it
- [ ] `cargo test`, `cargo clippy --all-targets -- -D warnings`,
`cargo fmt --check` pass (tungstenite-path unit tests + one axum
integration mirror)
## References
- docs/reviews/002-post-remediation-review.md (Part B', WS-13; Part G', COV-11b — the knob is currently untested on the axum path too)
- src/websocket/byte_adapter.rs:117 (doc claim), :229-253 (the timer), :782-1206 (tests)
- tasks/websocket/review-001-ws-session-limits.md (the WS-01 knob work)
- docs/architecture/websocket.md
## Notes
Highest-risk task in the batch (touching the shared pump's read loop —
the same loop the cap logic lives in). Slice suggestion: (1) progress
tracking + tests on the tungstenite path, (2) doc/keepalive decision,
(3) axum integration mirror. Coordinate with
review-002-con18b-ws-polish (same file) — sequence, don't parallelize.
If (a)-keepalive is chosen, note it interacts with FWD-15's
server-side keep-alives on the *HTTP* SSE path — different layers, but
document both in the same doc pass.