Repository navigation
feat(install): report a rejected state root at install and doctor time, and offer to fix it - #794
Merged
Merged
Conversation
…e, and offer to fix it The state writer refuses a state root another account can write to. On a native Windows host with a Codex sandbox account that is the default location, so every state-writing pmctl command stopped after an install that looked fine. - doctor fails with the reason and the fix instead of leaving the first pmctl call to be refused. - install.sh ends with the same warning; --fix-state-root (or a yes at an interactive prompt) creates ~/.pm-dispatch-state owner-only, confirms the guard accepts it, and on native Windows records it as the user's PM_DISPATCH_STATE_ROOT. An existing directory is checked, never re-permissioned; the check stays on. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P8BvZ5Crn6vi6EA2J7
… a person cancel The warning came after the install had finished. It now runs before any change: a person at a terminal chooses y (use ~/.pm-dispatch-state), n (install unchanged) or c (cancel, nothing changed); a scripted install still only warns, and --fix-state-root still repairs without asking. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P8BvZ5Crn6vi6EA2J7
… root exclusively, test repair and consent on every platform Gate remediation: critic-F001 (icacls options rewritten by MSYS), qa-tester-F001/F002 (native-capable repair and y/n/c/existing-destination coverage), security-reviewer-F001 (exclusive creation). Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P8BvZ5Crn6vi6EA2J7
… real ACL grant Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P8BvZ5Crn6vi6EA2J7
…tage needs to delete an owner-only directory Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P8BvZ5Crn6vi6EA2J7
…account, not the profile name Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P8BvZ5Crn6vi6EA2J7
…tor's new check accepts them on native Windows A state root made with mkdir -p under the temp root inherits a write grant for another principal on native Windows (e.g. the Codex sandbox group), which Doctor now reports as a failure. The stale and indeterminate detached-run cases create their state root with an owner-only helper instead. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
…ve Windows The repair promises to inspect an existing directory and never change its permissions. The Windows branch of the existing-directory case checked contents and persistence only, so moving the icacls call outside the creation branch would still pass. It now compares the directory's real ACL before and after the repair. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
…d ACL in one step mkdir followed by icacls left a window in which the new directory carried whatever its parent grants (a Codex sandbox group, for example), and another principal could plant files in it that the later ACL change does not remove. The root is now created with Win32 CreateDirectoryW and a protected owner/SYSTEM/Administrators descriptor supplied at creation, which also refuses a leaf that already exists as a directory or a junction. Without a working PowerShell nothing is created. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
…ld inherit on Windows pmctl state status reported a missing state root as safe because there was nothing to inspect. The first writer creates it, and on native Windows it takes whatever its parent grants, so install's preflight skipped the repair and doctor said safe on exactly the clean-install path the check exists for. The read-only check now looks at the nearest existing ancestor and counts only grants a new child directory would inherit (ContainerInherit, and for deeper missing levels not NoPropagateInherit), for the account that would create it. A dangling link, a non-directory or an unverifiable ACL is reported unsafe. Nothing is created. The doctor fixtures put their homes under the temp root, which can carry such a grant, so the test makes that root owner-only once instead of every case depending on the host's temp ACL. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
…the previous records stay Switching PM_DISPATCH_STATE_ROOT leaves task history, operation records and worktree registrations under the previous root, so from the new one they look gone. The repair now names the previous root when it holds anything and says how to keep using it; a missing or empty previous root says nothing. The platform guide and the changelog carry the same note. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
…ive Windows The first state_store_init case created its store under a temp root that inherits a Codex sandbox group grant, which the canonical writer rejects, so the whole suite aborted before reaching later cases (including the absent-state-root ones). The temp root is the test's own scratch directory, so it is made owner-only once, as test-doctor does. The suite now runs to the end natively: 88 PASS, 2 FAIL (non-owned store root cannot be simulated without POSIX owners; Windows path spelling partition keys), both also failing on main. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
…t too pmctl state status exits 3 with a complete JSON report when the store layout is incompatible or unreadable. Doctor's state-root check and install's state_root_unsafe_reason both treated any non-zero exit as "cannot inspect", so a rejected root on such a store was neither warned about nor offered the repair. Both now accept exit 3 and still ignore other failures. A doctor case covers an unsafe root with an incompatible VERSION, for Doctor and for the install check. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
…hell; silence three intended shellcheck infos PM_DISPATCH_PLATFORM=windows selects a profile on any OS, but the absent-root ACL probe needs PowerShell and cygpath. On Linux CI the override made the probe fail closed and Doctor reported a rejected state root for a root that was fine (doctor-windows-auto-profile-codex-on-path). The probe now also requires a real msys/cygwin shell. SC2016 (literal PowerShell expression) and SC2030/SC2031 (a stub PATH set on purpose in a subshell) are disabled at the line with the reason. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
The absent-root ACL probe now reads OSTYPE in runtime/lib/pmctl-state.sh, so the variable consumer graph that lint-script-domain-inventory checks needs that row. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01ESW7P9zqMvS4GeAcn3S3Jw
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
doctornow reports a rejected state root as[FAIL]with a concrete fix, instead of tools installing and then failing with "unsafe state root rejected" (the recurring Windows Temp ACL problem from the Codex sandbox group, Native Windows: 默认状态目录因继承来的 CodexSandboxUsers 修改权限被 ACL 守卫拒绝,报错未指明主体也无补救指引 #778/測試隔離:%TEMP% 對 CodexSandboxUsers 有寫入權限時,test-pmctl-context.sh 的 telemetry 案例被 ACL 守衛拒絕 #782).install.shchecks the state root before changing anything. Interactive: asks[y/n/c](create a private state dir and install / install unchanged / cancel). Non-interactive: warns only, unless--fix-state-rootis passed.--fix-state-rootcreates a NEW private dir (~/.pm-dispatch-state, owner-only ACL via icacls or chmod 700), verifies the guard accepts it, and persistsPM_DISPATCH_STATE_ROOT(setxon Windows, prints an export line elsewhere). It never edits an existing directory's ACL and never disables the guard.Tests
test-doctor:case_doctor_unsafe_state_root_fails_with_remedytest-install:test_install_reports_and_fixes_rejected_state_rootPermanent test admissions: case_doctor_unsafe_state_root_fails_with_remedy, test_install_reports_and_fixes_rejected_state_root — contract tests for a user-facing failure and its remedy, added to existing suites.
🤖 Generated with Claude Code
https://claude.ai/code/session_01ESW7P8BvZ5Crn6vi6EA2J7