fix(fleet-state): create .bak before write + validate TMP before promote (replay of e0e326f) - #32
fix(fleet-state): create .bak before write + validate TMP before promote (replay of e0e326f)#32antfleet-ops wants to merge 1 commit into
Conversation
…ote (aeonfun#203) The persist-state step in `skills/fleet-state/SKILL.md` declared "keep one `.bak` rolling. If `jq empty` fails after write → restore from `.bak`" — but nothing in the step ever created the `.bak`. The sequence was `mv $TMP ...json` first, then `jq empty` validation on the live file, with rollback attempting `cp ...json.bak ...json`. Two issues this caused: 1. On any failed validate, the rollback `cp` would silently fail (no source) and the operator would be left with a corrupt `fleet-state.json` and no recovery path. Subsequent fleet-state runs read this file as the baseline — so once corrupt, the historical bucket totals and spotlight rotation pointer would stay wrong for every following week. 2. Even when the new content was bad, the live file was already overwritten (the `mv` runs before validation), so the previous week's state was unrecoverable. This change: - Adds a `cp …json …json.bak` step BEFORE the write attempt, so the rollback path always has a non-empty backup. Runs every persist iteration as a rolling backup. - Moves the `jq empty` check from "after `mv`" to "before `mv`" — the candidate JSON is validated in the temp file, and only promoted if valid. If it's invalid, the temp file is discarded and the live file is restored from `.bak` defensively. Net effect: a malformed jq output now leaves the live file at the prior good state instead of replacing it with a corrupt blob. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-authored-by: antfleet-ops <285575208+antfleet-ops@users.noreply.github.com> Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
AntFleet · 2 findingsBoth reviewers flagged the items below on the changed files. AntFleet posts only what two independent frontier models agree on. Bug · High — jq pipeline for SPOTLIGHT_PICK fails when history is empty
Fix: Avoid echo | jq on possibly empty input. Either extract both fields directly from the file with a single jq call (e.g., jq -r '(.history | sort_by(.featured_at) | .[-1]) // {} | [.fork, .featured_at] | @TSV' ...) or guard: if [ -n "$SPOTLIGHT_PICK" ]; then ... fi. Alternatively, use jq -n with inpu… Docs-gap · Low — Step 2 'Resolve parent repo' contradicts the Sandbox note's no-gh-api claim
Fix: Either remove the — Review |
Bench replay of upstream aaronjmars/aeon#203 (commit e0e326f).
This PR triggers AntFleet's review pipeline against aeon's
.bak+ TMP-validate change. Patch Agent v1.5 is enabled for this install as the v1.5 canary — expect a suggestion block in the review comment when both reviewers (Opus 4.7 + GPT-5) agree on a localized fix.Source: https://github.com/aaronjmars/aeon/pull/203