WIP: fix(sandbox): Windows: a confined start takes its profile's start slot: profile.json is read once the sandbox is in #2827
No reviewers
Labels
No labels
area/accessibility
area/audio
area/input
area/install
area/menu
area/mods
area/renderer
area/saves
area/tooling
area/upscaling
beanstalk: approved
beanstalk: failed
beanstalk: needs approval
beanstalk: running
beanstalk: tested
ci: approved
good first issue
gpu/amd
gpu/igpu
gpu/intel
gpu/nvidia
help wanted
kind
bug
kind
chore
kind
docs
kind
feature
kind
performance
kind
question
needs measurements
platform/linux
platform/macos
platform/steam-deck
platform/windows
preview
priority
critical
priority
high
priority
low
regression
risk
high
risk
low
risk
medium
status
blocked
status
confirmed
status
duplicate
status
invalid
status
needs-info
status
wontfix
ci: approved
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
MagicBeanDev/Longshot!2827
Loading…
Reference in a new issue
No description provided.
Delete branch "llun/Longshot:fix/mod-api-win-profile-slot"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
For #2822 (into
mod-api). On Windows, a confined start (the sandbox's default) ignores its profile's start slot.profile_start_slot(host/hos_main.c) reads the profile'sprofile.jsonand hands itsstart_sloton asHOS_START_SLOT. On Windows it ran right afterlongshot_env.txt, beforehos_sandbox_start. Inside the AppContainer,profile.jsoncan only be opened through the builder's file layer, whichhos_sandbox_startputs in, so the open was refused. Every confined run then loggedprofile: <profile> (no profile.json: no start slot)and started on no slot, whatever the profile chose. This reads it at the end of the sandbox's block instead, still afterlongshot_env.txt(which may setHOS_START_SLOT, taken away first). Nothing readsHOS_START_SLOTbefore then: its only reader isgame/crates/api/src/save_start.rs, at the game's start. Linux's start is unchanged, since the builder's Landlock is in before the exec.To see it on
mod-api: Windows, the sandbox on,LONGSHOT_PROFILEnaming a profile whoseprofile.jsonhas astart_slot. The log'sprofile:line saysno profile.json. (On plainmod-apia confined start with a profile stops earlier, at the save folder: #2726's first two bugs. The runs below have #2726's save-folder fix and the same broker change applied locally, beneath this PR.)Read first: the sandbox's block in the Windows
mainofhost/hos_main.c.Testing
Tested: Windows 11, RTX 5080, a confined start through
longshot-builder gamewith a profile whoseprofile.jsonhas"start_slot": "slot_00". Before:profile: …\profile (no profile.json: no start slot). After:profile: …\profile; its start slot slot_00 (HOS_START_SLOT=0), withsandbox: in the AppContainer, the builder reached …just before it, and Skip title screen started.Checks: the new
tests/test_sandbox_profile_slot.pycuts the Windows start (fromload_longshot_env()through the sandbox's block) andprofile_start_slotfromhost/hos_main.cand compiles them with stand-ins, whereprofile.jsonopens only outside the container or once the file layer is in. It fails onmod-api@eaf4a48b(HOS_START_SLOT -,no profile.json: no start slot) and passes here, on Windows (llvm-mingw clang) and Linux (WSL Ubuntu 24.04, gcc). With the fix's lines undone it fails again, as doestests/test_game_start.py. That check's order rule is updated, not dropped: Linux reads the slot right afterlongshot_env.txt, Windows after it and afterhos_sandbox_start. The 44 checks that readhost/hos_main.cwere run: the ones failing here fail the same way onmod-apion this PC (POSIX headers and calls in Linux-only checks, the MSVC host's cargo).mise run lintpasses.Still to test:
start_slot, expecting the sameprofile:line as before this PR (@Beanstalk: a Linux start with a profile's start slot)Measurements
Verdict: fixed. A confined Windows start takes its profile's start slot.
Baseline:
mod-api(#2822's head), the branch this PR goes into: the bug is there, not onmain. The in-game runs are both onmod-apiwith #2726's save-folder fix and the broker change applied locally, beneath this PR.Setup: Windows 11, RTX 5080, NVIDIA 621.40. The same profile (
"start_slot": "slot_00"), started confined throughlongshot-builder game. Its log'sprofile:line, and the check.eaf4a48bd455c5a0profile:line, confined(no profile.json: no start slot)its start slot slot_00 (HOS_START_SLOT=0)tests/test_sandbox_profile_slot.pyRisks
The sandbox: no grant, root or right changes.
profile.jsonis read through the builder's file layer, under the file-read grant the plan already gives it (sandbox: allowed file-read …\profile.json). Reading it afterhos_sandbox_startis what keeps that read inside the confinement: before the sandbox was in, the confined game's open was refused.Only Windows' start changes: the profile is read a few calls later, after the sandbox's start. A Windows start that HOS_SANDBOX=0 leaves unconfined reads it at the same place, where it opens as before. A revert is enough. A player notices that a profile's start slot now applies on Windows.
Checklist
Ready for review
mod-api(#2822's head); the title is a Conventional Commit.mise run testpasses (any failure that also fails onmainis named). (The checks this change reaches pass.mod-api's whole suite has failures on Windows that this PR doesn't change: #2825 and #2826 fix eight of them.)main, or Measurements says why there is nothing to measure.third_party/untouched; nothing GPL-incompatible.When it applies
mainand passes here. (It fails onmod-api, where the bug is.)tests/that reads changed source is updated, not weakened.Assisted-by:/Co-Authored-By:trailers.Ready to merge
main, measured again or a comment says why the numbers still hold.🤖 Generated with Claude Code
host/hos_main.c's Windows start, from load_longshot_env() through the sandbox's block, and profile_start_slot cut from the source and compiled with stand-ins: profile.json opens outside the container, or inside it once hos_sandbox_start has put the builder's file layer in. A profile whose start_slot is slot_03 must give HOS_START_SLOT=3 inside the container and outside it. It fails on mod-api: the confined game reads profile.json before the sandbox is started, the open is refused, and the start takes no slot ("profile: ... (no profile.json: no start slot)"). Assisted-by: Claude Code Co-Authored-By: Claude Opus 5.5 <[email protected]>Tested in the game: Windows 11, RTX 5080, NVIDIA 621.40, a confined start through
longshot-builder gamewith a profile whoseprofile.jsonhas"start_slot": "slot_00"(onmod-apiwith #2726's save-folder fix and the broker change applied locally, beneath this PR). Before:profile: ...\profile (no profile.json: no start slot). After:profile: ...\profile; its start slot slot_00 (HOS_START_SLOT=0), withsandbox: in the AppContainer, the builder reached ...before it, and Skip title screen started.0fc794cc3322f0dd2ce6Rebased onto mod-api's new squash
eaf4a48b(the same tree as9e6b9c57, which this branch was on): the diff is this PR's own commits again. The checks and runs above hold as they are (the tree under them is unchanged); the description's commits are the new ones.Risks now says how this change stands with the sandbox (what it touches, and why the confined game reaches nothing more).
22f0dd2ce60bfefe8616Rebased onto mod-api's newest (
4cc50ca1: main's newest merged in), with no conflict; this PR's own checks were run again on the rebased head and pass as before. The merge touched none of this PR's files (#2827: only a comment in host/hos_main.c, far from its change), so the measurements and runs above hold; the After commit is the rebased head.0bfefe86160b74d3d55aRebased onto
mod-api@816d2354(#2837, headless shots of the mods' UI), now0b74d3d5. No conflict, and the diff is the same as before (samegit patch-id). #2837 touches none of this PR's files.0b74d3d55a58e5f8323358e5f83233d455c5a046Rebased onto
mod-api@c5e5b676: it was re-squashed onto main @46291934(#2833) twice today (cdbb8551, thenc5e5b676), which made this PR show main's and the whole mod API's diff. Nowd455c5a0, the same diff as before (samegit patch-id), no conflict. The changes underneath touch none of this PR's files, so its checks still hold.View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.