Skip to content

fix(setup): replace onboarding state atomically - #2816

Open
tang-vu wants to merge 1 commit into
Osmantic:mainfrom
tang-vu:fix/setup-atomic-state-writes
Open

fix(setup): replace onboarding state atomically#2816
tang-vu wants to merge 1 commit into
Osmantic:mainfrom
tang-vu:fix/setup-atomic-state-writes

Conversation

@tang-vu

@tang-vu tang-vu commented Aug 14, 2026

Copy link
Copy Markdown
Contributor

Summary

  • write persona, setup-progress, and setup-complete JSON through same-directory temporary files
  • flush and fsync each complete payload before atomic replacement
  • clean temporary files on both success and failure
  • cover replacement failure through the authenticated setup API boundary

Why this matters

The dashboard setup endpoints are the production writers for onboarding state. They opened active JSON files directly with w, truncating the current persona or setup marker before serialization completed. A process interruption, disk error, or failed replacement could therefore leave corrupt state and make the wizard regress to defaults. Atomic promotion preserves the last valid file until the new payload is durable.

Overlap check

Searched open and closed PRs for setup persona atomic write, setup-progress.json atomic, and changes to routers/setup.py. No PR covers onboarding-state durability. Existing atomic-write work targets .env, OAuth state, and extension receipts, not setup state.

Test plan

  • python -m pytest tests/test_setup.py tests/test_routers.py -q — 79 passed
  • python -m py_compile routers/setup.py tests/test_setup.py
  • git diff --check

Generated with Codex

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.

1 participant