edge-roll-blip: implementation plan (6 tasks, D10 first)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
1 file changed,
+366
−0
docs/superpowers/plans/2026-10-27-edge-roll-blip.md+366 −0
CI passed — run details
Intent
diff --git a/docs/superpowers/plans/2026-10-27-edge-roll-blip.md b/docs/superpowers/plans/2026-10-27-edge-roll-blip.md| new file mode 100644 |
| index 000000000..10396f8bf |
| --- /dev/null |
| +++ b/docs/superpowers/plans/2026-10-27-edge-roll-blip.md |
| @@ -0,0 +1,366 @@ |
| +# Edge roll blip (#434 part B) Implementation Plan |
| + |
| +> **For agentic workers:** REQUIRED SUB-SKILL: Use superpowers:subagent-driven-development (recommended) or superpowers:executing-plans to implement this plan task-by-task. Steps use checkbox (`- [ ]`) syntax for tracking. |
| + |
| +**Goal:** When a loopback or unix upstream restarts, requests through the edge wait for it |
| +instead of getting 502 or 503, and the edge logs one line once its own listeners are bound. |
| + |
| +**Architecture:** One deadline-bounded retry loop (`retryLocalDial`) shared by unix dials and a |
| +new loopback TCP dial (D10). Probed routes with a local addr retry live-set passes until a |
| +computed hold (D10b), without dialing ejected upstreams. Hold settings live on each `Edge` |
| +(`localHold`), never in mutable globals. D8 binds before serving and logs the bound addresses. |
| + |
| +**Tech Stack:** Go 1.26, `net/http`, `httputil.ReverseProxy`, `net/netip`. Package |
| +`internal/edge` only. |
| + |
| +**Spec:** `docs/superpowers/specs/2026-10-27-edge-roll-blip-design.md` (rev 4). Read §2-§6 and |
| +§10 before any task. |
| + |
| +## Global Constraints |
| + |
| +- Hold values (spec §2-§3): `localDialHold = 13 * time.Second`, `localHoldCap = 30 * time.Second`, |
| + `probeTimeout = 2 * time.Second` (all stay `const`), retry/poll step 100 ms, |
| + `multiDialTimeout` 3 s unchanged. |
| +- `localHold.dial <= 0` turns D10 off (today's transport, no `DialContext` wrapper); |
| + `Hold` returns `(0, false)` when `dial <= 0` or `cap <= 0`, which turns D10b off. |
| +- No test mutates a package global. Tests build their Edge with `newEdge(reg, act, hold)`. |
| +- Causes unchanged: refused past hold `CauseRefused` (502); a cut stalled TCP attempt |
| + `CauseTimeout` (502); probed past hold `CauseNoUpstream` (503 + `Retry-After: 2`). |
| +- Operator log lines only, no member copy; neutral hosts (`shop.example.com`). No unit file, |
| + root, updater, install or rollback change. |
| +- Tests: only `./internal/edge/` with `-run`, `-count=1`. Never `make test` or the full suite; |
| + CI runs it. Leave `GOCACHE` at its default. The sandbox mounts `~/.cache/go-build` |
| + read-only and refuses unix `socket()`, so run `go test`/`go build` outside it. |
| +- Unix sockets: use `shortSockDir(t)` (`internal/edge/door_test.go:902`); `genSockDir(t)` |
| + (`genproxy_test.go:112`) is the same shape. Both `os.MkdirTemp("", ...)` under `$TMPDIR`. If |
| + a socket test fails with `bind: invalid argument` (sun_path too long), rerun it with |
| + `mkdir -p /tmp/g && TMPDIR=/tmp/g go test ...`; the sockets are removed by the helpers' |
| + cleanup. |
| +- Commits end with `Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>`. Never |
| + `git stash`, `git checkout -- <file>`, pattern deletes. |
| +- Rule 3 (AGENTS.md): no task touches a security gate, root, termination, a cache, |
| + production storage, billing or a redirect, so no per-task Astra/Opus review; one |
| + whole-branch review before merge. |
| + |
| +## Review Focus |
| + |
| +1. Tests elsewhere that reach a refused loopback addr through `edge.New` (root `e2e_test.go`, |
| + `deploy_e2e_test.go`, `internal/host/applessroute_test.go`, `internal/fleetapi`) now wait |
| + 13 s or more instead of failing fast. Expected: CI durations barely move; if one slows, the |
| + fix is its own route, not a weaker hold. Task 1 Step 6 covers this package's set. |
| +2. `localhost:P` resolves to both `::1` and `127.0.0.1`; refused on both must still retry |
| + (Task 1, `TestLoopbackAddrRouteHolds/localhost`). |
| +3. Many requests held at once on a down upstream all release at the hold, with no goroutine |
| + left behind (Task 1, `TestHeldDialsReleaseAfterHold`). |
| +4. A Reload during a held probed request: the request keeps its entry deadline and sees the |
| + new live set (Task 4, `TestProbedHoldSurvivesReload`). |
| +5. A stalled loopback attempt (accepting nothing) is cut at the deadline, not 3 s or 13 s |
| + later (Task 1, `TestRetryLocalDialBlockingAttemptEndsAtDeadline`; Task 4, |
| + `TestProbedDeadlineMidPassDoesNotEject`). |
| + |
| +--- |
| + |
| +### Task 1: Loopback TCP routes hold the dial (D10) |
| + |
| +Rule 3 gates: no. |
| + |
| +**Files:** |
| +- Create: `internal/edge/localhold.go`, `internal/edge/localhold_test.go` |
| +- Modify: `internal/edge/edge.go` (`Edge` struct; `New` at `:457`; `tcpProxy` calls at |
| + `:851,864`; `tcpProxy` at `:2736`), `internal/edge/answered.go:58-64` (comment gains |
| + loopback TCP and probed routes) |
| +- Modify (tests that need the old instant failure): `internal/edge/edge_test.go`, |
| + `internal/edge/edgeerrors_test.go` |
| + |
| +**Interfaces (Produces):** |
| +```go |
| +const localDialHold = 13 * time.Second |
| +const localHoldCap = 30 * time.Second |
| +type localHold struct { |
| + dial, cap, probe time.Duration |
| + dialer func(ctx context.Context, network, addr string) (net.Conn, error) // test seam; nil = net.Dialer |
| +} |
| +func defaultLocalHold() localHold // {localDialHold, localHoldCap, probeTimeout, nil} |
| +func isLocalUpstream(addr string) bool |
| +var errHoldExpired = fmt.Errorf("edge: local upstream hold expired: %w", context.DeadlineExceeded) |
| +func retryLocalDial(ctx context.Context, deadline time.Time, attempt func(context.Context) (net.Conn, error)) (net.Conn, error) |
| +func newEdge(reg *registry.Registry, act Activator, hold localHold) (*Edge, error) // New = newEdge(reg, act, defaultLocalHold()) |
| +func tcpProxy(addr string, hold localHold) *httputil.ReverseProxy |
| +// test helper in localhold_test.go: |
| +func noHold() localHold // localHold{probe: probeTimeout} |
| +``` |
| + |
| +- [ ] **Step 1: Write the failing tests** in `localhold_test.go`: |
| + - `TestIsLocalUpstream`: true for `127.0.0.1:80`, `127.9.9.9:80`, `[::1]:80`, |
| + `localhost:80`; false for `10.0.0.5:80`, `example.com:80`, `nonsense`. |
| + - `TestRetryLocalDialServesWhenUpstreamReturns`: attempt returns `ECONNREFUSED` (wrapped in |
| + `*net.OpError`) twice, then a `net.Pipe` end; got conn, 3 attempts. |
| + - `TestRetryLocalDialReturnsLastRefusalAtDeadline`: always refused, deadline now+300 ms; |
| + `errors.Is(err, syscall.ECONNREFUSED)`, elapsed in [300 ms, 450 ms). |
| + - `TestRetryLocalDialBlockingAttemptEndsAtDeadline`: attempt blocks on `<-actx.Done()` and |
| + returns `actx.Err()`; deadline now+200 ms; `errors.Is(err, errHoldExpired)` and |
| + `errors.Is(err, context.DeadlineExceeded)`, elapsed < 300 ms. |
| + - `TestRetryLocalDialNonRetryableFailsAtOnce`: `errors.New("boom")`, exactly one attempt. |
| + - Edge-level, each on `newEdge(reg, nil, localHold{dial: d, probe: probeTimeout})` behind |
| + `httptest.NewServer(e)`, route `{Host: "shop.example.com", Kind: "service", Status: |
| + "ready", Addr: a}`: |
| + - `TestLoopbackAddrRouteHolds` with subtests `127.0.0.1` and `localhost`: `a` from |
| + `deadAddr(t)` (host swapped to `localhost` in the second); a listener answering 200 on |
| + `a` starts after 300 ms; `d` 2 s; GET gives 200. |
| + - `TestLoopbackAddrRouteRefusedPastHold`: `d` 200 ms, nothing listens; 502, and with |
| + `e.EnableErrors(sink)` (`memErrSink`, `edgeerrors_test.go:21`) the record's cause is |
| + `apperr.CauseRefused`. |
| + - `TestNonLoopbackAddrRouteFailsAtOnce`: `a` = `10.0.0.5:80`, `hold.dialer` counts calls |
| + and returns a refused `*net.OpError`; 502 within 100 ms, exactly 1 call. |
| + - `TestHeldDialClientCancelReturnsAtOnce`: dead `a`, `d` 2 s, client request context |
| + times out at 100 ms; `Do` returns within 300 ms. |
| + - `TestHeldDialPOSTBodyArrives`: upstream starts after 300 ms and echoes the body; a |
| + 64 KiB POST body arrives byte-identical. |
| + - `TestHeldDialWebSocketUpgrade`: `upgradeEchoBackend` (as in `edge_test.go:2030`) started |
| + on a reserved port after 300 ms; the upgrade echoes. |
| + - `TestHeldDialsReleaseAfterHold`: 50 concurrent GETs, `d` 300 ms, all 502 within 1 s; |
| + `runtime.NumGoroutine()` returns to within 10 of its baseline within 2 s. |
| + - `TestLocalHoldOffKeepsInstant502`: `noHold()`, dead `a`; 502 within 100 ms. |
| + |
| +- [ ] **Step 2: Run, expect FAIL (undefined: `isLocalUpstream`, `newEdge`, ...)** |
| + |
| +Run: `go test ./internal/edge/ -run 'TestIsLocalUpstream|TestRetryLocalDial|TestLoopbackAddrRoute|TestNonLoopbackAddrRoute|TestHeldDial|TestLocalHoldOff' -count=1` |
| + |
| +- [ ] **Step 3: Implement `localhold.go`** |
| + |
| +`isLocalUpstream`: `net.SplitHostPort`, then `host == "localhost"` or |
| +`netip.ParseAddr(host)` ok and `IsLoopback()`. `retryLocalDial` per spec §2 "One deadline": |
| +each attempt on `context.WithDeadline(ctx, deadline)`; on error, if `ctx.Err() != nil` return |
| +it; if the attempt context is done (deadline cut, parent not) return `errHoldExpired`; if not |
| +`isRetryableDialErr`, return it; if no time left, return it; else wait min(100 ms, time left) |
| +or `ctx.Done()`. It always makes the first attempt. |
| + |
| +- [ ] **Step 4: Wire the Edge** |
| + |
| +Add `hold localHold` to `Edge`; `New` becomes `newEdge(reg, act, defaultLocalHold())`, with |
| +`e.hold` set before the startup Reload. `tcpProxy(addr, hold)`: when `hold.dial > 0 && |
| +isLocalUpstream(addr)`, `Transport.DialContext` = fixed `deadline := time.Now().Add(hold.dial)` |
| +then `retryLocalDial` over `hold.dialer` or a `net.Dialer{}`; otherwise |
| +`Transport.DialContext = hold.dialer` (nil in production: today's transport). Both call sites |
| +pass `e.hold`. Update the `answered.go:58-64` comment. |
| + |
| +- [ ] **Step 5: Run Step 2's command, expect PASS** |
| + |
| +- [ ] **Step 6: Keep the package's refused-loopback tests fast** |
| + |
| +Run: `go test ./internal/edge/ -run 'TestEdgeFilesUnavailableByCause|TestLegacySingleAddrRouteUnchanged|TestMultiAddrWithoutHealthServesFirstUnprobed' -count=1 -v` |
| +Any that now takes 13 s or more (unprobed route on `deadAddr`) switches its `New(reg, nil)` to |
| +`newEdge(reg, nil, noHold())`; its assertions stay as they are. Rerun, expect PASS, each |
| +under 1 s. |
| + |
| +- [ ] **Step 7: Commit** `edge-roll-blip: D10, loopback TCP routes hold the dial` |
| + |
| +### Task 2: Restart witness (`tcp`, `unix`, negative control) |
| + |
| +Rule 3 gates: no. |
| + |
| +**Files:** |
| +- Create: `internal/edge/localhold_witness_test.go` |
| + |
| +**Interfaces:** |
| +- Consumes: `newEdge`, `localHold`, `noHold()` (Task 1); `openReg`, `shortSockDir`. |
| +- Produces: `runRestartWitness(t *testing.T, e *Edge, listen func() (net.Listener, error)) witnessStats` |
| + (`listen` binds the upstream's fixed address, called once per server), |
| + and `witnessStats{requests, ok, s502, s503, other int; p50, p99, max time.Duration}` (added |
| + wait), reused by Task 4's `probed` subtest. |
| + |
| +- [ ] **Step 1: Write `TestLocalUpstreamRestartWitness`** per spec §6: `testing.Short()` skips; |
| + subtests `t.Parallel()`, each on its own `newEdge` and `httptest.NewServer(e)`: |
| + - `tcp`: unprobed `Addr` route to a reserved `127.0.0.1:P`, `defaultLocalHold()`. |
| + - `unix`: `Socket` route under `shortSockDir(t)`; `runtime.GOOS == "windows"` skips. |
| + - `tcp-hold-off` (negative control): as `tcp` on `newEdge(reg, nil, noHold())`. |
| + The runner: upstream `http.Server` answering `/` and `/healthz` 200; eight workers on |
| + keep-alive clients send `GET /` with Host `shop.example.com`; 1 s baseline; then |
| + `Shutdown` with a 5 s drain context, a 1.5 s gap (port refuses or socket file absent), a new |
| + `http.Server` on the same address; 1 s more. Count by status, transport errors as `other`. |
| + Added wait = latency minus baseline p50. Each subtest logs: |
| + ```go |
| + t.Logf("local-hold witness: route=%s gap=%v requests=%d ok=%d 502=%d 503=%d other=%d added_wait p50=%v p99=%v max=%v", ...) |
| + ``` |
| + Pass for `tcp` and `unix`: `s502 == 0 && s503 == 0 && other == 0` and `max < gap+time.Second`. |
| + Pass for `tcp-hold-off`: `s502 > 0`. |
| + |
| +- [ ] **Step 2: Run, expect PASS with three log lines** |
| + |
| +Run: `go test ./internal/edge/ -run TestLocalUpstreamRestartWitness -count=1 -v` |
| + |
| +- [ ] **Step 3: Prove it can fail.** Temporarily give the `tcp` subtest `noHold()`; rerun; |
| + expect FAIL on `s502`. Restore by editing the line back (never `git checkout --`). |
| + |
| +- [ ] **Step 4: Commit** `edge-roll-blip: local restart witness (tcp, unix, hold-off control)` |
| + |
| +### Task 3: Unix dials on the shared loop and constant |
| + |
| +Rule 3 gates: no. |
| + |
| +**Files:** |
| +- Modify: `internal/edge/genproxy.go:39-63` (`dialUnixRetrying` body becomes a |
| + `retryLocalDial` call with `deadline := time.Now().Add(localDialHold)`, resolving the socket |
| + inside the attempt), `:85-86` (`dialGen`: same deadline, each attempt on |
| + `context.WithDeadline`, wait min(100 ms, time left)), `:311-312` (`waitServingGen` on |
| + `localDialHold`); `internal/edge/edge.go:3502-3508` (comment names `localDialHold`). |
| + |
| +**Interfaces:** Consumes `retryLocalDial`, `localDialHold` (Task 1). Produces nothing new. |
| + |
| +- [ ] **Step 1: Make the change**; `grep -n '13 \* time.Second' internal/edge/genproxy.go` |
| + returns nothing. |
| +- [ ] **Step 2: Run the existing unix and generation tests, expect PASS unchanged** |
| + |
| +Run: `go test ./internal/edge/ -run 'TestDialUnixRetrying|TestAppSocketProxy|TestGenPools|TestGenRoundTripper|TestUnixSocketUpstream|TestLocalUpstreamRestartWitness/unix' -count=1` |
| + |
| +- [ ] **Step 3: Commit** `edge-roll-blip: unix dials share the local hold loop and window` |
| + |
| +### Task 4: Probed routes with a local upstream wait for readmission (D10b) |
| + |
| +Rule 3 gates: no. |
| + |
| +**Files:** |
| +- Modify: `internal/edge/prober.go` (`newProberSet` at `:126`, `newHostProber` at `:188`, |
| + `Sync` call at `:292`, new `Hold`), `internal/edge/edge.go` (`newEdge` builds |
| + `newProberSet(hold)`; `multiProxy` at `:2817` and its call at `:871`) |
| +- Modify: `internal/edge/prober_test.go` (nine `newProberSet()` calls become |
| + `newProberSet(defaultLocalHold())`), `internal/edge/edge_test.go` |
| + (`TestSingleAddrWithHealthGets503Semantics`, `TestAllUpstreamsDownAnswers503WithRetryAfter` |
| + and any other probed `deadAddr` test that now waits switch to `noHold()`), |
| + `internal/edge/localhold_witness_test.go` (`probed` subtest) |
| +- Create: `internal/edge/localhold_probed_test.go` |
| + |
| +**Interfaces:** |
| +- Consumes: `localHold`, `isLocalUpstream`, `newEdge`, `runRestartWitness`. |
| +- Produces: |
| +```go |
| +func newProberSet(hold localHold) *proberSet // client Timeout and ResponseHeaderTimeout = hold.probe |
| +func newHostProber(spec probeSpec, client *http.Client, hold localHold) *hostProber // records hp.local, hp.hold |
| +func (p *proberSet) Hold(host string) (time.Duration, bool) // unknown host: (0, false) |
| +func multiProxy(host string, p *proberSet, hold localHold) *httputil.ReverseProxy |
| +``` |
| + |
| +- [ ] **Step 1: Write the failing tests** in `localhold_probed_test.go`: |
| + - `TestHoldMatchesFormula` (table, `newHostProber` with `defaultLocalHold()` on |
| + `WithDefaults()`ed specs): one local addr 19 s; local + 1 other 23 s; + 2 27 s; + 3 30 s |
| + (cap); remote-only `(0, false)`; raw `Health{}`, `IntervalMS: -1`, `RiseAfter: -1` each |
| + 19 s; `dial: 0` gives `(0, false)`. |
| + - Behaviour, each through `newEdge` + `httptest.NewServer`, route `Addrs` + `Health: |
| + healthJSON(t, provision.Health{Path: testProbePath, IntervalMS: 100, FailAfter: 1, |
| + RiseAfter: 2})`, hold `localHold{dial: 300ms, cap: 5s, probe: 50ms}` unless stated: |
| + - `TestProbedLocalUpstreamWaitsForReadmission`: the upstream (`countingBackend`-style on a |
| + reserved port) is stopped, a GET is sent, it restarts after 200 ms; 200, and its |
| + proxied-request counter is exactly 1 (nothing reached it while ejected). |
| + - `TestProbedEmptyLiveSetOnArrivalWaits`: as above but the GET waits until |
| + `len(e.probers.Live(host)) == 0` first; 200. |
| + - `TestProbedLocalStillDownPastHold`: never restarts; 503, `Retry-After: 2`, cause |
| + `CauseNoUpstream`, elapsed within 150 ms of `Hold(host)`. |
| + - `TestProbedPastCapAnswersAtCap`: `cap: 400ms` (below `dial + R`); 503 within 150 ms of |
| + 400 ms. |
| + - `TestProbedRemoteOnlyAnswersAtOnce`: `Addrs` `10.0.0.5:80`, `hold.dialer` refuses; 503 |
| + within 100 ms. |
| + - `TestProbedMixedSetWithLiveUpstreamServesAtOnce`: `deadAddr` plus a live backend; 200 |
| + within 100 ms. |
| + - `TestProbedDelayedProbeServedWithinR` (spec §10 "Delayed probe"): three loopback |
| + upstreams whose `/healthz` blocks past `probe`, ordered before one restarting |
| + upstream; served at readmission, measured readmission at most `R` from the formula. |
| + - `TestProbedDeadlineMidPassDoesNotEject`: `Addrs` `deadAddr` + `10.0.0.9:80`, |
| + `frozenHealth()`, `cap: 400ms`, `hold.dialer` blocks on `10.0.0.9:80` until its |
| + context ends; 503 `CauseNoUpstream` within 150 ms of 400 ms, and |
| + `e.probers.Live(host)` still contains `10.0.0.9:80`. |
| + - `TestProbedHoldSurvivesReload`: upstream down, GET in flight, `e.Reload()` after 100 ms, |
| + upstream back after 200 ms; 200. |
| + - In the witness: subtest `probed`, `Addrs` route to `127.0.0.1:P`, `Health{Path: |
| + "/healthz", IntervalMS: 100, FailAfter: 1, RiseAfter: 2}`, `defaultLocalHold()`; pass |
| + when zero failures and `max < gap + R`, with `R` from `Hold`'s formula. |
| + |
| +- [ ] **Step 2: Run, expect FAIL** |
| + |
| +Run: `go test ./internal/edge/ -run 'TestHoldMatchesFormula|TestProbed|TestLocalUpstreamRestartWitness' -count=1 -v` |
| + |
| +- [ ] **Step 3: Implement the hold in `prober.go`.** In `newHostProber`, after clamping: |
| + `N = len(hp.order)`, `I = hp.interval`, `r = hp.riseAt`, `T = hold.probe`; |
| + `G = max(I, T) + (N-1)*T`; `R = r*G + T`; `hp.hold = min(hold.dial+R, hold.cap)`; |
| + `hp.local` = any `hp.order` addr passes `isLocalUpstream`, and false when `hold.dial <= 0` |
| + or `hold.cap <= 0`. `proberSet` keeps `hold` for `Sync`'s `newHostProber` call. |
| + |
| +- [ ] **Step 4: Implement the passes in `multiProxy`'s `DialContext`** (spec §3): |
| +```go |
| +hold, local := p.Hold(host) |
| +var deadline time.Time |
| +if local { deadline = time.Now().Add(hold) } |
| +for { |
| + // one pass: today's walk over a fresh p.Live(host); each attempt on |
| + // context.WithTimeout(ctx, multiDialTimeout), and also WithDeadline(deadline) when local; |
| + // dial via hold.dialer when non-nil. |
| + // A failed attempt with ctx.Err() != nil: return it, no Eject (today). |
| + // A failed attempt after the deadline has passed: budget exhaustion, no Eject, |
| + // return errNoLiveUpstream. Any other failure: Eject, next addr (today). |
| + // No connection: if !local or no time left, return errNoLiveUpstream (wrapped as today); |
| + // else wait min(100ms, time left) or ctx.Done(), and pass again. |
| +} |
| +``` |
| + An empty live set is a pass with nothing to dial. `ErrorHandler` unchanged. |
| + |
| +- [ ] **Step 5: Run Step 2's command, expect PASS** |
| + |
| +- [ ] **Step 6: Keep the existing probed tests fast** |
| + |
| +Run: `go test ./internal/edge/ -run 'TestMultiUpstream|TestDialFailureRetriesOtherUpstream|TestSingleAddrWithHealth|TestAllUpstreamsDown|TestUpstreamStates|TestProber|TestEjectIsImmediate|TestAliasSharesMultiUpstreamEntry' -count=1 -v` |
| +Any that now waits for a hold switches to `newEdge(reg, nil, noHold())`; rerun, expect PASS. |
| + |
| +- [ ] **Step 7: Commit** `edge-roll-blip: D10b, probed local upstreams wait for readmission` |
| + |
| +### Task 5: D8, bind before serving and log the bound listeners |
| + |
| +Rule 3 gates: no. The :80 handler (ACME and redirect) and the TLS config are untouched; only |
| +how the listeners are bound changes, as `ListenAndServe(TLS)` does it internally. |
| + |
| +**Files:** |
| +- Create: `internal/edge/listeners.go`, `internal/edge/listeners_test.go` |
| +- Modify: `internal/edge/edge.go:3642-3649` (dev block), `:3814-3829` (http + https) |
| + |
| +**Interfaces (Produces):** |
| +```go |
| +func listenAddr(flag, def string) string // "" -> def (":http" or ":https"), else flag |
| +func listen(name, flag, def string) (net.Listener, error) // err: fmt.Errorf("edge: %s listener %s: %w", name, flag, err) |
| +func listenersLine(httpLn net.Listener, httpFlag string, httpsLn net.Listener, httpsFlag string) string // httpsLn nil = dev form |
| +``` |
| + |
| +- [ ] **Step 1: Write the failing tests** |
| + - `TestListenAddrNormalizesEmpty`: `("", ":http")` gives `:http`; `("", ":https")` gives |
| + `:https`; `("127.0.0.1:8080", ":http")` gives `127.0.0.1:8080`. |
| + - `TestListenNamesTheListenerOnFailure`: hold `127.0.0.1:0`'s port with one listener, then |
| + `listen("http", addr, ":http")`; error starts `edge: http listener 127.0.0.1:`. |
| + - `TestListenersLineGivesBoundAddresses`: two `listen` calls on `127.0.0.1:0`; the line is |
| + exactly `fmt.Sprintf("edge: listeners: bound http %s and https %s itself (flags %q %q)", |
| + h.Addr(), s.Addr(), "127.0.0.1:0", "127.0.0.1:0")` and does not contain `:0 `. |
| + - `TestListenersLineDevForm`: `listenersLine(h, "127.0.0.1:0", nil, "")` is |
| + `fmt.Sprintf("edge: listeners: bound http %s itself (dev mode; flag %q)", h.Addr(), "127.0.0.1:0")`. |
| + |
| +- [ ] **Step 2: Run, expect FAIL** |
| + |
| +Run: `go test ./internal/edge/ -run 'TestListenAddr|TestListenNames|TestListenersLine' -count=1` |
| + |
| +- [ ] **Step 3: Implement `listeners.go`; wire `RunWithActivatorReady`.** Bind on the calling |
| + goroutine before the serve goroutines: `listen("http", *httpAddr, ":http")`, then (not dev) |
| + `listen("https", *httpsAddr, ":https")`, `log.Fatal(err)` on failure; `log.Print` the |
| + line; the goroutines call `srv.Serve(ln)` and `httpsSrv.ServeTLS(ln, "", "")`, keeping the |
| + `http.ErrServerClosed` check and today's `serving N route(s)` / `DEV MODE` lines. |
| + |
| +- [ ] **Step 4: Run Step 2's command, expect PASS** |
| + |
| +- [ ] **Step 5: Commit** `edge-roll-blip: D8, bind before serving and log the bound listeners` |
| + |
| +### Task 6: Vet, format, cross-compile |
| + |
| +Rule 3 gates: no. |
| + |
| +- [ ] **Step 1:** `gofmt -l internal/edge/` prints nothing. |
| +- [ ] **Step 2:** `go vet ./internal/edge/` passes. |
| +- [ ] **Step 3:** `GOOS=darwin GOARCH=arm64 go build ./...` and |
| + `GOOS=windows GOARCH=amd64 go build ./...` both succeed (spec §5 D11). |
| +- [ ] **Step 4:** Once, the branch's new tests together: |
| + `go test ./internal/edge/ -run 'TestIsLocalUpstream|TestRetryLocalDial|TestLoopbackAddrRoute|TestNonLoopbackAddrRoute|TestHeldDial|TestLocalHoldOff|TestHoldMatchesFormula|TestProbed|TestListen|TestLocalUpstreamRestartWitness' -count=1 -v`; |
| + PASS, and copy the four `local-hold witness:` lines for the #434 reply. |
| +- [ ] **Step 5:** Commit any fixes as `edge-roll-blip: vet and gofmt`; otherwise nothing. |