Guard refresh_init_apps() to only run on first startup#32
Merged
Conversation
Use a persistent DB flag ("initial_apps_installed") to ensure initial
apps from config are only installed on the very first startup. On
subsequent restarts the flag is present and the function returns early,
preventing previously-uninstalled initial apps from being re-installed.
Closes #28
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…est assertion Replace inline string literal "initial_apps_installed" with a module-level constant STORE_KEY_INITIAL_APPS_INSTALLED, consistent with the established convention for all other DB keys in the codebase (STORE_KEY_BACKUP_PASSPHRASE, STORE_KEY_JWT_SECRET, etc.). Also tighten the unit test assertion from assert_called() to assert call_count matches the number of configured initial apps. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.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
refresh_init_apps()was called on every startup, which would re-install initial apps that a user had previously uninstalled."initial_apps_installed"using the existingget_value/set_valueprimitives indatabase.py.refresh_init_apps()logs and returns early without touching any apps.test_add_init_app(full-env test) to clear the flag before callingrefresh_init_apps()a second time, since the flag is set during lifespan startup.Closes #28
Test plan
test_refresh_init_apps_skipped_if_flag_set— unit test: sets flag, mocksinstall_app_from_store, asserts it is NOT calledtest_refresh_init_apps_installs_on_first_startup— unit test: clears flag, mocksinstall_app_from_store, asserts it IS called and flag is set afterwardstest_add_init_app— full-env integration test: clears flag before second call, confirms new app is installed (requiresTEST_ENV=full)🤖 Generated with Claude Code