feat: sync crontab on init and clean test artifacts - #165
Merged
Conversation
Add OpenSpec change proposing automatic reconciliation of persisted job definitions (memory/schedules/*.json) with the system crontab on container init. Covers: add/remove/update/pause of jobs, no-duplication via full block replacement, no interruption of running crond jobs, and configurable opt-out via scheduler.syncOnInit flag. Artifacts: proposal.md, design.md, specs/crontab-sync/spec.md, specs/cron-scheduler/spec.md (delta), tasks.md (24 tasks, 6 groups).
Implement automatic reconciliation of persisted job definitions (memory/schedules/*.json) with the system crontab on every container initialization. Jobs persist between container updates without duplication or interruption of running crond jobs. Changes: - Add Cron.sync() method: reads disk JSON, compares crontab block, writes reconciled block (add/remove/update/pause) - Add scheduler.syncOnInit config flag (default: true) - Wire sync into index.js boot sequence before TUI init - Add logging: info on start/complete, warn on error - 12 unit tests + 4 integration tests covering all scenarios Files: - src/scheduler/cron.js: sync() method + helpers - src/config/schemas.js: syncOnInit schema + default - index.js: sync boot call with try/catch/logging - config.yaml: syncOnInit: true - tests/unit/cron_sync.test.js: 12 unit tests - tests/integration/sync_integration.test.js: 4 integration tests
Import Cron scheduler and call uninstall() in the after() hook to strip the entire madz-schedules block, ensuring no residual crontab entries linger after tests run.
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.
Description
Implement automatic reconciliation of persisted job definitions (
memory/schedules/*.json) with the system crontab on every container init. Jobs persist between container updates without duplication or interruption of running crond jobs.Additionally, cronjob tests now clean the system crontab after each run by calling
Cron.uninstall()in theafter()hook, ensuring no residualmadz-schedulesblock entries linger.Type of Change
Testing
Unit tests (
tests/unit/cron_sync.test.js— 12 tests):Integration tests (
tests/integration/sync_integration.test.js— 4 tests):Test hygiene (
tests/unit/tools_cron.test.js):Cronscheduler and calluninstall()inafter()hook to strip the entiremadz-schedulesblock from the system crontab after all cronjob tests complete.All 16 new tests pass. Full test suite passes (100% of existing tests unaffected).
Coverage
Checklist
npm run lintpasses — oxlint + oxfmt cleanArchive Status
Change
sync-crond-on-inithas been archived. The newcrontab-synccapability spec has been merged into the main specs directory.