Prune old timestamped backups so user:// stays bounded - #339
Conversation
`backup_save()` now invokes `_prune_old_backups()` after writing the new file. The helper uses the existing newest-first `list_backups()` to delete any entries beyond the new `MAX_BACKUPS := 5` constant. `list_backups()` and `restore_backup()` behaviour are unchanged. Added `flow_backup_pruning` to `tests/test_save_backup.gd` covering: * exactly MAX_BACKUPS remain after creating MAX_BACKUPS+1 * stored count drops below total created * newest-first ordering is preserved after pruning Fixes #332 Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
There was a problem hiding this comment.
AI Automated Review
Full PR review.
Analysis engine: dsv4f@https://litellm.jory.dev/v1 (openai) — primary route
Recommendation: Approve
The PR implements keep-last-5 pruning for timestamped backups and adds a focused test. It satisfies issue PR 332's acceptance criteria, follows the repository's test conventions, and all CI checks passed.
Change-by-change findings
scripts/game_state.gd
MAX_BACKUPS := 5is declared in the same style as the other save constants.backup_save()calls_prune_old_backups()only after a successful copy; a failed backup does not trigger deletion._prune_old_backups()reuseslist_backups()(newest-first) and deletes only entries pastMAX_BACKUPS, so the newest five backups are preserved.list_backups()andrestore_backup()behavior is unchanged.
tests/test_save_backup.gd
flow_backup_pruningcreates six backups and asserts the list is capped at five, that the count was reduced, and that ordering remains newest-first.- All
assert_eqcalls use the required three-argument form and every assertion has a name, matching AGENTS.md. - Non-blocking note:
OS.delay_msec(1100)adds roughly 6.6s to the suite and theif not assert_eq(...): passbranch is awkward; the filename counter already guarantees uniqueness, so the delays are not strictly necessary.
Standards Compliance
- AGENTS.md requires
assert_eq(actual, expected, name); every new assertion satisfies this. - The new test follows the shared
test_case.gdheadless pattern used by the other suites. - Constant naming and placement match existing
game_state.gdconventions. - No release or version bump is required for this change.
Linked Issue Fit
Issue PR 332 asks: Prune old timestamped backups so user:// does not accumulate windowstead-backup-* files forever, with expected file scripts/game_state.gd.
- Acceptance 1 (after N=5 backups exist, the oldest are deleted on the next
backup_save()): implemented by_prune_old_backups(). - Acceptance 2 (
list_backups()remains newest-first;restore_backup()unchanged): both functions are untouched in behavior and the existing ordering test still passes. - Acceptance 3 (
tests/test_save_backup.gdgains a pruning assertion): added asflow_backup_pruning.
The PR description names issue PR 332 and the diff touches the expected file, so the scope-overlap convention is satisfied.
Tool Harness Findings
Tool harness planning was still pending, so no harness-generated findings were available. CI on commit a0114b2 reported success for the script test suite, headless smoke test, macOS validation, and all export validations.
Sources
- PR PR 339 diff and metadata
- Issue PR 332 body and acceptance criteria
- CI status for commit a0114b2
- Inspected
scripts/game_state.gdandtests/test_save_backup.gdat head
Unknowns / Needs Verification
- The tool harness had not produced output at review time; this is an evidence gap but not a functional concern.
- No local Godot run was performed; verification relies on the green CI results.
- No other unknowns were identified.
Pruning of timestamped save backups implemented with MAX_BACKUPS=5 and test added.
Fixes #332
Opened by foreman on review GO (workload wl-misospace-windowstead-332).