test: add missing coverage for council/paths.py - #8
Merged
Merged
Conversation
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.
Why
council/paths.pyis the single source of truth for~/.passiveworkerslayout, and AGENTS.mdexplicitly calls out
write_private_jsonas load-bearing/security-sensitive:Despite that, the module had no dedicated test file — it was only exercised incidentally through
other tests (e.g.
tests/test_doctor.pypinscoordinator_entries()indirectly viacouncil.doctor). This closes that coverage gap directly.What this adds
New
tests/test_paths.py, covering all four public functions:home()— default resolves to~/.passiveworkers;PW_HOMEoverride works; an empty-stringPW_HOMEis treated as unset (guards theorfallback in the implementation).reports_dir()— default resolves underhome();PW_REPORTS_DIRoverride wins even whenPW_HOMEis also set.write_private_json()(the load-bearing one):0600(fresh write, overwrite, and aftermkdir(parents=True)).json.load().os.open(..., 0o600)directly rather thanopen()+ a separateos.chmod()call — theexact pattern that would reopen a world-readable window.
coordinator_entries()— the join.json/asker.json"default"sentinel bug this functionexists to prevent (see
tests/test_doctor.py's docstring for the original incident): excludes"default", excludes any non-dict value defensively, returns the right dict-valued entriesotherwise, handles the empty-state case, and doesn't mutate its input.
No production code changed —
council/paths.pyitself is untouched.Verification
All run from a fresh venv against this branch:
python -m py_compile tests/test_paths.py— cleanruff check .— all checks passedpytest tests/ -q— full suite green: 524 collected (523 passed, 1 pre-existing unrelatedskip), up from a 508-test baseline (524 − 16 new tests in this file). Zero failures, zero
regressions.
🤖 Generated with Claude Code