Skip to content

Prune old timestamped backups so user:// stays bounded - #339

Merged
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-332/issue-332
Aug 14, 2026
Merged

Prune old timestamped backups so user:// stays bounded#339
joryirving merged 1 commit into
mainfrom
foreman/wl-misospace-windowstead-332/issue-332

Conversation

@itsmiso-ai

Copy link
Copy Markdown
Contributor

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).

`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>
@itsmiso-ai
itsmiso-ai requested a review from joryirving as a code owner August 14, 2026 07:35

@its-saffron its-saffron Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 := 5 is 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() reuses list_backups() (newest-first) and deletes only entries past MAX_BACKUPS, so the newest five backups are preserved. list_backups() and restore_backup() behavior is unchanged.

tests/test_save_backup.gd

  • flow_backup_pruning creates six backups and asserts the list is capped at five, that the count was reduced, and that ordering remains newest-first.
  • All assert_eq calls 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 the if not assert_eq(...): pass branch 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.gd headless pattern used by the other suites.
  • Constant naming and placement match existing game_state.gd conventions.
  • 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.gd gains a pruning assertion): added as flow_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.gd and tests/test_save_backup.gd at 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.

@joryirving
joryirving merged commit 540c0c2 into main Aug 14, 2026
8 checks passed
@joryirving
joryirving deleted the foreman/wl-misospace-windowstead-332/issue-332 branch August 14, 2026 12:23
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.

[P3] Backup files accumulate in user:// forever — no pruning, no in-app restore

2 participants