Skip to content

fix(agent): non-root XDG fallback for state-db/events/policy paths (#159)#160

Merged
Ju571nK merged 1 commit into
mainfrom
fix/personal-nonroot-paths-159
Jun 14, 2026
Merged

fix(agent): non-root XDG fallback for state-db/events/policy paths (#159)#160
Ju571nK merged 1 commit into
mainfrom
fix/personal-nonroot-paths-159

Conversation

@Ju571nK

@Ju571nK Ju571nK commented Jun 14, 2026

Copy link
Copy Markdown
Owner

What

Gives state.db, the events dir, and policy.yaml (and the rule-packs.yaml derived 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.

path was (all users) now (non-root)
state.db /var/lib/sigil/state.db $XDG_STATE_HOME/sigil/state.db~/.local/state/sigil/state.db
events dir /var/log/sigil $XDG_STATE_HOME/sigil/events~/.local/state/sigil/events
policy.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 into pub lib functions with pure, unit-tested resolvers mirroring resolve_keystore_path_unix.

Why (found via fresh-install verification)

Following docs/install-personal.md verbatim on a clean macOS machine, the documented sigil run (no flags) aborted with a bare Permission denied (os error 13) — the daemon tried to create /var/lib/sigil and /var/log/sigil as 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 run starts non-root; auto-creates ~/.local/state/sigil/{state.db,events}.
  • rule-packs watcher targets ~/.config/sigil/rule-packs.yaml (matches the doc).
  • sigil-hook claude-code --enforce with rm -rf …permissionDecision: deny; ls → allow (silent).
  • sigil show risk → assessments; sigil doctor host_id now [OK] (no more /var/lib/sigil warn).

Tests

nonroot_path_tests (root→system / non-root→XDG / →HOME / →system last-resort, ×3 paths). cargo fmt clean · workspace clippy -D warnings clean · workspace tests green.

Fixes #159

🤖 Generated with Claude Code

)

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>
@Ju571nK Ju571nK merged commit 082eb95 into main Jun 14, 2026
5 checks passed
@Ju571nK Ju571nK deleted the fix/personal-nonroot-paths-159 branch June 14, 2026 14:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

personal install: sigil run fails as non-root (state-db/events-dir lack XDG fallback) — blocks documented macOS/Linux personal path

1 participant