Skip to content

feat: add timeout-check report and refactor CLI args - #33

Merged
ldastey-dev merged 5 commits into
masterfrom
feat/timeout-check-and-cli-refactor
Aug 2, 2026
Merged

feat: add timeout-check report and refactor CLI args#33
ldastey-dev merged 5 commits into
masterfrom
feat/timeout-check-and-cli-refactor

Conversation

@ldastey-dev

Copy link
Copy Markdown
Owner

Summary

Adds a new timeout-check subcommand and refactors all existing subcommands to accept CLI arguments alongside environment variables.

New timeout-check subcommand

chesscom timeout-check 12345 67890          # specific matches
chesscom timeout-check all                  # all in-progress matches
chesscom timeout-check all --threshold 24   # custom threshold (hours)
  • Detects actual timeouts (played_as_white/black == "timeout")
  • Detects at-risk games by fetching board data and checking move_by against a configurable threshold (default 5 hours)
  • xlsx output: Tab 1 = alerts grouped by match; Tab 2 = player timeout counts (descending, timeouts > 0 only)
  • stdout output: concise per-match summary with flagged player counts and warnings for failed board fetches

CLI args refactoring (all 5 subcommands)

  • --club-ref and --club-name available on every subcommand (shared parent parser)
  • --year on match-participation
  • --clubs and --exclusion-club on prospects
  • --threshold on timeout-check
  • CLI args take precedence over env vars via _apply_cli_overrides()

Review findings addressed

Four-reviewer fleet (security, principal, architect, DevOps) identified 6 findings, all fixed:

  • HIGH: Exact slug matching to prevent team-scotland matching team-scotland-juniors
  • MEDIUM: Surface board fetch failures instead of silently swallowing
  • MEDIUM: CLI override semantics fixed to use is not None
  • MEDIUM: Domain function purity — injectable now parameter for testability
  • LOW: Threshold validation rejects negative/NaN/Inf
  • LOW: Stale doc reference fixed

Test coverage

270 tests passing (+54 new), lint and format clean.

ldastey-dev and others added 2 commits June 7, 2026 14:59
Add new timeout-check subcommand that inspects in-progress team matches
for actual timeouts and games where a team member's clock is running low.

New features:
- TimeoutCheckReport with two xlsx tabs (by-match alerts + by-player summary)
  plus concise stdout output
- get_match_board() API method for fetching board-level game data with
  move_by timestamps
- TimeoutAlert domain model and timeout risk analysis functions
  (calculate_hours_remaining, is_timeout_risk)
- TIMEOUT_THRESHOLD_HOURS configurable via env var (default: 5h)

CLI refactoring:
- All subcommands now accept --club-ref and --club-name flags
- match-participation accepts --year
- prospects accepts --clubs and --exclusion-club
- timeout-check accepts positional match IDs (or 'all') and --threshold
- CLI args take precedence over env vars via _apply_cli_overrides()
- Shared parent parser eliminates flag duplication

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
… DevOps reviews

Fixes applied:
- HIGH: Exact slug matching in _is_our_player() — parse final URL path
  segment instead of substring match to prevent team-scotland matching
  team-scotland-juniors
- MEDIUM: Surface board fetch failures — catch requests.RequestException
  specifically, track skipped boards, show warning in console summary
- MEDIUM: CLI override semantics — use 'is not None' consistently in
  _apply_cli_overrides() to match documented behaviour
- MEDIUM: Domain purity — inject optional 'now' parameter into
  calculate_hours_remaining() and is_timeout_risk() for deterministic
  testing
- LOW: Threshold validation — reject negative, zero, NaN, and Inf values
  for TIMEOUT_THRESHOLD_HOURS
- LOW: Fix stale AGENTS.md reference (4 → 5 concrete reports)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ldastey-dev
ldastey-dev force-pushed the feat/timeout-check-and-cli-refactor branch from 81344b3 to 82a8457 Compare June 7, 2026 14:01
ldastey-dev and others added 3 commits June 7, 2026 15:11
Add --cov-fail-under=90 to pytest command so PRs that drop below
the coverage threshold will fail CI.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Allow match IDs to be configured via .env as well as CLI positional
args. CLI args take precedence when provided; falls back to
TIMEOUT_MATCH_IDS env var. Raises a clear error if neither is set.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
- Add timeout-check subcommand documentation with .env and CLI examples
- Document common --club-ref and --club-name flags
- Show both .env-only, CLI-only, and mixed usage for every subcommand
- Update environment variables table with TIMEOUT_MATCH_IDS and
  TIMEOUT_THRESHOLD_HOURS
- Update project structure to include timeout_check.py and TimeoutAlert
- Note 90% coverage enforcement in CI section

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@ldastey-dev
ldastey-dev merged commit 5c31eed into master Aug 2, 2026
5 checks passed
@ldastey-dev
ldastey-dev deleted the feat/timeout-check-and-cli-refactor branch August 2, 2026 10:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant