Cron job store: per-profile JSON with cross-process file locking #775

Closed
opened 2026-10-27 13:37:42 +00:00 by sam · 0 comments
Owner

Slice 1 of the cron/scheduling epic (archie-core-1786637496320-249-be6d9a20). Implements the durable job store: one JSON file per profile at the conventional path, CRUD operations, and cross-process file locking so a CLI edit and a daemon writer don't corrupt each other.

The ticker engine (internal/domain/scheduling) consumes this through its JobSource interface. The store's only contract with the engine is Due(ctx, now) -> ([]Job, error) — the engine applies no schedule arithmetic of its own, so the store owns cron expressions, fixed intervals, and catch-up windows.

Acceptance criteria

  • One JSON file at the conventional per-profile path (<config_dir>/cron/jobs.json or equivalent). Schema is durable and version-stamped for forward compatibility.
  • Create / read / update / delete by job ID with merge semantics that preserve fields not in the patch.
  • Cross-process file lock (flock or OS equivalent) makes concurrent CLI+daemon writers serial; last-writer-wins is documented as the conflict policy.
  • Implements scheduling.JobSource so the ticker engine can poll it without knowing the file layout or format.
  • A truncated/partial-write file is not a panic: open returns an explicit error the engine surfaces as phase="source" KindJobError rather than crashing the loop.

Close reason

Slice 1 of cron/scheduling epic landed: per-profile JSON store with cross-process flock, merge-semantic Update, version-stamped schema, ErrCorruptFile on truncated files, ErrUnsupportedSchema on forward versions. Implements scheduling.JobSource so the ticker engine can poll it without knowing the file layout. Adversarial review applied: deep-copy Get/List, pool validation in Create/Update, ErrScheduleUnsupported on Once MarkRun, 0o600 file mode, SetEscapeHTML(false) for operator-readable files, fsync before rename for durability, ErrClosed sentinel after Close, real cross-process flock test via os/exec. task check green.


Imported from beads archie-core-1786637496320-249-be6d9a20.1 · GitHub #680 · type feature · priority P2 · created 2026-08-27 · closed 2026-08-28

Slice 1 of the cron/scheduling epic (archie-core-1786637496320-249-be6d9a20). Implements the durable job store: one JSON file per profile at the conventional path, CRUD operations, and cross-process file locking so a CLI edit and a daemon writer don't corrupt each other. The ticker engine (internal/domain/scheduling) consumes this through its `JobSource` interface. The store's only contract with the engine is `Due(ctx, now) -> ([]Job, error)` — the engine applies no schedule arithmetic of its own, so the store owns cron expressions, fixed intervals, and catch-up windows. ### Acceptance criteria - One JSON file at the conventional per-profile path (`<config_dir>/cron/jobs.json` or equivalent). Schema is durable and version-stamped for forward compatibility. - Create / read / update / delete by job ID with merge semantics that preserve fields not in the patch. - Cross-process file lock (`flock` or OS equivalent) makes concurrent CLI+daemon writers serial; last-writer-wins is documented as the conflict policy. - Implements `scheduling.JobSource` so the ticker engine can poll it without knowing the file layout or format. - A truncated/partial-write file is not a panic: open returns an explicit error the engine surfaces as `phase="source" KindJobError` rather than crashing the loop. ### Close reason Slice 1 of cron/scheduling epic landed: per-profile JSON store with cross-process flock, merge-semantic Update, version-stamped schema, ErrCorruptFile on truncated files, ErrUnsupportedSchema on forward versions. Implements scheduling.JobSource so the ticker engine can poll it without knowing the file layout. Adversarial review applied: deep-copy Get/List, pool validation in Create/Update, ErrScheduleUnsupported on Once MarkRun, 0o600 file mode, SetEscapeHTML(false) for operator-readable files, fsync before rename for durability, ErrClosed sentinel after Close, real cross-process flock test via os/exec. task check green. --- _Imported from beads `archie-core-1786637496320-249-be6d9a20.1` · GitHub #680 · type feature · priority P2 · created 2026-08-27 · closed 2026-08-28_
sam added the mediumfeature labels 2026-10-27 13:37:42 +00:00
sam self-assigned this 2026-10-27 13:37:42 +00:00
sam closed this issue 2026-10-27 13:37:42 +00:00
sam added a new dependency 2026-10-27 13:42:10 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Reference: sam/archie#775