Files
pad/internal
xarmian 2b33184ef1 fix(metrics,watchevents,server): three codex round-1 findings (BUG-2727)
1. pad_redis_up was registered unconditionally, so a deployment with no
   Redis exported a permanent 0 — which reads as "Redis is down" to
   anything scraping it and would have every single-process binary
   alerting on a dependency it does not have. It now registers only
   inside the PAD_REDIS_URL branch, matching /health/ready, which already
   omitted its redis block on the same condition. My own field comment
   claimed the absent behaviour while the code did the opposite.

2. The receive loop could report a false exit during shutdown: Close
   cancels the context AND closes the pubsub, and Go picks between ready
   select cases at random. A context re-check makes the outcome
   independent of that.

   Scope stated honestly, because it is narrower than the finding
   implies. With the guard removed, 200 Close cycles under publish
   traffic produced zero false exits — and removing it AND reversing
   Close's ordering still produced none, because Close waits on the
   receive goroutine and the goroutine observes the cancelled context
   either way. So no test fails if these three lines are deleted, and
   both the code comment and the test doc say so rather than implying
   coverage that does not exist. It is kept as defence against a future
   reordering, not as a fix for observed behaviour.

3. Corrupt session entries returned a list error without incrementing
   the failure counter, so pad_session_presence_failures_total
   under-reported precisely the case an operator is least likely to find
   another way — a dead Redis is obvious, a corrupt row is not. Both
   corrupt shapes now count. The non-string arm is unreachable through
   MGET (Redis answers nil for a key holding a non-string value,
   verified), so it is annotated as defensive and the test says no leg
   drives it instead of quietly covering only the reachable one.

Test-power notes are measured, not asserted: the Close test catches
removal of the select's ctx case (mutation-verified) and does not
discriminate the guard.

Claude-Session: https://claude.ai/code/session_01JVDBKbgn3Xt7ndW1YoYd8X
2026-08-22 01:55:59 +00:00
..
2026-03-26 01:52:36 +00:00