Skip to content

fix: protect job frontmatter from being overwritten during execution#25

Open
Aleschka wants to merge 1 commit intomoazbuilds:masterfrom
Aleschka:fix/protect-job-frontmatter
Open

fix: protect job frontmatter from being overwritten during execution#25
Aleschka wants to merge 1 commit intomoazbuilds:masterfrom
Aleschka:fix/protect-job-frontmatter

Conversation

@Aleschka
Copy link
Copy Markdown

@Aleschka Aleschka commented Mar 11, 2026

Summary

  • Adds snapshotJobFrontmatter() to jobs.ts — takes a snapshot of the job file's YAML frontmatter before execution and returns a restore function
  • Integrates snapshot/restore into the job execution loop in start.ts — if Claude modifies or strips the frontmatter during a run, it is automatically restored
  • Handles edge cases: file deleted, frontmatter completely mangled, or body content changed by Claude (preserves updated body, restores only frontmatter)
  • Logs a message when restoration occurs for debugging

Fixes #1

Test plan

  • Create a job with schedule and recurring frontmatter
  • Run the job and verify frontmatter remains intact
  • Manually strip frontmatter from a job file mid-run to simulate the bug, verify it gets restored
  • Verify one-shot jobs still clear their schedule correctly after execution

Snapshots job file frontmatter before Claude runs and restores it
if Claude modifies or strips it during execution.

Fixes moazbuilds#1
@Aleschka Aleschka force-pushed the fix/protect-job-frontmatter branch from c2ba70d to 2985bd0 Compare March 11, 2026 23:02
Fenrur added a commit to Fenrur/claudeclaw that referenced this pull request Mar 13, 2026
From upstream PR moazbuilds#25 by Aleschka.
Snapshots job frontmatter before execution and restores it if Claude
overwrites it during the run.

Co-Authored-By: Aleschka <aleschka@users.noreply.github.com>
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.

Cron frontmatter overwritten

1 participant