Skip to content

refactor(scheduler): async save worker + test consolidation#152

Merged
yishuiliunian merged 3 commits into
mainfrom
worktree-delightful-dreaming-hellman
May 14, 2026
Merged

refactor(scheduler): async save worker + test consolidation#152
yishuiliunian merged 3 commits into
mainfrom
worktree-delightful-dreaming-hellman

Conversation

@yishuiliunian
Copy link
Copy Markdown
Contributor

Summary

  • Extract disk I/O from mutation paths into a dedicated save worker with message queue
  • Add wait_idle() barrier API for test synchronization
  • Consolidate test infrastructure with shared MockStorage

Changes

  • crates/loopal-scheduler/src/save_worker.rs — new async save worker
  • crates/loopal-scheduler/src/scheduler.rs — integrate save worker channel
  • crates/loopal-scheduler/src/tick.rs — use save worker instead of inline I/O
  • crates/loopal-scheduler/tests/suite/mock_storage.rs — shared test helper
  • Various test files — deduplicate helpers, use shared mock

Test plan

  • bazel test //crates/loopal-scheduler:suite passes
  • bazel build //... --config=clippy passes
  • CI passes

The 3-day window was wired into two unrelated paths: cron expression
parsing rejected anything whose next fire was >3d out, and the tick
loop garbage-collected non-durable tasks after 3d. The parse-time
check made legitimate weekly/monthly cron unusable (e.g. `0 9 * * 1`
created after this week's Monday fire), and the runtime GC was a
heuristic with no clear value once durable tasks were already exempt.

Replace the parse-time window with a never-fires check (e.g. Feb 30)
and remove the runtime expiry entirely — tasks now live until they
are explicitly deleted, or (for one-shots) until they fire.
Extract disk I/O from mutation paths into a dedicated save worker:
- SaveMessage queue decouples tasks.write from fsync latency
- Barrier API for test synchronization (wait_idle)
- Retry via dirty flag on transient failures

Consolidate test infrastructure:
- Shared MockStorage for persistence tests
- Remove duplicated test helpers across files
@yishuiliunian yishuiliunian merged commit 3097bd9 into main May 14, 2026
4 checks passed
@yishuiliunian yishuiliunian deleted the worktree-delightful-dreaming-hellman branch May 14, 2026 10:55
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