Skip to content

bug(native): RemoveRoot can unmap a path while its transfer writer is still admitted #136

Closed

Description

@Seagulls

Summary

OpenSave can acknowledge ordinary native RemoveGameRoot while a previously admitted native writer still owns the root's captured filesystem path. The mapping is removed before that writer has finished using it. This is a root-topology admission race; removal itself is not intended to delete files.

Baseline: Liquid-co/OpenSave:dev-public@a0f6032b8ba36da25e3e0e5e90c5ace9ba0c1fc7. Reproduced on Linux amd64 against disposable native HTTP/SQLite fixtures and synthetic files only.

Independent reproduction

Public Go regression · Reproduction guide

git checkout repro/native-root-lineage-import-20261030
go test -count=1 -race -v ./internal/api -run '^TestRegressionRemoveRootRefusesActiveNativeWriter$'

The test registers an additional config root with slot.sav = ORIGINAL, holds OpenSave's real native Sync.Writing(gameID) gate, then calls DELETE /api/games/{id}/roots/config. Stock returns 200, and the mapping disappears while the writer remains admitted. Required: 409, intact mapping, then successful removal after the writer releases, without deleting slot.sav.

This focused witness models an active writer gate; it is not a complete two-peer file-transfer replay.

Root cause

internal/api/routes_roots.go permits topology mutation without excluding native path users. internal/store/game_roots.go serializes the SQLite change, not outstanding transfers that have already captured paths. Supported CLI root commands should not circumvent the running daemon's admission even when its published daemon.addr file is missing.

Bounded suggested fix

Use a per-game, nonblocking native topology reservation held across the authoritative mutation and subsequent root/watch updates, with a truthful conflict while previously accepted writers or queued work still use the root. Route the independent OpenSave CLI through that authority or refuse unsafe offline mutation. Do not introduce a new transfer engine, permanent managed-game mode or unrelated lifecycle framework.

Acceptance criteria

  • The exact-stock test fails for the expected HTTP 200/removed-mapping assertion; patched implementation returns 409 and preserves the mapped root.
  • AddRoot, RemoveRoot, remap and supported CLI entry points respect already admitted writers, including with missing daemon.addr.
  • Removal after work finishes succeeds and never deletes physical files; queued/native work is not silently lost.
  • Existing unrelated-game operations, Go tests, race checks, Linux build and Windows cross-build pass.

Evidence limit: No claim of deployed user-save loss, full two-peer replay, or native Windows runtime verification.


Independent public reproducer and original report: Seagulls#13.

Activity

  1. Seagulls commented on Nov 4, 2026

    @Seagulls
    Author

    The daemon-local topology race is addressed by merged PR #139. The independent CLI/daemon ownership case, including missing or stale daemon.addr, is now tracked separately in #146, as requested when separating lifecycle/takeover work from that PR.

    #146 is an awareness tracker for maintainer-led follow-up; it does not claim that the original independent-process acceptance criterion has passed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions