Skip to content

Fix: Enforce strict DAO finalization logic to preserve audit logs and dates#466

Open
ayushshukla1807 wants to merge 3 commits intohatnote:masterfrom
ayushshukla1807:fix-finalize-round-dao-bypass
Open

Fix: Enforce strict DAO finalization logic to preserve audit logs and dates#466
ayushshukla1807 wants to merge 3 commits intohatnote:masterfrom
ayushshukla1807:fix-finalize-round-dao-bypass

Conversation

@ayushshukla1807
Copy link
Copy Markdown

@ayushshukla1807 ayushshukla1807 commented Apr 3, 2026

Consolidated Fix for Round Finalization (#462

This PR completely resolves the architectural issues identified in #462 by consolidating the robust testing from PR #491 with a mature, DAO-led refactor. This implementation strictly adheres to maintainer feedback regarding the separation of concerns.

Key Architectural Improvements

1. Unified Round Finalization (DAO Layer)

  • Implemented CoordinatorDAO.finalize_round(): A generic, reusable method that handles state transitions, close_date injection, and audit logging.
    • Fixed Endpoint Bypass: Updated the finalize_round endpoint in admin_endpoints.py to delegate to this DAO method, ensuring all closures are recorded in the audit log.

2. Adherence to Maintainer Guidance

  • Summary Logic Migration: Following @lgelauff's advice, the creation of RoundResultsSummary has been moved from the individual round closure (finalize_ranking_round) to the campaign-level closure (finalize_campaign). This ensures summaries are only generated when a campaign is truly complete.

3. Integration & Regression Testing

  • Integrated fix(admin): finalize round via DAO close path #491 Tests: Incorporated a comprehensive regression test that validates status, close_date, and audit_log generation during round closure.
    • Verified Local Pass: Full test suite pass confirmed for the new logic.

Verification Results

Local Verification

Finalized round and campaign locally. Verified that close_date is correctly populated and audit logs are recorded.

Local Verification Screenshot

@userAdityaa
Copy link
Copy Markdown

Hi @ayushshukla1807, apologies, but I’ve already opened a PR for this that also includes the additional tests covering the changes.

@ayushshukla1807
Copy link
Copy Markdown
Author

Hi @userAdityaa, excellent catch! I missed PR #463 while surveying the issue tracker! Closing this duplicate in favor of your implementation.

…sSummary to finalize_campaign

Per lgelauff's feedback on hatnote#462:
- finalize_ranking_round now only sets close_date, status, and writes audit log
- RoundResultsSummary creation moved to finalize_campaign, where it belongs
  (only created when the last round was a ranking round)
- finalize_round endpoint delegates to coord_dao.finalize_round()
@lgelauff
Copy link
Copy Markdown
Collaborator

You may also want to consider #491 here - there seems to be some overlap?

- Moved RoundResultsSummary creation from finalize_ranking_round to finalize_campaign as requested by maintainer.
- Created generic CoordinatorDAO.finalize_round method to ensure consistent status updates, close_date injection, and audit logging.
- Updated admin_endpoints.py to delegate to the new DAO method, resolving the bypass issue.
- Integrated regression test from PR hatnote#491 to ensure technical parity and future stability.
@ayushshukla1807
Copy link
Copy Markdown
Author

Hi @lgelauff! Good catch. I’ve already consolidated the testing and DAO-based state changes from #491 into this PR. I also took your previous feedback to heart and moved the result summary generation out of the round closure and into the campaign closure. This version now fully resolves #462 while maintaining a cleaner separation of concerns.

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.

[Bug]: finalize_round endpoint bypasses DAO finalization logic (missing close_date, audit log, result summary)

3 participants