Skip to content

Guard refresh_init_apps() to only run on first startup#32

Merged
max-tet merged 2 commits intomainfrom
issue/28-initial-apps-first-startup-only
Feb 24, 2026
Merged

Guard refresh_init_apps() to only run on first startup#32
max-tet merged 2 commits intomainfrom
issue/28-initial-apps-first-startup-only

Conversation

@max-tet
Copy link
Member

@max-tet max-tet commented Feb 24, 2026

Summary

  • refresh_init_apps() was called on every startup, which would re-install initial apps that a user had previously uninstalled.
  • Added a persistent DB flag "initial_apps_installed" using the existing get_value/set_value primitives in database.py.
  • On first startup the flag is absent, so initial apps are installed normally and the flag is written afterwards.
  • On subsequent startups the flag is present, so refresh_init_apps() logs and returns early without touching any apps.
  • Updated test_add_init_app (full-env test) to clear the flag before calling refresh_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, mocks install_app_from_store, asserts it is NOT called
  • test_refresh_init_apps_installs_on_first_startup — unit test: clears flag, mocks install_app_from_store, asserts it IS called and flag is set afterwards
  • test_add_init_app — full-env integration test: clears flag before second call, confirms new app is installed (requires TEST_ENV=full)

🤖 Generated with Claude Code

max-tet and others added 2 commits February 24, 2026 12:01
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>
@max-tet max-tet merged commit c63ea12 into main Feb 24, 2026
6 checks passed
@max-tet max-tet deleted the issue/28-initial-apps-first-startup-only branch February 24, 2026 12:03
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.

Default apps from config are installed after shard_core update

1 participant