refactor(paths): replace eager constants with lazy getters (N4)#27
Merged
Conversation
Theme N4 — Drop eager paths.ts constants. The bare exports `codexDir`, `accountsDir`, `authPath`, `currentNamePath`, `registryPath`, and `sessionMapPath` were evaluated at module import time, so env-var overrides (`CODEX_AUTH_CODEX_DIR`, `CODEX_AUTH_JSON_PATH`, etc.) set after the first `import` had no effect. That broke tests that set the env after `require()`, and broke systemd `--user` daemons that inherited a different `HOME` than the user-facing CLI. All internal call sites already use the `resolveX()` functions; no conversions were needed in this PR. The bare constants are now marked `@deprecated` and scheduled for removal in v0.2.0 so any external library consumers get a one-release migration window. A new `src/tests/paths.test.ts` proves the resolvers track env-var changes applied after module load, and includes a regression guard asserting the deprecated bare constants do NOT track env-var changes (so we know the defect is gone when v0.2.0 removes them). Exit criteria (docs/future/17-ROADMAP.md Theme N4): - No file imports the bare constants. - Constants marked @deprecated with one-release removal note. - Test under src/tests/paths.test.ts proves env-var changes apply after module load.
This was referenced May 17, 2026
NagyVikt
added a commit
that referenced
this pull request
May 18, 2026
Bumps package.json + package-lock.json from 0.1.24 to 0.1.25 and extends releases/v0.1.25.md to cover every theme that landed since v0.1.24: - N1 durability (#29): atomic writes, registry lock, fsync-before-rename - N2 account-service split (#30): 1675 LOC -> 164 LOC orchestrator + 12 modules - N3 error taxonomy + --json (#28): AuthmuxError base, stable codes, JSON envelope - N4 lazy path resolvers (#27): bare constants deprecated for v0.2.0 - P0 wave (#26): secure perms, [y/N] update prompt, kiro ENOENT, CI matrix, registry proxy-source round-trip, 18k-line improvement docs Notes follow the canonical 7-section shape from docs/future/17-ROADMAP.md (Added, Changed, Fixed, Deprecated, Removed, Security, Migration), with the prior Durability section folded into a "Theme deep-dives" appendix so the canonical shape is intact. No code changes. No npm publish. Verification: - npm run build: clean - npm test: 129/129 pass - node -e "require('./package.json').version" -> 0.1.25 - node -e "require('./package-lock.json').version" -> 0.1.25 Co-authored-by: NagyVikt <nagy.viktordp@gmail.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.
Summary
Implements Theme N4 — Drop eager
paths.tsconstants fromdocs/future/17-ROADMAP.md.The bare exports
codexDir,accountsDir,authPath,currentNamePath,registryPath, andsessionMapPathinsrc/lib/config/paths.tswereevaluated at module import time, so env-var overrides set after the first
importhad no effect. Rationale lives indocs/future/01-ARCHITECTURE.md§10.2.All internal call sites already use the
resolveX()functions; the bareconstants are now marked
@deprecatedand scheduled for removal in v0.2.0so any external library consumers get a one-release migration window.
Exit criteria
codexDir,accountsDir, etc.).@deprecatedwith a one-release removal note (v0.2.0).src/tests/paths.test.tsproves env-var changes apply after module load.Files changed
src/lib/config/paths.ts— JSDoc@deprecatedon six bare constants; resolvers unchanged.src/tests/paths.test.ts— new; 6 tests covering all five resolvers plus a regression guard.Zero call-site conversions were required:
grepconfirms every importer ofconfig/pathsalready pulls inresolveX()functions, not the bare names.Verification
Behavior change
None for end users. Pure refactor + new test. The deprecated constants still resolve to the same paths they always did.
Coordination
Sibling PRs from N1 (durability) and N3 (errors taxonomy) running in
parallel; expect a rebase if they land first. This PR deliberately did
not touch command file bodies (only resolver-import sites would
change anyway, and there were none), so the conflict surface with N3 is
empty.
Test plan
npm run buildcleannpm test— 91/91 pass on Node 22 / Linux