Skip to content

refactor(config): consolidate starter-config creation on atomic writer (closes #144) - #160

Open
txltedxgod wants to merge 1 commit into
falbany:mainfrom
txltedxgod:fix/issue-144-consolidate-starter-config-atomic
Open

txltedxgod wants to merge 1 commit into
falbany:mainfrom
txltedxgod:fix/issue-144-consolidate-starter-config-atomic

Conversation

@txltedxgod

Copy link
Copy Markdown
Contributor

Summary

Closes #144

Consolidates the three independent implementations of 'format template + write' onto \write_starter_config\ and ensures all starter-config writes are atomic:

  1. Atomic starter creation: \write_starter_config\ now writes via \write_text_atomic\ (temp file in same directory + \os.replace), preventing corrupted/truncated .profiles\ files on interrupted --init\ or creation prompts.
  2. Consolidated delegation:
    • \profiles.app.init_default_config\ delegates directly to \write_starter_config.
    • \profiles.core.config.loader.propose_config_creation\ delegates directly to \write_starter_config.
    • \profiles.launch.creation.propose_creation\ (and the /api/config/create\ endpoint) continues delegating to \write_starter_config.
  3. Custom \cwd\ parameter: \write_starter_config\ now supports an optional \cwd\ keyword argument (defaulting to \Path.cwd()) for template placeholder substitution.
  4. Test coverage:
    • Added \ est_uses_atomic_write\ and \ est_writes_with_custom_cwd\ to \ ests/core/test_actions.py.
    • Added \ est_delegates_to_write_starter_config\ to \ ests/test_app.py.
    • Updated \ est_write_error_returns_false\ in \ ests/core/config/test_loader.py\ to verify atomic writer error handling.

All 227 configuration and creation tests pass cleanly.

@falbany

falbany commented Nov 11, 2026

Copy link
Copy Markdown
Owner

Thanks for this — clean consolidation, and making write_starter_config the single atomic writer is exactly what #144 called for. I've verified locally on your branch (3c2011e): 1521 tests pass, coverage 88.93%, pylint 9.88, pyright clean, and the logic reviewed well (the lazy profiles.core.actions import in loader.py avoids circularity, and the test mocks land correctly).

Two small things before merge:

  1. ruff format now runs as a CI gate (see .github/workflows/ci.yml, added today). Your branch has one violation: a missing blank line at tests/test_app.py:578 (after the from profiles.core.actions import ... line). Just run ruff format tests/test_app.py.

  2. Please rebase onto (or merge in) latest main — CI/Linux portability fixes landed in tests/core/test_actions.py, the same file this PR touches, and it's good to validate against the new quality gates.

Everything else looks good; no other changes requested. One non-blocking note: write_text_atomic uses mkstemp, so newly created .profiles files get 0600 permissions instead of umask defaults — arguably an improvement for a config file, just flagging the delta.

@txltedxgod
txltedxgod force-pushed the fix/issue-144-consolidate-starter-config-atomic branch from 3c2011e to d14e065 Compare November 11, 2026 23:16
@txltedxgod
txltedxgod requested a review from falbany as a code owner November 11, 2026 23:16
@txltedxgod

Copy link
Copy Markdown
Contributor Author

Thanks for the review @falbany! Addressed both items on d14e065:

  1. Ran ruff format on tests/test_app.py (ruff format --check . now reports all 223 files formatted, ruff check . clean).
  2. Rebased cleanly onto main (7c1e949).

Both Quality gates (Python) and Web front-end (build & tests) checks have passed on the updated branch (Windows packaging dry-run is still running).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

config: consolidate starter-config creation on one atomic writer (3 duplicate implementations, none atomic)

2 participants