Skip to content

Cap aggregate forecast previews at question close time - #5054

Closed
SylvainChevalier wants to merge 2 commits into
mainfrom
claude/github-issue-5053-sb5kii
Closed

Cap aggregate forecast previews at question close time#5054
SylvainChevalier wants to merge 2 commits into
mainfrom
claude/github-issue-5053-sb5kii

Conversation

@SylvainChevalier

Copy link
Copy Markdown
Contributor

Summary

Fix the default aggregate forecast ("latest" CP) preview for questions that were resolved retroactively (resolved as of a past date but kept accumulating forecasts until the resolution was entered). The preview now correctly reflects the forecast value at the question's effective close time rather than the most recent forecast.

Key Changes

  • questions/services/forecasts.py: Updated get_last_aggregated_forecasts_for_questions() to filter aggregate forecasts by actual_close_time. For open questions (where actual_close_time is null), the most recent forecast is used. For closed/resolved questions, only forecasts that started at or before actual_close_time are considered.

  • questions/serializers/aggregate_forecasts.py: Added _get_latest_aggregate_forecast() helper function that selects the appropriate forecast for the "latest" CP preview. It respects the actual_close_time cutoff for closed questions while maintaining full history in serialization.

  • tests/unit/test_questions/test_services/test_forecasts.py: Added comprehensive test suite (TestCPAtResolutionTime) covering:

    • Retroactively resolved questions with forecasts after resolution time
    • Verification that the latest preview uses the forecast at resolution time, not the most recent one
    • Confirmation that open questions still use the most recent forecast

Implementation Details

  • actual_close_time is defined as min(actual_resolve_time, scheduled_close_time), matching the horizon scoring logic
  • The solution maintains backward compatibility: open questions continue to use the most recent forecast
  • Full forecast history is preserved in serialization; only the "latest" preview is capped at close time
  • Includes fallback behavior: if all forecasts start after the cutoff (edge case), the earliest available forecast is used to keep a CP visible

https://claude.ai/code/session_01XgUzpLZNHiVXK3t7UGoSsU

The default CP preview on resolved questions used the last aggregate
forecast rather than the CP at the point of resolution. When a question
is resolved as of a past date, it appears open until the resolution is
entered, so aggregate forecasts keep accruing after actual_close_time and
the preview showed a value from after the question effectively closed.

Cap the "latest" aggregate at actual_close_time (min of actual_resolve_time
and scheduled_close_time) in both the query used for feed-card previews and
the aggregations serializer used on the detail page, so the default CP
reflects the value at resolution/close time. Open questions keep showing
the most recent CP.

Scores are unaffected: scoring already clamps forecast windows to
actual_close_time, so this was a display-only issue.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XgUzpLZNHiVXK3t7UGoSsU
@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 233221bc-003f-48fa-9b65-af73aee9f73c

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/github-issue-5053-sb5kii

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XgUzpLZNHiVXK3t7UGoSsU

Copy link
Copy Markdown
Contributor Author

Superseded by #5055. This PR's branch name (claude/github-issue-5053-sb5kii) contains "github", which Fly.io's abuse filter blocks for the preview-deploy app name. The identical change has been recreated on claude/issue-5053-sb5kii in #5055. Closing this one.


Generated by Claude Code

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.

2 participants