params: the error-schema declaration + the wire hygiene residue (review-002 D-3, N-3, N-9)

- D-3: socks5_open_spec declares the channel:open_failed
  ErrorDefinition (alktty-ported schema, adapted) — reason enum is
  the full ADR-049 §3 five-code vocabulary matching
  SocksEstablishmentReason's parse table; description carries this
  crate's gate classes (FORBIDDEN / INVALID_INPUT /
  channel:too_many_channels) + the no-phantom-channel property.
  Pinned by open_spec_declares_the_open_failed_error_definition,
  which round-trips every enum value through the typed vocabulary —
  schema and typed view cannot drift. Module doc updated from claim
  to fact.
- N-3: DatagramReader::feed's structurally-unreachable let-else
  restructured — the header read folds into the let-else's else arm
  (live-else shape); zero behavior change, wire suite green
  unchanged.
- N-9: is_mid_frame kept; doc names the anticipated batch-2 consumer
  (the front-door bridges) so dead-surface sweeps don't flag it.

Verification:
- cargo test: 357 passed, 0 failed (all suites)
- cargo clippy --all-targets -- -D warnings: clean
- cargo fmt --check: clean
- cargo doc --no-deps: clean
- cargo check --target wasm32-unknown-unknown: clean
- cargo clippy --target wasm32-unknown-unknown -- -D warnings: clean

Task: tasks/implementation/fix-hygiene-residue.md (completed)
This commit is contained in:
glm-5.3-flash committed 2026-09-24 18:41:42 +00:00
1 parent 68d5be36a0
commit ff3295422c
3 files changed
+166 -17

No files matched your search

+82 -8
View File
@@ -1,7 +1,7 @@
---
id: implementation/fix-hygiene-residue
name: "Fix — error-schema declaration + small hygiene residue (review-002 D-3, N-3, N-9)"
status: pending
status: completed
depends_on: []
scope: narrow
risk: low
@@ -57,16 +57,16 @@ postures (`docs/reviews/002-protocol-core-implementation-review.md`):
## Acceptance Criteria
- [ ] `socks5_open_spec` declares the `channel:open_failed`
- [x] `socks5_open_spec` declares the `channel:open_failed`
`ErrorDefinition` (the alktty-ported schema, adapted) — or the
doc is reworded to the honest empty posture with the reason
recorded
- [ ] A test pins the declaration (mirroring alktty's) — or the
- [x] A test pins the declaration (mirroring alktty's) — or the
reworded doc matches the spec exactly
- [ ] The `feed` let-else is restructured; zero behavior change
- [x] The `feed` let-else is restructured; zero behavior change
(the wire suite green unchanged)
- [ ] `is_mid_frame`'s doc names the anticipated consumer
- [ ] `cargo test` green; clippy/fmt clean; both wasm checks clean;
- [x] `is_mid_frame`'s doc names the anticipated consumer
- [x] `cargo test` green; clippy/fmt clean; both wasm checks clean;
`cargo doc --no-deps` clean
## References
@@ -82,8 +82,82 @@ postures (`docs/reviews/002-protocol-core-implementation-review.md`):
## Notes
> Agent fills this during implementation.
- **D-3 — declared, not reworded.** The review's lean (the declare
side) worked with no substrate constraint: the registry accepted
the definition on the first try. The schema is alktty's
`channel:open_failed` block
(`/workspace/@alkdev/alktty/src/channels.rs:165-208`), adapted:
the `reason` enum carries all five ADR-049 §3 codes
(`dial_failed` / `unknown_resource` / `resource_shortage` /
`handler_error` / `timeout`) — alktty's enum has four because its
establisher has no `resource_shortage` path, while this crate's
declared vocabulary is chosen to match
`SocksEstablishmentReason`'s parse table exactly (the typed view a
consumer branches on), not the current default establisher's
reachable subset (`socks5_session_establisher` is a session gate
returning `Establishment::default()`; a composed/registry
establisher could produce any of the five). The `description`
text is rewritten to this crate's establishment story: the
registry gate classes first (`FORBIDDEN` / `INVALID_INPUT` /
`channel:too_many_channels` — the ACL runs before the
establisher, ADR-006), then the establishment vocabulary, then
the no-phantom-channel property. One judgment call worth noting
for the review round: the declared enum is *wider* than the
default producer's behavioral surface (which produces none of the
five today — the dial is in-stream, post-open). That is the
correct direction to over-declare: `error_schemas` discloses the
op's contract shape (any registration of this op, per ADR-049
§4), and the enum is the wire's parse table
(`SocksEstablishmentReason::parse`), so a stricter enum would
under-declare for custom-establisher registrations.
- **The pinning test cross-checks schema vs typed vocabulary.**
Beyond mirroring alktty's declaration pin
(`:780-807`), `open_spec_declares_the_open_failed_error_definition`
asserts each enum value round-trips through
`SocksEstablishmentReason::parse`/`as_str` — the declared schema
and the typed vocabulary cannot drift silently (the exact D-3
drift class, pinned shut).
- **N-3 — restructured to a live-else shape, not the review's
sketch.** Both of the review's alternates were considered: the
`let Some(&mut (declared, ref mut acc))` match has the same
dead-arm problem (it must fire *after* the header read, which is
exactly the unreachable region), and the re-order-to-drop-else
sketch inverts the loop's exit order. The landed shape folds the
header read into the let-else's else arm
(`let Some((declared, acc)) = self.current.as_mut() else {
<read header; continue; }`) — every branch is live, the
"current set above" invariant is structural (the else arm is the
only place `current` is set), and the body is untouched. Zero
behavior change: the full wire suite passes unmodified.
- **N-9 — kept with the note.** One doc paragraph naming the
anticipated batch-2 consumer (a front-door bridge driving its own
reader loop — the doors) and citing the review finding.
## Summary
> Agent fills this on completion.
All three residue items closed in one pass (`src/params.rs`,
`src/wire.rs`):
1. **D-3**: `socks5_open_spec` now declares the
`channel:open_failed` `ErrorDefinition` — alktty-ported schema
(`{ reason (enum of the five ADR-049 §3 codes), message }`,
both required), description adapted to this crate's gate classes
+ establishment story. Module doc updated from claim to fact.
Pinned by `open_spec_declares_the_open_failed_error_definition`
(declaration + enum round-trips through
`SocksEstablishmentReason` — schema and typed vocabulary pinned
drift-free).
2. **N-3**: `DatagramReader::feed`'s structurally-unreachable
let-else restructured into a live-else shape (header read in the
else arm); zero behavior change — the wire suite green unchanged.
3. **N-9**: `is_mid_frame` kept; its doc names the anticipated
consumer (the batch-2 front-door bridges) so future dead-surface
sweeps don't flag it.
Verification: `cargo test` 357 passed / 0 failed (all suites);
`cargo clippy --all-targets -- -D warnings` clean; `cargo fmt
--check` clean; `cargo doc --no-deps` clean; `cargo check
--target wasm32-unknown-unknown` clean; `cargo clippy --target
wasm32-unknown-unknown -- -D warnings` clean. Doc-vs-code drift is
gone either way (review-002 D-3 closed; the review-round gate item
"the `ErrorDefinition` is declared" holds).