Add rejection loop accounting - #5
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds an auditable “research loop” accounting layer that converts candidate evaluation outputs into compact records, summarizes loop outcomes (including rejection reasons), and produces a ranked “rejection gallery” of near-miss candidates. It also updates the demo output and documentation to reflect the new inspection/audit artifacts, and adds tests for the new rejection accounting behavior.
Changes:
- Introduce
CandidateRecord,ResearchLoopSummary,summarize_loop, andrejection_galleryutilities for auditable loop accounting. - Update the demo to emit a structured payload including candidate diagnostics, loop summary, and a rejection gallery.
- Add unit test coverage for rejection gallery sorting and rejection-reason counting; refresh README/report text accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| tests/test_research.py | Adds a regression test asserting rejection accounting (reason counts) and rejection gallery ranking behavior. |
| src/ai_alpha_lab/loop.py | New loop-accounting module with record/summary dataclasses and rejection gallery ranking logic. |
| src/ai_alpha_lab/demo.py | Emits demo JSON payload including loop summary and rejection gallery derived from evaluation output. |
| src/ai_alpha_lab/init.py | Exposes loop-accounting types/functions as part of the public package surface. |
| reports/rejection-gallery.md | Updates report to describe the implemented loop accounting helpers and demo behavior. |
| README.md | Refreshes project description/feature list and links to include rejection accounting artifacts. |
Suppressed comments (1)
src/ai_alpha_lab/loop.py:68
- rejection_gallery sorts rejected candidates using raw float keys. If oos_rank_ic or oos_net_return is NaN, the ordering becomes unstable and NaN entries can appear ahead of better candidates depending on input order. Normalize NaN to -inf (or otherwise handle it) so NaN-scored candidates reliably sort to the bottom.
rejected = [record for record in records if not record.promoted]
ranked = sorted(rejected, key=lambda record: (record.oos_rank_ic, record.oos_net_return), reverse=True)
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+58
to
+59
| best_oos_rank_ic=max((record.oos_rank_ic for record in items), default=None), | ||
| best_oos_net_return=max((record.oos_net_return for record in items), default=None), |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds an auditable research-loop layer:
Local verification:
C:\qds\Scripts\python.exe -m unittest discover -s tests -vpassed with 6 tests.