Repository navigation
fix(design-tweak): fix the born-red HTTPServer bind ratchet via the sanctioned _Server subclass - #17909
Conversation
…ver bind ratchet matches its baseline test_http_server_bind_ratchet records _BASELINE_SITES = 15 but the tree carries 16 bare HTTPServer((host, port), ...) constructions, so the ratchet has been red on every main head since it was added in #17450 (which itself shipped with 16 sites and a baseline of 15 -- the count was recorded one low). Rather than bump the baseline, apply the fix the ratchet's own docstring prescribes: subclass and call socketserver.TCPServer.server_bind so no host name is resolved. _Server already subclasses ThreadingHTTPServer for the address-reuse flag; give it the server_bind override (mirroring plumb_cpu.LoopbackServer) and construct it from start_inject_proxy instead of the stock ThreadingHTTPServer. That removes exactly one bare construction (16 -> 15) and hardens the overlay-injecting dev proxy against the macOS getfqdn stall the ratchet exists to prevent. The bind-failure test's patch target moves with the construction (ThreadingHTTPServer -> _Server); its assertion is unchanged. Fixes #17908
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing to check. [UX-REVIEWED] 270d60f Description read[DESCRIPTION-READ] 4351ddf431679f48a738b9804b77cf5dd4866a01b296b92f38ccc5f4b662504b That sha256 names everything this verdict read: the PR description, plus the 3 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Check that the inject proxy now sets SO_REUSEADDR on POSIX through [DESIGN-REVIEWED] 270d60f Description read[DESCRIPTION-READ] a2c8e5b1d4f3dc39b9ad96da8471a0645407cbd07e3272d4c5336f7529eb4880 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Check before merge: What this change shipsInventory (3 items) — 1 justifiedIntent: unblock every open PR by turning two deterministic base-side reds (shard 2 ratchet, shard 6 doc test) green. This is a FIX (#17908).
[FIRST-PRINCIPLES-REVIEWED] 270d60f Description read[DESCRIPTION-READ] 406995a9a2a9b5782525835111e4e84792687b59a19e52e8734ecb7689002e94 That sha256 names the PR description this verdict read. Recompute it with |
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
#17662 deleted the turn relay and with it every session_control.py raise of remote_target_unsupported, but the session-control page still tabulates it, so test_session_control_doc.py::test_every_tabulated_refusal_code_is_one_the_source_raises is red on main (shard 6, both Linux and Windows). This is the same one-line deletion as the open PR #17903. Carrying it here lets both base reds -- the HTTPServer bind ratchet (shard 2, this PR's own fix) and the doc row (shard 6) -- clear together, since #17903 fails on shard 2 and this PR failed on shard 6, so neither could go green alone.
iamwhatever
left a comment
There was a problem hiding this comment.
Review at head 270d60f (comment only; this account opened the PR).
| Check | Finding |
|---|---|
| Bind ratchet | dev_preview.py builds the inject proxy with runtime._Server; _Server.server_bind calls socketserver.TCPServer.server_bind and sets server_name/server_port, the same shape as plumb_cpu.LoopbackServer. The tree has 15 sites again; _BASELINE_SITES stays 15. |
| Side effect | The proxy now inherits allow_reuse_address = IS_POSIX. It binds port 0, so a reused address cannot collide. The main design-tweak server also skips getfqdn; nothing in design_tweak reads server_name. |
| Doc row | Drops remote_target_unsupported; git grep finds no raise of it under src/. |
| Test | test_bind_failure_returns_none patches _Server, matching the new constructor. |
| Local run | test_http_server_bind_ratchet.py, test_session_control_doc.py, test_design_tweak_relay_paths.py: 54 passed. |
No blocking findings. One leftover outside this diff: docs/feature-map/README.md still lists remote_target_unsupported among the reload refusals; no test reads it.
|
Self-review (crew-pr-reviewer, read-only): RECOMMEND APPROVE Reviewed head |
Problem / Motivation
Goal: Make
test_http_server_bind_ratchetpass onmainby routing one bareHTTPServerconstruction through the sanctioned subclass, so the ratchet matches its recorded baseline again.test/test_http_server_bind_ratchet.py::test_bare_http_server_constructions_match_the_recorded_countis deterministically red onmain(current heada2ca1b77f), which blocks the shard-2 Backend Tests lane — and therefore PR Readiness — on every open PR. It records_BASELINE_SITES = 15while the tree carries 16 bareHTTPServer((host, port), ...)/ThreadingHTTPServer((host, port), ...)constructions:Why it matters
A base-side red on a shard-2 ratchet fails that lane for every PR, so Readiness can never converge for anyone until it is fixed. The ratchet also guards a real failure mode:
http.server'sserver_bindresolvessocket.getfqdn(host)betweenbind()andlisten(), a system-resolver lookup that can stall on macOS runners while the socket is bound but refuses every connect — which a waiting parent reads as a server that never came up.Not a goal
_BASELINE_SITES, and no conversion of the other 15 sites (test fixtures and one further preview bind); they remain the baselined 15.What changed (motivation → approach → change)
Symptom: the ratchet is red (16 vs 15). Root cause: it was born red — the commit that introduced the test, #17450 (
781294256), already contained 16 matching sites but recorded_BASELINE_SITES = 15. The count was recorded one low; all 16 sites are legitimate ephemeral-port ("127.0.0.1", 0) binds.Approach: rather than bump the baseline, apply the fix the ratchet's own docstring prescribes — subclass and call
socketserver.TCPServer.server_bindso no host name is resolved (mirrorsplumb_cpu.LoopbackServer). The design-tweak backend already has a_Server(ThreadingHTTPServer)subclass (it overridesallow_reuse_address); extend it, and point one real production site at it.Change:
server.py: add aserver_bindoverride to_Serverthat binds throughsocketserver.TCPServer.server_bindand records the address directly, skippinggetfqdn.dev_preview.py:start_inject_proxynow constructsruntime._Serverinstead of the stockruntime.ThreadingHTTPServer.That removes exactly one bare construction (16 → 15) and hardens the overlay-injecting dev proxy — a server a waiting parent depends on — against the stall the ratchet exists to prevent.
Second commit — also carries #17903's doc fix so both base reds clear together. Main had a second deterministic red: shard 6's
test_session_control_doc.py::test_every_tabulated_refusal_code_is_one_the_source_raises, because #17662 deleted everysession_control.pyraise ofremote_target_unsupportedbut the page still tabulated it. The open PR #17903 fixes that with a one-line doc deletion — but #17903 fails on shard 2 (the ratchet) and this PR failed on shard 6 (the doc row), so neither could go green alone (a deadlock). This PR's second commit applies the identical one-line deletion fromsession-control.md, so merging either PR first clears both reds.Backwards compatibility
Removes nothing: the change swaps a stock
ThreadingHTTPServerconstruction for its existing subclass and adds aserver_bindoverride; no field, type, key, kind, or public function is rejected, renamed, or removed, and the dev proxy still binds an ephemeral port and returns the same(server, url)shape.Tests
test/test_http_server_bind_ratchet.py— now passes (2/2); the scan finds 15 sites, matching_BASELINE_SITES.test/test_design_tweak_relay_paths.py::TestStartInjectProxy— passes (8/8).test_bind_failure_returns_none'spatch.objecttarget moves with the construction (ThreadingHTTPServer→_Server); its assertion is unchanged.test/test_builtin_backend_address_reuse.py— passes;_Server's address-reuse behaviour is unaffected.test/test_session_control_doc.py— passes (10/10), includingtest_every_tabulated_refusal_code_is_one_the_source_raises, after the second commit removes the stale refusal row.Manual verification
N/A — unit coverage sufficient; the change is a server-construction swap exercised by the tests above.
Pattern harvest
Not generalizable: this is a one-off off-by-one in a single ratchet's recorded baseline at the commit that introduced it, not a recurring code pattern.
Related Issues
Fixes #17908