Skip to content

fix(history): future-dated ramp steps can still crowd a due pending approval out of the actionable fetch #680

Closed

Description

@cristim

Summary

Residual of #632 after PR1 (terminal rows no longer starve actionable rows): inside the actionable class, far-future ramp steps are pending with a scheduled_date months ahead and sort first under ORDER BY scheduled_date DESC, so they can fill the actionable cap and hide a pending approval dated today.

Current behaviour

GetExecutionsByStatuses (internal/config/store_postgres.go:~1375) orders scheduled_date DESC with a hard clamp of MaxListLimit (1000). Plan creation writes up to 52 pending ramp steps per plan (internal/api/handler_plans.go createPurchaseExecutionsTx). About 20 plans saturate 1000 rows. truncated is set when the cap is hit, so the loss is flagged but not prevented.

Steps to verify the gap

Create 20+ ramp plans (52 future pending steps each) plus one pending approval due today; load History: the due-today row is absent and truncated is true.

Expected behaviour

Rows that are actionable now (due, notified, scheduled with a near fire time, approved/running/paused) are fetched before future-dated unactionable ramp steps.

Proposed fix

In the SQL method added by #632 PR2 (filtered executions query): order actionable rows by proximity to now (for example ABS(EXTRACT(EPOCH FROM scheduled_date - now()))) or exclude pending rows whose scheduled_date is beyond a horizon; add a failing-first test with 20 x 52 future rows plus one due row (pgxmock SQL shape plus testcontainers integration where available).

References

Parent #632, umbrella #248, #630. Found in the #632 PR1 plan review. Severity: medium.

Activity

  1. IAmJSD commented on Oct 16, 2026

    @IAmJSD
    Collaborator

    Claiming: working on this

  2. self-assigned this
    on Oct 16, 2026
  3. added a commit that references this issue on Oct 17, 2026
    af374cc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions