Skip to content

Enable exclusions with a single loop guarantee - #359

Merged
pyrech merged 1 commit into
mainfrom
pyrech/exclusions-between-participants
Aug 18, 2026
Merged

Enable exclusions with a single loop guarantee#359
pyrech merged 1 commit into
mainfrom
pyrech/exclusions-between-participants

Conversation

@pyrech

@pyrech pyrech commented Aug 15, 2026

Copy link
Copy Markdown
Member

Re-enables the exclusions feature from #314 (disabled in #318 because the algorithm could produce several loops).

Rudolph now builds a single chain (Hamiltonian cycle) with randomized backtracking instead of a giver/receiver matching, so associations always form exactly one loop. A step limit bounds the worst case on pathological exclusions.

Also:

  • reshuffle on the validate step now catches RudolphException instead of returning a 500
  • randomized test with a hidden guaranteed loop to lock the single loop property

Fix #144

@pyrech
pyrech marked this pull request as ready for review August 17, 2026 06:59
@pyrech
pyrech requested a lite review from Copilot August 18, 2026 07:53

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Re-enables the exclusions feature by changing Rudolph’s assignment algorithm to always produce exactly one loop (a single Hamiltonian cycle), and updates UI/validation behavior accordingly.

Changes:

  • Reworked Rudolph::associateUsers() to build a single-cycle chain with randomized backtracking plus a per-attempt step cap.
  • Updated the validate “reshuffle” behavior to catch RudolphException and surface the error instead of failing with a 500.
  • Expanded test coverage to assert exclusions are respected and that generated associations form a single loop (including randomized stress coverage).

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/Santa/Rudolph.php Implements single-loop (Hamiltonian cycle) generation with bounded backtracking and converts chains to associations.
src/Controller/SantaController.php Enables exclusions for ≤100 participants and handles reshuffle failures by collecting/displaying RudolphException messages.
tests/Santa/RudolphTest.php Adds assertions for exclusions + single-loop property and introduces randomized exclusions test plus a targeted “forced single loop” case.
templates/santa/exclusions.html.twig Updates the “not available” message (now explicitly “too many participants”).
templates/content/faq.html.twig Removes “work in progress” messaging for exclusions in the FAQ entry.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@pyrech
pyrech requested a review from damienalexandre August 18, 2026 12:16

@damienalexandre damienalexandre left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@pyrech
pyrech merged commit 11af7ba into main Aug 18, 2026
3 checks passed
@pyrech
pyrech deleted the pyrech/exclusions-between-participants branch August 18, 2026 12:35
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.

Allow to exclude some combinations of users

3 participants