fix(agent): non-root XDG fallback for state-db/events/policy paths (#159)#160
Merged
Conversation
) The personal/user-session profile is designed for non-root use (control socket + keystore already fall back to XDG), but default_state_db_path (/var/lib/sigil), default_events_dir (/var/log/sigil), and default_policy_yaml_path (/etc/sigil) had no non-root fallback. A non-root `sigil run` aborted with a bare EACCES before binding the control socket, and the rule-packs watcher (derived from the policy dir) armed on /etc/sigil instead of the documented ~/.config/sigil — silently breaking hook enforcement even when the daemon did start. Mirror resolve_keystore_path_unix: root keeps the system paths; non-root falls back to $XDG_STATE_HOME/sigil/{state.db,events} (else ~/.local/state/sigil) and $XDG_CONFIG_HOME/sigil/policy.yaml (else ~/.config/sigil). The daemon already create_dir_all's both locations. Consolidate the three duplicated copies (main.rs/doctor.rs/show.rs) into pub lib fns with pure unit-testable resolvers. Verified on a fresh macOS install (v0.5.1 binary): no-flag `sigil run` now starts non-root, watches ~/.config/sigil/rule-packs.yaml (matching docs/install-personal.md), and the hook deny/allow chain works end-to-end. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
What
Gives
state.db, the events dir, andpolicy.yaml(and therule-packs.yamlderived from it) the non-root XDG fallback that the control socket and keystore already have. Fixes the documented personal/OSS install path on macOS / non-root Linux.state.db/var/lib/sigil/state.db$XDG_STATE_HOME/sigil/state.db→~/.local/state/sigil/state.db/var/log/sigil$XDG_STATE_HOME/sigil/events→~/.local/state/sigil/eventspolicy.yaml/rule-packs.yaml/etc/sigil/…$XDG_CONFIG_HOME/sigil/…→~/.config/sigil/…Root behavior (systemd/packaged) is unchanged. The three duplicated default-path copies (
main.rs,doctor.rs,show.rs) are consolidated intopublib functions with pure, unit-tested resolvers mirroringresolve_keystore_path_unix.Why (found via fresh-install verification)
Following
docs/install-personal.mdverbatim on a clean macOS machine, the documentedsigil run(no flags) aborted with a barePermission denied (os error 13)— the daemon tried to create/var/lib/sigiland/var/log/sigilas non-root. Worse, even past that, the rule-packs watcher armed on/etc/sigil/rule-packs.yaml(derived from the policy dir) instead of the documented~/.config/sigil/rule-packs.yaml, so hook enforcement silently never loaded the user's rule pack. All three are the same class: the non-root XDG fallback was applied to the socket/keystore but missed here. Full investigation in #159.Verification
Fresh install of the published v0.5.1 binary, then this branch's binary, HOME-isolated, no path overrides:
sigil runstarts non-root; auto-creates~/.local/state/sigil/{state.db,events}.~/.config/sigil/rule-packs.yaml(matches the doc).sigil-hook claude-code --enforcewithrm -rf …→permissionDecision: deny;ls→ allow (silent).sigil show risk→ assessments;sigil doctorhost_id now[OK](no more/var/lib/sigilwarn).Tests
nonroot_path_tests(root→system / non-root→XDG / →HOME / →system last-resort, ×3 paths).cargo fmtclean · workspaceclippy -D warningsclean · workspace tests green.Fixes #159
🤖 Generated with Claude Code