Skip to content

feat: add CLI-config state synchronization - #5

Merged
yilu331 merged 2 commits into
mainfrom
feat/cli-config-state-sync
Apr 13, 2026
Merged

feat: add CLI-config state synchronization#5
yilu331 merged 2 commits into
mainfrom
feat/cli-config-state-sync

Conversation

@yilu331

@yilu331 yilu331 commented Apr 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Implement CLI-config state synchronization so that reflexio services start --storage <backend> persists the storage choice to both the config file and .env
  • Add bootstrap_config module with resolve_storage() implementing the priority chain: CLI flag > env var > config file > default
  • Add config local subcommand for offline config inspection without a running server
  • Fix OS port defaults from int = 8081 to int | None = None so env vars (BACKEND_PORT, DOCS_PORT) are properly consulted

Changes

New: reflexio/cli/bootstrap_config.py

  • resolve_storage() — full priority chain resolution
  • save_storage_to_config() — persist storage type to local config file, preserving other fields
  • load_storage_from_config() — read storage type from config file

Modified: reflexio/cli/commands/services.py

  • start() uses resolve_storage() + conditional write-back to config and .env
  • Port defaults changed to int | None for proper env var fallback
  • validate_storage_backend() kept for backwards compat but marked deprecated
  • _VALID_STORAGE_BACKENDS imported from bootstrap_config to avoid duplication

Modified: reflexio/cli/commands/config_cmd.py

  • New config local subcommand showing persisted storage, resolved storage, and mode

New tests

  • tests/cli/test_bootstrap_config.py — 25 tests covering priority chain, round-trip, write-back, layer consistency, container safety
  • tests/cli/test_config_cmd.py — 5 new tests for config local (JSON mode, human-readable, mode mapping)

Test Plan

  • 189 CLI tests pass (pytest tests/cli/ -v)
  • Ruff lint: clean
  • Pyright type check: clean
  • Priority chain verified: flag > env > config > default
  • Write-back verified: explicit --storage updates both .env and config
  • Container safety: graceful fallback when config file doesn't exist

yilu331 added 2 commits April 12, 2026 23:40
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
yilu331 merged commit 495992c into main Apr 13, 2026
@yyiilluu
yyiilluu deleted the feat/cli-config-state-sync branch April 14, 2026 07:20
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.
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