"""A Windows user imported the Tisusa .swarm (507 workspace files) and got an app card that said "This app's files are missing" (2026-09-04). The staging reader keyed files with the OS separator, the app importer looked for `workspace/`, skipped every file, and saved a hollow app. Bundle keys are slash-separated everywhere now, and a bundle that ships files but none under workspace/ fails loudly instead of importing a shell.""" import os import pytest from backend.apps.swarm import closure from backend.apps.swarm.entities.apps import AppExportable def test_bundle_keys_are_slashes_even_when_the_os_answers_with_backslashes(monkeypatch): real_relpath = os.path.relpath # The Windows shape: relpath answers with backslashes and the separator is a backslash. monkeypatch.setattr(os.path, "relpath", lambda full, start: real_relpath(full, start).replace("/", "\\")) monkeypatch.setattr(os, "sep", "\\") assert closure.bundle_key("/sb/entities/e1/files/workspace/app/index.html", "/sb/entities/e1/files") == "workspace/app/index.html" def test_the_staging_reader_uses_the_slash_keys(tmp_path): base = tmp_path / "entities" / "e1" / "files" / "workspace" / "app" base.mkdir(parents=True) (base / "index.html").write_bytes(b"