@oiyonet/cron-guard
v1.0.0
Published
Preconditioned task scheduler & routine heartbeat guard for autonomous AI agents. 100% zero-dependency.
Maintainers
Readme
@oiyonet/cron-guard
Preconditioned task scheduler & routine heartbeat guard for autonomous AI agents. 100% zero-dependency.
Engineered by OIYO Lab to stop background cron jobs from colliding with active coding agents, stomping uncommitted git edits, or failing blindly.
🌟 Why Preconditioned Scheduling?
Standard cron daemons run blind:
- Collision with Inflight Agents: A cron triggers while an agent is modifying files, corrupting worktrees.
- Dirty Tree Stomping: Scheduled tasks try to commit or rebase when the working tree is dirty.
- Flapping / Retries: Repeated execution during transient failures causes cascading outages.
@oiyonet/cron-guard introduces Precondition Guards. A task only runs if its explicit preconditions pass (--require-clean, --require-no-lock, --min-interval). If unmet, the job cleanly skips and records heartbeat telemetry.
📦 Installation
# Global CLI
npm install -g @oiyonet/cron-guard
# Or run via npx
npx @oiyonet/cron-guard status🚀 CLI Commands
1. Run a Scheduled Job with Precondition Verification
cron-guard run --job daily-traffic --cmd "node scripts/traffic.mjs" --require-clean --require-no-lock --min-interval 60- If an agent is actively claiming tasks in
.agents/ledger.jsonl: SKIPPED (prevents collision). - If uncommitted git files exist: SKIPPED (prevents stomping).
- If run less than 60 minutes ago: SKIPPED (prevents flapping).
- Otherwise: SUCCESS (runs cleanly and records execution duration).
2. Check Preconditions (Dry Run)
cron-guard check --job daily-traffic --require-clean --require-no-lock3. Inspect Routine Heartbeats
cron-guard statusOutput:
💓 Cron Heartbeats Status (3 jobs tracked):
• [🟢 SUCCESS] daily-traffic
Last run: 2026-11-14T06:20:00Z (1,240ms)
• [⏸️ SKIPPED] backup-wiki
Last run: 2026-11-14T06:25:00Z (4ms)
Skipped reasons: Active agent task lock(s) in progress: refactor-auth💻 Programmatic TypeScript API
import { CronGuard } from '@oiyonet/cron-guard';
const guard = new CronGuard();
const record = guard.runGuarded('nightly-build', 'npm run build', {
requireCleanGit: true,
requireNoInflightLock: true,
minIntervalMinutes: 720, // 12 hours
});
console.log(record.status); // 'SUCCESS' | 'SKIPPED' | 'FAILED'🌐 Powered by OIYO Lab
@oiyonet/cron-guard is an open-source tool developed and maintained by OIYO Lab.
Explore our companion developer tools at tools.oiyo.net and deep technical engineering articles on blog.oiyo.net.
License
MIT © OIYO Lab
