fix(cost_budget): align 7d period start to Monday UTC#146
Merged
levleontiev merged 2 commits intomainfrom Apr 12, 2026
Merged
Conversation
The compute_period_start function for the '7d' period was using an offset of 259200 (3 days from epoch Thursday = Sunday), but the test spec documents the period should be aligned to Monday UTC. Change the offset to 345600 (4 days from epoch = Monday) so that weekly budget periods start on Monday at 00:00 UTC.
The scenario 'computes weekly period boundary aligned to Monday UTC' had an expected value of 1769904000 (Sunday Feb 1 2026) instead of 1769990400 (Monday Feb 2 2026). Update to match the corrected Monday-aligned offset in compute_period_start.
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.
Summary
The
compute_period_startfunction insrc/fairvisor/cost_budget.luawas aligning weekly (7d) budget periods to Sunday instead of Monday UTC as documented in the test spec.Root cause
The offset used in the 7d calculation was
259200(3 days from the Unix epoch, which was a Thursday — putting the anchor on Sunday January 4, 1970). The correct offset is345600(4 days from epoch = Monday January 5, 1970).Changes
src/fairvisor/cost_budget.lua: Change 7d offset from259200→345600spec/unit/features/cost_budget.feature: Update expected period start from1769904000(Sun Feb 1 2026) →1769990400(Mon Feb 2 2026)Verification
For
now = 1770129000:floor((1770129000 - 259200) / 604800) * 604800 + 259200 = 1769904000(Sunday)floor((1770129000 - 345600) / 604800) * 604800 + 345600 = 1769990400(Monday ✓)🤖 Generated with Claude Code