feat: add CLI-config state synchronization - #5
Merged
Conversation
Implement priority chain (CLI flag > env var > config file > default) for storage backend resolution. CLI services start now persists resolved storage to both config file and .env when explicitly passed via --storage flag. - Add bootstrap_config module with resolve_storage(), save/load functions - Fix OS port defaults to int | None for proper env var fallback - Add config local subcommand for offline config inspection - Add 25 tests covering priority chain, write-back, and container safety
- Gate save_storage_to_config behind explicit --storage flag only (F001) - Warn when supabase requested without credentials (F002) - Add default case to match statement in save_storage_to_config (F003) - Add tests for config local command (F004) - Use _config_dir/_DEFAULT_ORG_ID in show_local instead of hardcoded path (F005) - Deduplicate _VALID_STORAGE_BACKENDS by importing from bootstrap_config (F006) - Fix misleading test name test_env_file_not_created_if_missing (F007)
yilu331
added a commit
that referenced
this pull request
Jun 24, 2026
…_data #4 (CRITICAL): remove AND content != '' guard from _PURGE_SQL — rows with content='' but other PII (user_id, embedding, tags) populated were skipped entirely, leaving PII intact and no purge event recorded. Idempotency of the event is guaranteed by INSERT OR IGNORE on the deterministic request_id key. #1: replace inline IN-placeholder SQL in clear_user_data Phase 3 + Phase 4 with _delete_in_chunks() calls to stay under SQLite SQLITE_MAX_VARIABLE_NUMBER on large user datasets. #2: call _delete_source_windows_for_user_playbook_ids before hard-deleting user_playbooks in Phase 4 — without this the agent_playbook_source_user_playbooks join table accumulated orphan rows. #3: wrap Phase 5 purge loop in with self._lock — self._lock is an RLock so purge_content's internal re-acquire is safe; Phase 4 commit already closed the outer transaction so no flush hazard exists. #5: update abstract + concrete purge_content docstrings to explicitly state only 'profile'/'user_playbook' are supported; 'agent_playbook' raises ValueError. #6: drop conditional escape hatch in test_clear_user_data_tombstone_only_user — scenario is deterministic (tombstone → purge set), assert unconditionally. #7: add is_purged assertion to cross-user-chain test. New tests: test_purge_with_empty_content_still_blanks_other_pii and test_purge_idempotent_on_already_purged_row covering the #4 invariant.
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
reflexio services start --storage <backend>persists the storage choice to both the config file and.envbootstrap_configmodule withresolve_storage()implementing the priority chain: CLI flag > env var > config file > defaultconfig localsubcommand for offline config inspection without a running serverint = 8081toint | None = Noneso env vars (BACKEND_PORT,DOCS_PORT) are properly consultedChanges
New:
reflexio/cli/bootstrap_config.pyresolve_storage()— full priority chain resolutionsave_storage_to_config()— persist storage type to local config file, preserving other fieldsload_storage_from_config()— read storage type from config fileModified:
reflexio/cli/commands/services.pystart()usesresolve_storage()+ conditional write-back to config and.envint | Nonefor proper env var fallbackvalidate_storage_backend()kept for backwards compat but marked deprecated_VALID_STORAGE_BACKENDSimported frombootstrap_configto avoid duplicationModified:
reflexio/cli/commands/config_cmd.pyconfig localsubcommand showing persisted storage, resolved storage, and modeNew tests
tests/cli/test_bootstrap_config.py— 25 tests covering priority chain, round-trip, write-back, layer consistency, container safetytests/cli/test_config_cmd.py— 5 new tests forconfig local(JSON mode, human-readable, mode mapping)Test Plan
pytest tests/cli/ -v)--storageupdates both.envand config