feat(debug): Tier 2 debugging aids#17
Merged
Merged
Conversation
Operational/debuggability improvements for the buy flow (PR 2 of the plan): - Correlation logging (logutil.correlated): wrap the worker and buy-flow loggers in a LoggerAdapter that prefixes each line with a provider/item/row token — the same token that names the screenshot files — so one buy's log lines, shots, and Sheet row grep together. - Full-page diagnostic screenshots: _screenshot now captures full-page for failure tags (no_price, no_place_order, cart_mismatch, blocked_*, challenge_*, signin_*, timeout, crash, …) so below-the-fold error banners aren't cropped; the review/confirmation/dump shots stay header-only for notifier size. - doctor --check-login: optional read-only session probe that relaunches each store profile (reusing verify_session) and reports LOGGED-IN / LOGGED-OUT, so an expired session is caught before a real order hits the sign-in wall. Default doctor stays browser-free. - Screenshot retention: a shots dir that grew unbounded is now pruned by the worker (startup + after each order) and via `roomieorder prune-shots`, gated by ROOMIEORDER_SHOTS_RETENTION_DAYS (default 30, 0 disables). Tests cover the correlation prefix, full-page tag selection + _screenshot wiring, prune_shots (age/disabled/missing-dir/artifact coverage), the new config vars, and the prune-shots / doctor --check-login CLI surfaces. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01J322vufhqKDvdJmukTZdkq
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PR 2 of the plan — Tier 2 (debugging aids), building on the merged Tier 1 safety rails (#16). These are observability/operability improvements; none touch the money-moving decision path. Tier 3 (operational features) remains for a follow-up.
2.1 Structured correlation logging
New
logutil.correlated()wraps the worker and buy-flow loggers in aLoggerAdapterthat prefixes each line with a shortkey=valuetoken (provider/item/row) — the same token that already names the screenshot files ({ts}_{provider}_{item}_{tag}.png). One buy's log lines, screenshots, and Sheet row now grep together instead of being reconstructed by hand.2.2 Full-page diagnostic screenshots
_screenshotpreviously capturedfull_page=Falsealways, cropping error banners / mismatched cart lines / disabled controls below the fold — exactly what you need for triage. A module-level_FULL_PAGE_TAGSset (+blocked_/challenge_/signin_prefixes) now captures diagnostic tags full-page (no_price,no_place_order,cart_mismatch,timeout,crash, …), while the happy-pathreview/confirmation/dumpshots stay header-only (they go over the notifier, where a tall PNG is just bulk).2.3
doctor --check-loginsession probedoctoronly checked profile directory existence — an expired session was discovered only when a real order hit the sign-in wall. The opt-in--check-loginflag relaunches each store profile read-only (reusing the buy flow'sverify_session) and reportsLOGGED-IN/LOGGED-OUT. Defaultdoctorstays browser-free and instant; only the flag launches Chrome, and a launch failure is awarn, not a hard fail.2.4 Screenshot retention / pruning
The shots dir (systemd
StateDirectory) grew unbounded. Newretention.prune_shots()deletes files older thanROOMIEORDER_SHOTS_RETENTION_DAYS(default 30, 0 disables). The worker prunes at startup and after each order (best-effort, never disrupts the loop);roomieorder prune-shots [--days N]runs the same sweep by hand.Tests
pytest(191 passed / 11 skipped),ruff, andmypy srcall green. New coverage:test_logutil.py— prefix formatting, empty-field dropping, no-token passthroughtest_retention.py— age cutoff, disabled (0), missing dir,*_dom.html/*_probe.txtcoveragetest_purchase.py—_is_full_page_tagmatrix +_screenshotpasses the rightfull_pagetest_cli.py—prune-shots(removes old / disabled),doctor --check-login(reports per-profile; default never probes)test_config.py—shots_retention_daysdefault + overrideDocs
README command list (
doctor --check-login,prune-shots),examples/env.example(ROOMIEORDER_SHOTS_RETENTION_DAYS), andAGENTS.mdscreenshot-tags section (adds thecart_mismatchtag from #16, the full-page behavior, and the retention note).Not in this PR (Tier 3, follow-up)
verify-order, proactive session-freshness notify, healthcheck heartbeat, and the remaining 3.4 doc fixes (status-enum sync,catalog show→catalog).🤖 Generated with Claude Code
Generated by Claude Code