From a146c7c9f66ba7fe5d6e9ff582cf9c2b8ffd8ab5 Mon Sep 17 00:00:00 2001 From: Lev Date: Sun, 12 Apr 2026 04:13:30 +0300 Subject: [PATCH 1/2] fix(cost_budget): align 7d period to Monday UTC 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. --- src/fairvisor/cost_budget.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/fairvisor/cost_budget.lua b/src/fairvisor/cost_budget.lua index fc85f26..570f5d4 100644 --- a/src/fairvisor/cost_budget.lua +++ b/src/fairvisor/cost_budget.lua @@ -92,7 +92,7 @@ function _M.compute_period_start(period, now) end if period == "7d" then - return floor((now - 259200) / 604800) * 604800 + 259200 + return floor((now - 345600) / 604800) * 604800 + 345600 end return nil, "unknown period" From 7fd24946e909832bfc35fd38fc65b0f48952956a Mon Sep 17 00:00:00 2001 From: Lev Date: Sun, 12 Apr 2026 04:13:41 +0300 Subject: [PATCH 2/2] test(cost_budget): fix expected 7d period start to Monday 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. --- spec/unit/features/cost_budget.feature | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/unit/features/cost_budget.feature b/spec/unit/features/cost_budget.feature index 50c66a6..c63bfb2 100644 --- a/spec/unit/features/cost_budget.feature +++ b/spec/unit/features/cost_budget.feature @@ -117,7 +117,7 @@ Feature: Cost budget limiter module behavior Scenario: computes weekly period boundary aligned to Monday UTC When I compute period start for period "7d" at now 1770129000 - Then the period start is 1769904000 + Then the period start is 1769990400 Scenario: rejects unknown period in period start computation When I compute period start for period "30m" at now 1770129000