Skip to content

Refactor/solver modularization v1 - #194

Merged
Vhivi merged 10 commits into
mainfrom
refactor/solver-modularization-v1
Apr 25, 2026
Merged

Vhivi merged 10 commits into
mainfrom
refactor/solver-modularization-v1

Conversation

@Vhivi

@Vhivi Vhivi commented Apr 25, 2026

Copy link
Copy Markdown
Owner

Summary

Modularize the backend solver architecture and fix cross-year/weekend leave handling so scheduling logic is more maintainable and leave behavior is consistent between backend and frontend.

Changes

  • Extracted solver logic from backend/app.py into a modular solver package:
    • context container,
    • constraint registry,
    • grouped constraints (hard, soft, mixed),
    • objective builder,
    • dedicated solver engine orchestration.
  • Kept API contract stable by preserving generate_planning(...) facade behavior in routes.
  • Added modular solver regression coverage for registry wiring and key hard constraints.
  • Added planning-start-date propagation (planning_start_date) from route to solver engine.
  • Built deterministic full-date mapping for planning day labels in solver context.
  • Updated leave blocking logic to compare full resolved dates instead of dd-mm-only matching.
  • Updated backend leave helper to support reference-date-based year-safe resolution.
  • Updated PlanningTable to resolve day labels from planningStartDate and match leave/unavailable/training using full config dates (dd-mm-YYYY).
  • Ensured weekend days included in leave periods are rendered as Con..
  • Updated project docs/changelog for modular solver architecture and date-handling rules.

Tests

  • Backend modularization tests added (test_solver_modularization.py).
  • Backend regressions added for:
    • leave periods from another year not affecting target planning year,
    • leave helper weekend/reference-year behavior.
  • Frontend regressions added for:
    • no false leave match when dd-mm matches but year differs,
    • weekend leave rendering as Con. when weekend dates are inside leave range.
  • Full validation:
    • python -m pytest -q => 73 passed
    • npm test -- --runInBand => 2 passed suites, 7 passed tests

Why

This reduces solver monolith complexity and makes constraints easier to evolve safely, while fixing real leave-date correctness issues (year collisions and weekend rendering) in a way that keeps backend and frontend date semantics aligned.

@Vhivi Vhivi added bug Something isn't working documentation Improvements or additions to documentation backend frontend test javascript Pull requests that update javascript code labels Apr 25, 2026
@Vhivi Vhivi added this to the 4 - Tests et optimisation milestone Apr 25, 2026
@Vhivi Vhivi self-assigned this Apr 25, 2026
@Vhivi
Vhivi merged commit bc534a4 into main Apr 25, 2026
2 checks passed
@Vhivi
Vhivi deleted the refactor/solver-modularization-v1 branch April 25, 2026 13:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working documentation Improvements or additions to documentation frontend javascript Pull requests that update javascript code test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant