Skip to content

refactor(server): extract the progression routes into routers/progression.py (R3) - #853

Merged
byrongamatos merged 1 commit into
mainfrom
refactor/r3-router-progression
Jul 10, 2026
Merged

refactor(server): extract the progression routes into routers/progression.py (R3)#853
byrongamatos merged 1 commit into
mainfrom
refactor/r3-router-progression

Conversation

@byrongamatos

@byrongamatos byrongamatos commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

4 progression routes (overview / add-paths / onboarding / events, spec 010) + their exclusive helpers (_goal_ui_progress, the 112-line _progression_overview) + the _PROGRESSION_EVENT_TYPES whitelist.

The two shared server accessors read through the seam: get_progression_content (landed for shop #851) and builtin_diagnostic_filename (new slot — a trivial const-returning fn shared with stats' api_record_stats). Both injected via the second appstate.configure() after their defs (the import-top configure runs before them). The cache + fns stay in server.py, so test_progression_api's server._progression_content patch is untouched — 0 retarget.

Bodies verbatim (@app@router, meta_dbappstate.meta_db, _clean_str from reqfields). server.py: 7,798 → 7,594.

Verification

  • Route table identical (143); both seam accessors wired; pyflakes clean.
  • pytest 2401 passed (63 in test_progression_api, whose _progression_content patch still works).
  • Boot smoke: GET /api/progression 200 (drives _progression_overview + both accessors); events 400 on bad body. npm run lint 0; Codex 0 findings.

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added progression APIs for viewing progression status, selecting paths, managing onboarding, and recording supported progression events.
    • Added detailed progression summaries, including goals, mastery, streaks, challenges, wallet status, and available paths.
    • Added validation for progression events and onboarding actions, with clear errors for invalid requests.
  • Documentation

    • Updated progression documentation to reflect the current router count.

…sion.py (R3)

4 routes (overview/add-paths/onboarding/events, spec 010) + their EXCLUSIVE
helpers (_goal_ui_progress, _progression_overview 112L) + the
_PROGRESSION_EVENT_TYPES whitelist. Bodies verbatim; @app -> @router,
meta_db -> appstate.meta_db, _clean_str from reqfields.

The two SHARED server accessors read through the seam: get_progression_content
(added for shop #851) and builtin_diagnostic_filename (new slot — a trivial
const-returning fn shared with the stats router's api_record_stats). Both are
injected via the second appstate.configure() after their defs (the import-top
configure runs before them). The cache + fns stay in server.py, so
test_progression_api's server._progression_content patch is untouched — 0 retarget.

server.py: 7,798 -> 7,594.

Verified: pyflakes clean; route table IDENTICAL (143); both seam accessors wired;
pytest 2401 passed (63 in test_progression_api); eslint 0. Boot smoke: GET
/api/progression 200 (drives _progression_overview + both accessors), events
400 on bad body.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@byrongamatos
byrongamatos merged commit f9f3332 into main Jul 10, 2026
4 checks passed
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Caution

Review failed

The pull request is closed.

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: d70b8877-cfe3-4564-8817-9fd780d9b0e4

📥 Commits

Reviewing files that changed from the base of the PR and between 5f58af4 and 8f3a191.

📒 Files selected for processing (4)
  • docs/size-exemptions.md
  • lib/appstate.py
  • lib/routers/progression.py
  • server.py

📝 Walkthrough

Walkthrough

The progression API was moved from server.py into lib/routers/progression.py. Application state now exposes builtin_diagnostic_filename, and the server registers the new router with the required dependencies. The server size-exemption documentation was updated accordingly.

Changes

Progression router extraction

Layer / File(s) Summary
Application-state seam
lib/appstate.py
Adds the builtin_diagnostic_filename application-state slot, defaulting to None and accepted by configure().
Progression router implementation
lib/routers/progression.py
Defines the progression router and its overview, path selection, onboarding, and validated event endpoints.
Server router wiring
server.py, docs/size-exemptions.md
Registers the progression router, supplies its appstate dependencies, removes the inline handlers, and updates the documented router count.

Estimated code review effort: 3 (Moderate) | ~20 minutes

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/r3-router-progression

Comment @coderabbitai help to get the list of available commands.

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