Skip to content

fix(ledger): remove implicit 7-day sliding window on volumes list#141

Merged
flemzord merged 1 commit into
mainfrom
fix/ledger-volumes-remove-default-time-window
Apr 14, 2026
Merged

fix(ledger): remove implicit 7-day sliding window on volumes list#141
flemzord merged 1 commit into
mainfrom
fix/ledger-volumes-remove-default-time-window

Conversation

@flemzord

Copy link
Copy Markdown
Member

Summary

fctl ledger volumes list silently injected default time boundaries, causing incorrect Point-in-Time (PIT) volume queries.

When a user ran:

fctl ledger volumes list --end-time "2025-06-12T12:00:00Z"

fctl sent both endTime=2025-06-12 and startTime=2025-06-05 (endTime minus 7 days) to the ledger API, even though the user never provided --start-time.

This caused the ledger to generate:

WHERE effective_date <= '2025-06-12' AND effective_date >= '2025-06-05'

Instead of the expected:

WHERE effective_date <= '2025-06-12'

Any move older than 7 days before the requested PIT date was invisible, making volumes appear and disappear depending on the chosen date — which is incorrect for immutable ledger data.

Root cause

In cmd/ledger/volumes/list.go, two default blocks injected time boundaries when the user did not provide them:

// Defaulted endTime to now when not provided
if pit == nil {
    tmp := time.Now()
    pit = &tmp
}

// Defaulted startTime to endTime - 7 days when not provided
if oot == nil {
    tmp := pit.Add(-24 * 7 * time.Hour)
    oot = &tmp
}

The ledger server handles missing parameters correctly: when no startTime is sent, it queries all moves from the beginning of time up to endTime. The default injection was entirely client-side in fctl and never requested by the user.

Behavior change

Scenario Before (broken) After (fixed)
--end-time only Sends endTime + startTime (endTime - 7d) Sends endTime only → true PIT query
--start-time only Sends startTime + endTime (now) Sends startTime only
Both flags Sends both (correct) Sends both (unchanged)
Neither flag Sends endTime=now + startTime=now-7d Sends neither → all data

⚠️ Breaking behavior change: Users who relied on the implicit 7-day window (without knowing it existed) will now get results covering the full ledger history. This is the correct behavior — the previous default was silently filtering out data.

Verification

Tested against a production stack. With the fix, go run ./ ledger volumes list --end-time <date> returns the correct volumes covering all historical moves, while the installed fctl returns empty results due to the 7-day window excluding the relevant transactions.

Test plan

  • Run fctl ledger volumes list --end-time <date> → should return all volumes up to that date (no lower bound)
  • Run fctl ledger volumes list --start-time <date> --end-time <date> → should return volumes in the explicit range
  • Run fctl ledger volumes list without time flags → should return all volumes
  • Run fctl ledger volumes list --start-time <date> → should return volumes from that date onward

BREAKING BEHAVIOR CHANGE:

Previously, `fctl ledger volumes list` silently injected default time
boundaries when the user did not provide them:

- If `--end-time` was omitted, it defaulted to `time.Now()`
- If `--start-time` was omitted, it defaulted to `endTime - 7 days`

This meant that every volumes query was silently scoped to a 7-day
sliding window, even when the user intended a Point-in-Time (PIT) query
covering all historical data up to a given date.

For example, running:
  fctl ledger volumes list --end-time "2025-06-12T12:00:00Z"

Would send both `endTime=2025-06-12` AND `startTime=2025-06-05` to
the ledger API. The ledger then applied:
  WHERE effective_date <= '2025-06-12' AND effective_date >= '2025-06-05'

Any transaction older than 7 days before the requested PIT date was
invisible, causing volumes to appear and disappear depending on the
chosen date — which is incorrect for immutable ledger data.

The ledger server correctly handles missing parameters: when no
startTime is sent, it queries all moves from the beginning of time
up to the endTime. The default injection was entirely client-side
in fctl and never requested by the user.

After this fix, only explicitly provided flags are sent to the API:
- `--end-time` only → sends `endTime` only (true PIT query)
- `--start-time` only → sends `startTime` only
- Both flags → sends both (explicit time range)
- Neither flag → sends neither (all data)
@flemzord flemzord requested a review from a team as a code owner April 14, 2026 10:42
@coderabbitai

coderabbitai Bot commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: bbbcc3c7-4787-4bb3-9270-499b8394bd58

📥 Commits

Reviewing files that changed from the base of the PR and between 58f68b9 and 1af8308.

📒 Files selected for processing (1)
  • cmd/ledger/volumes/list.go
💤 Files with no reviewable changes (1)
  • cmd/ledger/volumes/list.go

Walkthrough

This change removes automatic defaulting logic for datetime parameters in the volumes list command. Previously, null datetime values were automatically set to the current time and seven days prior; they are now passed through directly from the datetime parsing function without computed defaults.

Changes

Cohort / File(s) Summary
Datetime Default Logic Removal
cmd/ledger/volumes/list.go
Removed 11 lines of code that automatically defaulted pit (point-in-time) to time.Now() and oot (out-of-time) to a derived value 7 days prior. Values now pass through directly from fctl.GetDateTime without defaults.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 Defaults once guarded the timeline with care,
Setting now and weeks past into the air,
But logic must lighten, and values flow free,
Straight from the source, as they're meant to be! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change: removing the implicit 7-day sliding window from the volumes list command, which is the core fix in this changeset.
Description check ✅ Passed The description is directly related to the changeset, providing context about the bug being fixed, root cause analysis, behavior changes, and verification details.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ledger-volumes-remove-default-time-window

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 and usage tips.

@fguery fguery left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should make sure that shows in the CHANGELOG, it's a big change

@fguery

fguery commented Apr 14, 2026

Copy link
Copy Markdown
Contributor

Maybe even update the docs?

@flemzord flemzord enabled auto-merge (squash) April 14, 2026 10:49
@flemzord flemzord disabled auto-merge April 14, 2026 10:50
@flemzord flemzord merged commit 6205861 into main Apr 14, 2026
4 checks passed
@flemzord flemzord deleted the fix/ledger-volumes-remove-default-time-window branch April 14, 2026 10:50
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.

3 participants