Repository navigation
Studio: keep the user's git identity and gh login in unsloth start pi - #15865
Conversation
Review + reproduction evidencePinned review: I reproduced a shell command run by Pi through
Conclusion: real bug on the default |
|
Reached Codex review convergence at NilayYadav#922 on 25957a5. |
[skip ci]
|
Review record for #15865, carried over from the mirror it was reviewed on: danielhanchen/unsloth-staging-review#602. Findings are quoted as posted and attributed to the account that posted them. The reactions shown are the triage recorded on the mirror; none were re-applied here. Commits are named as the mirror's, with this PR's equivalent where one was found. Round 1: reviewed mirror
|
## Summary `unsloth_cli/tests/test_start.py` has 9 tests that fail on Windows on main. They only show up when a PR touching `unsloth start` gets a Windows leg (first seen on the staging xplat run for #15865, which changes none of them), because the regular CI does not run this file on Windows. In each case the product does the right thing for Windows and the test encoded a POSIX-only expectation: | Test | Windows failure | Why | |---|---|---| | `test_write_codex_subagent_bridge_keeps_parent_credentials_out`, `test_write_codex_parent_overlay_preserves_user_state_and_instructions` | `assert (33206 & 63) == 0` | `st_mode & 0o077` is a POSIX promise; Windows reports `0o666` for any writable file, whatever `os.open(..., 0o600)` asked for | | `test_no_launch_last_line_is_self_contained`, `test_no_launch_claude_last_line_blanks_conflicting_auth` | `KeyError: 'CODEX_HOME'`, no `ANTHROPIC_API_KEY= ` | they parse inline `NAME=value cmd`; on Windows `--no-launch` prints PowerShell, which the neighbouring `test_no_launch_output_is_parseable` already skips for | | `test_start_studio_server_builds_command_and_waits` | `assert '-X' == 'run'`, then `start_new_session` is `None` | on Windows the server is launched through this interpreter (`python -X utf8 ...`, #8490), so `run` is not `cmd[1]`, and it is detached with `CREATE_NEW_PROCESS_GROUP`, not a POSIX session | | `test_connect_pi_as_subagent_preserves_cloud_parent[False/True]` | `'...\\unsloth_cli\\pi_subagent.ts'.endswith('unsloth_cli/pi_subagent.ts')` | separator, compared as a POSIX path now | | `test_session_config_falls_back_when_existing_temp_root_is_unwritable`, `..._when_studio_auth_root_is_unwritable` | the "unwritable" root was written to | `mkdir(mode = 0o500)` / `chmod(0o500)` do not make a directory unwritable on Windows | ## What changed - The two mode-bit checks become `os.name == "nt" or ... & 0o077 == 0`. - The two last-line tests and the two unwritable-root tests skip on Windows, with the reason. - The studio server test finds `run` after the interpreter head on Windows and checks `creationflags & CREATE_NEW_PROCESS_GROUP` there; on POSIX it still requires `cmd[1] == "run"` and `start_new_session=True`. - The pi subagent test compares `Path(command[2]).as_posix()`. Nothing changes on Linux or macOS except that comparison. ## Verification - Linux: `unsloth_cli/tests/test_start.py` 949 passed, 1 skipped. - With `start.py`'s two `os.open(..., 0o600)` calls changed to `0o644`, both credential tests fail on Linux, so the permission guard still bites where it means something. - Windows (staging `windows-latest`): the first push fixed the two mode-bit tests and showed the other 7; the second left only the server test's detach check (`919 passed, 1 failed`); this push covers it, and the leg is re-running.
unsloth start pimoved HOME to a temporary session folder, and every shell command Pi runs inherits it. Inside Pi,git config --global user.emailcomes back empty,git commitfails with "Author identity unknown", andghno longer finds its login, while plainpion the same machine works. When the model tries to fix this itself, it writes a placeholder name and email into the session folder and commits under that made-up author.HOME now stays the user's own. Pi's config, provider, key and sessions still live in the session folder through PI_CODING_AGENT_DIR, which Pi already prefers over HOME, so nothing new lands in the real ~/.pi. Since Pi reads the user's ~/.agents/skills directly again, the link that copied it into the session folder is gone too. The same applies on Windows, where USERPROFILE is no longer moved.