Skip to content

fix: minor fixes #5

Merged
psteinroe merged 7 commits intomainfrom
1768552330
Jan 16, 2026
Merged

fix: minor fixes #5
psteinroe merged 7 commits intomainfrom
1768552330

Conversation

@psteinroe
Copy link
Owner

No description provided.

1. Changed workflow to use `bash` instead of `sh` for running
   build-migrations.sh since it uses bash-specific features (pipefail)

2. Fixed window time checking in worker to use database time in tests,
   respecting fake_now setting. Also changed from local time (toTimeString)
   to UTC time (toISOString) to be consistent with WindowChecker.
In tests with fake time, the system time may be outside the task's window
even though the fake time is inside/outside the window intentionally.
Skip the early filtering optimization in tests and let ctx.step()/checkpoint()
handle window checks using database time (which respects fake_now).
Move the test vs production time logic into DatabaseClient:
- In production: returns new Date() directly (no DB call)
- In tests: queries database to respect fake_now setting

This simplifies worker.ts and TaskContext which now just call
db.getCurrentTime() without environment checks.
The fetch-time window filtering was causing test failures:
1. It used local/system time which differs from fake time in tests
2. When CI runs early morning UTC (before 09:00), tasks with 09:00-17:00
   windows would be filtered out before ctx.step() could test the
   window release behavior

Window enforcement now happens solely at ctx.step()/ctx.checkpoint(),
which properly uses database time (respecting fake_now in tests) and
correctly handles the release/reschedule logic.
Restored the fetch-time window filtering optimization which prevents
fetching tasks that are outside their execution window.

Fixed the window execution tests to work with fetch-time filtering:
- Tests now start with fake time INSIDE the window (10:00)
- Task handlers advance fake time to OUTSIDE window before ctx.step()/checkpoint()
- This properly tests the window release behavior while allowing tasks to be fetched

The db.getCurrentTime() in DatabaseClient handles test vs production:
- Tests: queries database for fake_now setting
- Production: returns new Date() directly (no DB call)
Skip the db.getCurrentTime() call when no tasks have windows, avoiding
issues with tests that don't set up the schema before starting orchestrator.
This also improves performance by avoiding unnecessary DB calls.
@psteinroe psteinroe changed the title initial fix: minor fixes Jan 16, 2026
@psteinroe psteinroe merged commit 68dca11 into main Jan 16, 2026
9 checks passed
@psteinroe psteinroe deleted the 1768552330 branch January 16, 2026 09:39
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.

1 participant