Skip to content

[Feature]: Split cron store into definitions + runtime state files #53581

Description

@Lukavyi

Summary

Split jobs.json into two files: definitions (git-trackable) and runtime state (gitignored). Currently both live in a single file, making git history noisy with timestamp/status churn after every cron run.

Problem to solve

When cron.store points to a git-tracked file (e.g. ~/clawd/cron/jobs.json), every cron execution mutates runtime fields:

  • state.lastRunAtMs, state.nextRunAtMs, state.lastDurationMs
  • state.lastStatus, state.consecutiveErrors, state.lastDeliveryStatus
  • updatedAtMs (job-level)

With ~10 daily jobs this produces 10+ meaningless commits/day, drowning real config changes in noise.

Proposed solution

Split into two files at the same directory level:

~/clawd/cron/jobs.json        # definitions only (schedule, payload, delivery, enabled, name)
~/clawd/cron/jobs-state.json  # runtime state (lastRunAtMs, nextRunAtMs, errors, etc.) — .gitignore

On load: merge state into definitions by job id.
On save: strip runtime fields from definitions file; write state separately.

The building blocks already exist in store.ts:

  • stripRuntimeOnlyCronFields() already strips state and updatedAtMs
  • shouldSkipCronBackupForRuntimeOnlyChanges() already compares stripped versions

A new config option could control the behavior:

"cron": {
  "store": "~/clawd/cron/jobs.json",
  "separateState": true  // default false for backward compat
}

Or infer automatically: if a .gitignore / .jj/ exists in the store directory, separate state by default.

Alternatives considered

  1. jobs.d/ directory (see [Feature]: cron jobs.d/ directory support (one file per job, for NixOS/GitOps declarative setups) #20950) — solves GitOps/NixOS but not the state noise problem; complementary, not a replacement.
  2. Git clean/smudge filters — fragile hack, not a real solution.
  3. User-side .gitignore patterns — impossible since definitions and state live in the same file.

Impact

  • Affected: any user storing cron jobs in a git/jj repo
  • Severity: annoying — constant noisy diffs, meaningless commits
  • Frequency: every cron run (multiple times daily)

Additional context

Related: #20950 (jobs.d/ directory support)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions