Skip to content

fix: preserve vehicle construction across interrupted shutdowns - #32

Merged
ryanbarlow97 merged 2 commits into
mainfrom
fix/durable-construction-jobs
Oct 15, 2026
Merged

ryanbarlow97 merged 2 commits into
mainfrom
fix/durable-construction-jobs

Conversation

@ryanbarlow97

@ryanbarlow97 ryanbarlow97 commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

Vehicle construction consumed materials but kept the queued job only in memory until plugin shutdown. An interrupted shutdown could therefore discard an accepted aircraft or boat build. Save accepted jobs immediately, checkpoint progress every 30 seconds while busy, and persist completion, cancellation and station removal with atomic file replacement.

Record the output vehicle UUID before the construction event can save it through SimpleFactions. Recovery recognizes live or destroyed saved outputs, while a missing runtime output can be rebuilt. Save the finished vehicle before clearing its station, refund a rejected start through the existing cancellation event, and keep a job queued when a later save fails. Existing identity fields and legacy station saves remain supported. Saves leave timer displays intact; accepted starts and output recovery are logged.

Validation: tfmc-mvn -o -B --no-transfer-progress clean verify on Java 21; 56 tests and the existing 100% instruction/line/branch coverage gate pass. Regression coverage includes restoration without shutdown, checkpoint timing, atomic replacement failure, failed-start refunds, completion ordering, output recovery and failed cancellation/removal saves. Muse reviewed the design, implementation and final follow-up at 5d05774 with no blockers. CodeRabbit reported no actionable findings on the initial implementation; its follow-up review was rate-limited.

Limits: inventory, registration payments and station storage are separate stores; a process failure during their handoff can require staff reconciliation. This does not restore already-lost jobs. Before downgrading, resolve any saved outputUuid markers to avoid replay by an older reader.

Docs: TF-Minecraft/Docs#274

@github-actions github-actions Bot added the size:L 100-499 effective changed lines (tests excluded in mixed PRs). label Oct 15, 2026
@coderabbitai

coderabbitai Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 55 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: ca5a0c49-1082-43f5-8ef2-6783ab754a76
📥 Commits

Reviewing files that changed from the base of the PR and between 73e2929 and 5d05774.

📒 Files selected for processing: 6
  • src/main/java/net/tfminecraft/vfbuilders/core/ActiveStation.java
  • src/main/java/net/tfminecraft/vfbuilders/data/Database.java
  • src/main/java/net/tfminecraft/vfbuilders/managers/StationManager.java
  • src/test/java/net/tfminecraft/vfbuilders/DatabaseTest.java
  • src/test/java/net/tfminecraft/vfbuilders/ManagerTest.java
  • src/test/java/net/tfminecraft/vfbuilders/StationTest.java

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 2d2ed92f-09a3-4985-8192-390780aff0b8
📥 Commits

Reviewing files that changed from the base of the PR and between 5f34832 and 73e2929.

📒 Files selected for processing: 7
  • src/main/java/net/tfminecraft/vfbuilders/core/ActiveStation.java
  • src/main/java/net/tfminecraft/vfbuilders/data/Database.java
  • src/main/java/net/tfminecraft/vfbuilders/managers/StationManager.java
  • src/test/java/net/tfminecraft/vfbuilders/DatabaseTest.java
  • src/test/java/net/tfminecraft/vfbuilders/ManagerTest.java
  • src/test/java/net/tfminecraft/vfbuilders/SchedulerTest.java
  • src/test/java/net/tfminecraft/vfbuilders/StationTest.java

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.

📝 Summary

Summary by CodeRabbit

  • Bug Fixes
    • Construction progress is now preserved when saving fails, helping prevent accepted builds from being lost or duplicated.
    • Failed construction starts return the materials, and station breaks are cancelled when construction cannot be safely saved.
    • Station removals are rolled back if they cannot be saved successfully.
    • Completing or cancelling a build now handles already-saved outputs without creating duplicates or refunding the blueprint incorrectly.
  • Reliability
    • Station data is saved periodically while builds are active, and saving no longer removes station holograms.

Station construction now checkpoints output vehicle identifiers and saves station data atomically. Completion, cancellation, construction starts, and station removal use save results to determine whether to retain or clear state.

Changes: Station Persistence and Construction

Layer / File(s) Summary
Persist station state
src/main/java/net/tfminecraft/vfbuilders/data/Database.java, src/test/java/net/tfminecraft/vfbuilders/DatabaseTest.java
Station saves write UTF-8 JSON to a temporary file and replace the destination atomically. Station data now stores and restores output UUIDs. Tests cover failed replacement, preservation of existing data, and output UUID persistence.
Checkpoint construction output
src/main/java/net/tfminecraft/vfbuilders/core/ActiveStation.java, src/test/java/net/tfminecraft/vfbuilders/StationTest.java
ActiveStation checkpoints a spawned output UUID before dispatching the construction event. It reuses matching vehicles, saves live vehicles before clearing construction, and preserves construction state when persistence fails.
Manage station checkpoints and removal
src/main/java/net/tfminecraft/vfbuilders/managers/StationManager.java, src/test/java/net/tfminecraft/vfbuilders/ManagerTest.java, src/test/java/net/tfminecraft/vfbuilders/SchedulerTest.java
StationManager binds station checkpoints, saves active blueprints every 600 ticks, and checks save results during construction starts and station removal. Tests cover save failures, state retention, and scheduled saves.

Priority: ➖ Normal

Estimated code review effort: 4 (Complex) | ~45 minutes

Change: Bug fix

Sequence Diagram(s)

sequenceDiagram
  participant StationManager
  participant ActiveStation
  participant Database
  participant VehiclePersistence
  StationManager->>Database: Save station state when construction starts
  ActiveStation->>VehiclePersistence: Get persistence for construction completion
  ActiveStation->>StationManager: Run station checkpoint
  StationManager->>Database: Save station state with output UUID
  ActiveStation->>VehiclePersistence: Save live vehicle
  ActiveStation->>ActiveStation: Clear construction after successful save
Loading
Merge Risk: ⚪ Minimal · up to 73e29

No demonstrated issue blocks merging after normal checks.

- [ ] Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

coderabbitai[bot]
coderabbitai Bot previously approved these changes Oct 15, 2026
@ryanbarlow97
ryanbarlow97 merged commit d3349dd into main Oct 15, 2026
3 checks passed
@ryanbarlow97
ryanbarlow97 deleted the fix/durable-construction-jobs branch October 15, 2026 23:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 effective changed lines (tests excluded in mixed PRs).

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant