Files

5.4 KiB

Publish immutable save requests asynchronously on Windows

Task ID: S15-01 Role: astra_implementer Status: READY

1. Context and baseline

Exclusive /home/faumaray/Projects/stoneheart_at_home-worktrees/s15 system/s15-persistence, baseline 8d2870a. Root and other authors use different checkouts. S15-W02, M01-P2/F3, Void pin 7b0fea6. Root created Void/Library#3 for unsupported Windows replace_file.

2. Objective and deliverables

Implement a bounded FIFO background Windows save service, with atomic same-volume publication of immutable request content and meaningful failure outcomes. Provide API/test surface for viewer and later checkpoint framing.

3. Scope and non-goals

Own independent S15 file service only. No UI/World/serialization format change. Input is a snapshot-owning producer (or shared immutable bytes) with tick, epoch and request identity; synchronous existing save helper remains until owner integration.

4. Files to inspect

Inspect app/viewer_win32.cpp::save_world_file, current save codec, docs/plan/systems/S15.md. In exact pin inspect Void/System/Path.hpp (ReplaceFailure, unsupported Windows), Void/Async/{ThreadExecutor,FuturePool}.hpp for a single writer and bounded admission. Existing env and library checkout are in /tmp/stoneheart-verify.KoZwE4o8.

5. Write ownership and coordination

Write scope: engine/include/settlement/core/save_service.hpp; engine/src/save_service_win32.cpp; tests/save_service_tests.cpp; CMakeLists.txt You are not alone. Use explicit workdir/absolute paths only in specified worktree; others own independent systems. Root handles CMake merges/Git. Do not edit main or change shared Serena project.

6. Implementation or investigation approach

Give each accepted save a monotonic request identity, captured tick and session UUID (reuse Void::Uuid::Uuid or consistent fixed bytes). Materialize from immutable producer on writer thread or allow shared immutable bytes, further integration must keep snapshot acquisition cheap. Bound queue including in-flight and return Busy/Closed before ownership side effects. One FIFO writer ensures older accepted saves cannot replace newer same-slot requests. Use pinned Void Async where suitable. Worker completes all accepted requests on shutdown. A failed producer/write must deliver completion and next FIFO task continues.

7. Interfaces and data contracts

Publish to a unique same-directory staging file created exclusively, write all bytes incl embedded NUL, handle short/error or close failure, explicitly FlushFileBuffers, atomically rename with replacement on the same volume; preserve previous slot on any prepublication failure, remove only owned staging files and distinguish postpublication visible/durability-unknown. First create, Unicode paths, sharing errors. Keep application-crash observations separate from power-loss guarantees. Local adapter + replacement criterion and upstream #3 link. Deterministic fault injection at phases for test; do not broaden external access. Communicate API early.

8. Dependencies and integration

S01 runtime later captures immutable snapshot/manifests, S15 checkpoint codec constructs bytes, UI will enqueue this service and poll completion. No dependency on unfinished runtime/system branch. CMake public types require actual transitive includes for callers.

9. Edge cases security and performance

Serialize FIFO submission ordering even if concurrent callers; expose or check order via returned IDs. No blocking UI submission, no mutex held waiting for disk/producer or while joining. Same-directory sibling preserved on failures. Use isolated temporary directory for tests, never overwrite user files. Reject missing parent/closed service; documents should make overwrite/new behavior clear.

10. Acceptance criteria

  1. Unicode path succeeds on create/replace while readers see full contents. 2. Prepublication failures preserve old bytes, temp cleaned, postpublication failure truthful. 3. Slow earlier/newer order on a single slot, bounds, shutdown drain, producer exception followed by next success verified. 4. Tests establish immutable snapshot life & UI caller progress without sleep-only assertions; tag save-slot and run under Wine.

11. Verification commands and evidence

Source /tmp/stoneheart-verify.KoZwE4o8/env.sh. From YOUR worktree configure cmake -S . -B /tmp/stoneheart-milestones.xprJ2SVp/save-build -G Ninja --toolchain "$SETTLEMENT_VERIFY/cross.cmake" -DBUILD_TESTING=ON -DCMAKE_BUILD_TYPE=Release -DFETCHCONTENT_SOURCE_DIR_VOID_LIBRARY:PATH="$SETTLEMENT_VERIFY/candidate/_deps/void_library-src". Build with cmake --build --parallel 6, run ctest --test-dir --output-on-failure and your targeted tests. Evidence required. Tests use new empty temp dirs, Windows/Wine results labelled. Collect native limitations. Provide specific replacement test for Void #3.

12. Constraints and stop conditions

Stop if Windows primitive cannot meet claimed contract or tests prove a different outcome. After two failed repairs escalate with artifacts. No external writes, further agents, branch operations, admin actions or out-of-scope edits.

13. Authorization and decisions

User approved entire roadmap and per-system development with commits/push from root. F3 accepted FIFO ordering and failure semantics. Upstream issue already exists.

14. Return format

Return S15-01 status, exact API/files, failure/visibility semantics, commands/counts, native verification still needed and integration notes. No subagents.