2 Commits
Author SHA1 Message Date
lucioandClaude Opus 5 06122c66dd fix: single-reader CDP session; prime walk no longer fails silently
prime ran the in-page click walk as a task while drain() also read the
websocket. `websockets` forbids concurrent recv(), so this was always broken --
it just failed differently by version: loudly on websockets 15.0.1, and
silently on 16.0, where the JS still executed but its return value was lost.
The `walk: None` in every prime summary was that failure being swallowed by a
bare `except Exception`, and I read past it.

CDPSession now runs exactly one reader coroutine that dispatches command
replies to futures and events to a queue, so call() and drain() can safely run
concurrently -- which priming genuinely needs, since the requests being observed
are triggered by the script being awaited.

call() also gains a timeout so a lost reply fails instead of hanging, and the
walk now reports its error rather than reporting None.

Tests use a fake websocket that asserts the socket never has more than one
concurrent reader.

129 tests, no network required.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-07-25 09:27:24 -07:00
lucioandClaude Opus 5 5a61890011 feat: read-only Wodify athlete client
A CLI that answers "what classes ran", "who was there" and "what was the
workout" with a single HTTP POST each -- no browser at query time.

Wodify's athlete app is an OutSystems Reactive SPA. Driving it with a headless
browser works but is slow and, for an LLM agent, expensive: a full page render
to read a few lines back out of the DOM. Its data actions are plain JSON
endpoints, so this talks to them directly.

  wodify list date 2026-07-25      time, coach, booked/max, title, duration, ID
  wodify list workout <id>         attendee names + that class's workout

Two phases. `prime` attaches over CDP to a browser that is already logged in and
captures the session cookies, the CSRF token, and each action's apiVersion and
body shape. Everything after that is stdlib HTTP -- the query path has no
third-party dependencies at all.

Three things genuinely require the browser, which is why priming exists:
- the session bearer nr1W_Theme_UI is HttpOnly, so it cannot be exported by hand
- X-CSRFToken is not in cookies, localStorage, or any JS global
- apiVersion is per-action, not global

Read-only is enforced in code, not by the credential (Wodify issues no
read-only token): an explicit allowlist plus a write-marker guard applied even
to allowlisted paths, so a careless registry edit fails closed. Tests assert
that real mutating endpoint names are refused.

Responses are cached in SQLite, keyed by the local date they were fetched on, so
a repeat query the same day touches no network. All fetching funnels through
service.py so a call site cannot forget the cache.

Staleness is explicit rather than silent: responses carry
hasModuleVersionChanged/hasApiVersionChanged, and the client raises
VersionStale/SessionExpired instead of returning a plausible empty result. That
matters because every bug found while building this produced confident wrong
output rather than an error -- see CLAUDE.md for the field-name traps.

History squashed before first publication: earlier commits embedded real gym
members' names in test fixtures. Fixtures now use fictional names.

122 tests, no network required.

Co-Authored-By: Claude Opus 5 <[email protected]>
2026-07-25 09:23:19 -07:00