Reconcile amended 13F filings before diffing - #1381
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 42 minutes Your organization has reached its usage spending cap. Adjust your spending cap in the billing tab. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughdiff_holdings.py now selects authoritative filings per period, preferring 13F-HR/A amendments over originals, using period_end or filed_date as the period key. Holdings fetching is refactored to per-filing lookups. Tests are extended to cover amendment reconciliation and updated placeholder handling. Changes13F Amendment Reconciliation
Estimated code review effort: 3 (Moderate) | ~25 minutes Sequence Diagram(s)sequenceDiagram
participant DiffHoldings as diff_holdings()
participant Selector as _select_authoritative_filings
participant Fetcher as _fetch_holdings_for_filing
participant DB as Database
DiffHoldings->>Selector: request current/prior filing ids
Selector->>DB: query filings (period_end or filed_date)
DB-->>Selector: filing rows
Selector->>Selector: group by period, prefer /A amendments
Selector-->>DiffHoldings: current_id, prior_id
DiffHoldings->>Fetcher: fetch holdings(current_id)
Fetcher->>DB: query holdings for filing_id
DB-->>Fetcher: holdings rows
Fetcher-->>DiffHoldings: current holdings by CUSIP
DiffHoldings->>Fetcher: fetch holdings(prior_id)
Fetcher->>DB: query holdings for filing_id
DB-->>Fetcher: holdings rows
Fetcher-->>DiffHoldings: prior holdings by CUSIP
DiffHoldings->>DiffHoldings: compute INCREASE/EXIT/ADD/DECREASE deltas
Related issues: 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Pull request overview
This PR adds an explicit “authoritative filing selection” stage to diff_holdings so that (for a given manager and reporting period) amended 13F filings supersede originals before holdings are diffed, with regression coverage that demonstrates both the fixed behavior and the prior double-count behavior when reconciliation is disabled.
Changes:
- Add
_select_authoritative_filings()to reconcile 13F amendments and pick one filing per reporting period before diffing. - Refactor
_fetch_latest_sets()to fetch holdings for the latest two authoritative periods (instead of “latest two filing dates from holdings join”). - Add regression tests covering amendment reconciliation and tighten the Postgres-placeholder test to account for multiple DB calls.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| diff_holdings.py | Introduces authoritative-per-period filing selection (preferring amendments) and refactors latest-set fetching to use the reconciled filing IDs. |
| tests/test_diff_holdings.py | Adds regression coverage for amendment reconciliation (including a deliberate “broken selector” path) and updates placeholder assertions for the refactor. |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@diff_holdings.py`:
- Around line 48-51: The period selection in the holdings grouping loop is
mixing `period_key` and `filed_date`, which can split related filings into
different groups when `period_end` is missing on one row. Update the logic in
the cursor iteration to use a single canonical reporting-period value
consistently (for example in `diff_holdings`), or ignore rows that do not have a
valid reporting period, so amendments and originals stay grouped together.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Pro
Run ID: e514fa4b-f954-444a-a282-022c60e1265e
📒 Files selected for processing (2)
diff_holdings.pytests/test_diff_holdings.py
|
Closer review fix pushed in Addressed the CodeRabbit period-grouping comment by making Validation:
|
|
Additional closer review fix pushed in Covered the remaining unresolved review threads:
Validation after the full patch:
|
|
Runner dispatch state for codex on PR #1381. Do not edit. |
🤖 Keepalive Loop StatusPR #1381 | Agent: Codex | Iteration 0/12 Current State
Last Codex Run
To retry immediately:
Or wait for the next successful Gate run to automatically retry. Codex output:
🔍 Failure Classification| Error type | infrastructure | 🧠 Task Analysis| Provider | ✅ GitHub Models (primary) |
|
Keepalive Work Log (click to expand)
|
Provider Comparison ReportProvider Summary
📋 Full Provider Details (click to expand)openai
anthropic
Agreement
DisagreementNo major disagreements detected. Unique Insights
🔍 LangSmith Traces |
|
Workflow state fingerprint for Agents Verifier. Do not edit. |
Closes #1324
Summary
Validation
Summary by CodeRabbit
Bug Fixes
Tests