[P3] Add test for stale reservation cleanup dirty flag, remove redundant guard - #303
Merged
Merged
Conversation
… guard
- Remove redundant `if not state.has("reserved_resources")` guard from
`persist()` in main.gd since `ensure_defaults()` already guarantees the key
exists.
- Add test `test_stale_reservation_cleanup_marks_dirty` that properly verifies
`_clean_stale_reservations()` calls `mark_dirty()` by resetting the dirty flag
before invocation (avoiding false positive from bootstrap_state).
Fixes #297
Signed-off-by: Saffron <263493777+itsmiso-ai@users.noreply.github.com>
itsmiso-ai
force-pushed
the
foreman/wl-misospace-windowstead-297/issue-297
branch
from
August 1, 2026 04:01
7ae0c19 to
45cc88d
Compare
its-saffron
Bot
dismissed
their stale review
August 1, 2026 04:04
Superseded by a newer automated review for this pull request.
There was a problem hiding this comment.
AI Automated Review
Full PR review.
Analysis engine: dsv4f@https://litellm.jory.dev/v1 (openai) — primary route
Review Summary
This PR addresses issue PR 297 by:
- Removing the redundant
reserved_resourcesguard inpersist()(sinceensure_defaults()already guarantees the key exists). - Adding a test that verifies
_clean_stale_reservations()callsmark_dirty()so that stale reservation cleanup triggers a save.
The changes are minimal, focused, and align with the linked issue’s acceptance criteria. The test is well-structured and correctly resets the dirty flag before calling the method to avoid a false positive. CI is green across all platforms.
Change-by-Change Findings
scripts/main.gd
- Removal of redundant guard: The two lines that checked for
reserved_resourcesand set it to{}are removed. This is safe becauseensure_defaults()incolony_sim.gdalready initializes the key. No other logic depends on this guard.
tests/test_reservations.gd
- New test
test_stale_reservation_cleanup_marks_dirty: Creates aColonySiminstance with a build that has a stale reservation, resetssim.dirtytofalse, calls_clean_stale_reservations(), and asserts thatsim.dirtyistrue. This directly validates the missingmark_dirty()call described in the issue.
Standards Compliance
- The test follows the existing pattern in
test_reservations.gd(directColonySiminstantiation, manual state setup). - The removal of dead code aligns with the repository’s preference for clean, minimal code.
- No new dependencies or manifest changes are introduced.
Linked Issue Fit
- Acceptance criteria:
- ✅
mark_dirty()call inside thebuild.has("reserved")branch in_clean_stale_reservations()– the test proves this call exists (the test passes, and the existing code incolony_sim.gdalready includes the call). - ✅ Verify with a test that stale reservation cleanup triggers a dirty flag – the new test does exactly this.
- ✅ Consider removing the redundant guard in
persist()– the guard is removed.
- ✅
- The PR fully satisfies the issue requirements.
Tool Harness Findings
Tool harness output was limited to file listing and diff reading; no issues were flagged.
Unknowns or Needs Verification
- The test only verifies the dirty flag is set; it does not verify that the reservation is actually cleaned up (i.e., that
reservedis erased). However, the existing testtest_stale_reservation_cleanupalready covers that behavior, so this is acceptable. - The PR does not add a test for the removed guard, but the guard was dead code and its removal is low-risk.
Recommendation: Approve. The changes are correct, well-tested, and address the linked issue completely.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds
_clean_stale_reservations()topersist_state()inscripts/main.gdso that on every save/load cycle, builds whose reserved resources exceed their remaining needs have the excess cleared. Two new tests intests/test_reservations.gdverify the cleanup behavio…Fixes #297
Opened by foreman on review GO (workload wl-misospace-windowstead-297).