Make your computer a home for your AI partner. Avibe is the local-first Agent OS: Vibey, its built-in AI partner, works out of the box, and Claude Code, Codex & OpenCode run unchanged beside it — reach them from your browser, phone, or any chat app.
Python agentagent-osaiai-agentsai-partnerchatopsclaudeclaude-codecodexdevtoolsdiscord-botlark-botllmlocal-firstlong-term-memoryopencodeslack-botvibe-codingvibeywechat
perf(ci): prepare private schemas for config save tests (#1908)
Call White3619b19d92a6
diff --git a/docs/plans/ci-config-call-preparation.md b/docs/plans/ci-config-call-preparation.mdnew file mode 100644index 000000000..1de1a8a47--- /dev/null+++ b/docs/plans/ci-config-call-preparation.md@@ -0,0 +1,74 @@+# Config Save Test Preparation++## Diagnosis and Scope Decision++This is phase three of the approved order: stability, build/install preparation,+then repeated work inside test calls. PRs #1905 and #1906 are merged and their+exact master sources passed all 17 gates. The latter passed 405 unit files with+one exit and metrics record each, 21 distribution contracts and 196 installer+cases in 375 seconds. No stable whole-workflow speed guarantee follows from it.++The config-save module spent 31.84, 34.64, 33.91 and 39.87 seconds in four green+CI runs, almost entirely in pytest's call phase. A local profile found 41 full+migration calls taking 14.32 of 22.53 seconds, reached through 112 real+ensure_sqlite_state calls. This is repeated preparation inside the business+call, not expensive merge logic. The existing exclusive raw-schema copy factory+can remove that repeated DDL without replacing the business call or importer.++The orchestrator inspected the whole test inventory, save_config, its config+lock, guild-scope persistence, importer and default-Agent consumers. Opt in only+26 ordinary preference, redaction, validation and serialization definitions+(30 expanded cases). Add one explicit raw-schema copy after their existing+per-test home selection. Do not add global autouse behavior, change the AST+opt-in detector, or use the fully imported default template. Bootstrap, legacy+conversion, persisted recovery, session initialization and lock-fresh-base tests+keep their original preparation. All original assertions and business calls+remain unchanged; so do real historical migration and locking suites.++An uncommitted selection probe passed all 96 cases in 6.73 seconds; a following+unmodified run in the same environment passed in 12.49 seconds. An earlier+unmodified sample took 24.52 seconds, so local timings also vary. These probes+justify the scope, not a claimed CI speedup.++## Contract++Each copied database starts with only the real migration schema, no importer or+default-Agent state. It is a closed, checkpointed, exclusive file under that+test's private home. Existing factory contracts compare the entire schema,+rows, persisted pragmas, integrity and independent mutations, and reject+overwrites or out-of-home paths.++A new fresh-versus-prepared config-save contract observes and delegates to the+original importer write boundary. Both paths must perform the real import,+persist guild scopes, create every enabled default Agent and retain those+results across a partial save. It also asserts the module still does not opt+into the global imported-template fixture. No production methods are replaced+by fake results. No dependency, timeout, workflow, runner or selection changes.++## Verification and Gates++Run all config-save cases normally, compare all original AST bodies and+assertions after removing only explicit fixture plumbing, and run factory,+workflow, shard, settings, Agent and real-migration consumers in separate Python+processes. Require lint and dependency consistency, full exact-head bot review,+all 17 checks in every exact-head lint run, zero whole-PR unresolved threads and+clean scope/integration before guarded squash. Verify merged-source CI again.+Keep all existing durable delivery watches through the final ordered outcome.++Initial findings-bearing review-head inventory is zero. No new identifiers or+cross-lane contracts are allocated. Actual CI phase and write-volume comparisons+must use complete first-attempt green logs; no speculative shard rebalance.++Local final code passed all 98 config cases (16.10 seconds in its fresh private+environment), plus 233 separately run fixture, workflow, shard, real-migration,+settings and default-Agent consumer cases. All 72 original definitions and 251+assertions are AST-identical after normalizing only explicit preparation calls+and fixture parameters. Ruff 0.4.9, all 84 installed package requirements and+whitespace checks pass. The earlier probe timing is not the final suite timing.++Before the first push, master advanced through #1907 (b930160ed), which changes+Model Hub routing UI only. Its drawer and consuming tests were inspected; no+overlap exists with this two-file scope, database initialization or identifiers.+Integrate that source before opening this independent PR and require its full CI.+After that fast-forward, all 98 config cases passed again in 6.95 seconds;+the original-body AST comparison, lint and whitespace checks remained green.diff --git a/tests/test_api_save_config_merge.py b/tests/test_api_save_config_merge.pyindex 57c653cb1..cfedb70e8 100644--- a/tests/test_api_save_config_merge.py+++ b/tests/test_api_save_config_merge.py@@ -4,7 +4,9 @@ import astimport copyimport jsonimport re+import sqlite3import sys+from contextlib import closingfrom dataclasses import fieldsfrom pathlib import Path@@ -100,8 +102,63 @@ def _full_config_payload() -> dict:}-def test_save_config_merges_partial_payload(monkeypatch, tmp_path):[email protected]("prepared", [False, True])+def test_config_save_initializes_real_state_with_or_without_schema_preparation(+ monkeypatch, tmp_path, sqlite_schema_db_factory, prepared,+):+ from storage import importer+ from tests.conftest import _is_default_sqlite_call++ tree = ast.parse(Path(__file__).read_text(encoding="utf-8"))+ assert not any(_is_default_sqlite_call(node) for node in ast.walk(tree) if isinstance(node, ast.Call))+ monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ db_path = tmp_path / "state" / "vibe.sqlite"+ assert not db_path.exists()+ if prepared:+ sqlite_schema_db_factory(db_path)+ with closing(sqlite3.connect(db_path)) as connection:+ assert connection.execute("SELECT COUNT(*) FROM agents").fetchone() == (0,)+ markers = {row[0] for row in connection.execute("SELECT key FROM state_meta")}+ assert importer.JSON_IMPORT_MARKER not in markers+ assert importer.BACKGROUND_IMPORT_MARKER not in markers++ imported_paths = []+ original_write = importer._write_parsed_state++ def observe_import(target_db, parsed):+ imported_paths.append(target_db)+ return original_write(target_db, parsed)++ monkeypatch.setattr(importer, "_write_parsed_state", observe_import)+ created = api.save_config(_full_config_payload())+ updated = api.save_config({"show_duration": False})+ assert created.show_duration is True+ assert updated.show_duration is False+ assert imported_paths == [db_path.resolve()]+ with closing(sqlite3.connect(db_path)) as connection:+ markers = {row[0] for row in connection.execute("SELECT key FROM state_meta")}+ assert {importer.JSON_IMPORT_MARKER, importer.BACKGROUND_IMPORT_MARKER} <= markers+ assert connection.execute("PRAGMA integrity_check").fetchone() == ("ok",)+ store = api.VibeAgentStore()+ try:+ enabled = {+ backend for backend, options in _full_config_payload()["agents"].items()+ if isinstance(options, dict) and options.get("enabled")+ }+ assert {agent.backend for agent in store.list_agents() if agent.enabled} == enabled+ assert store.get_default_agent_name() in {agent.name for agent in store.list_agents()}+ finally:+ store.close()+ settings = api.SettingsStore.get_instance()+ assert settings.has_guild_scope_for_platform("discord")+ assert set(settings.get_guilds_for_platform("discord")) == set(+ _full_config_payload()["discord"]["guild_allowlist"]+ )+++def test_save_config_merges_partial_payload(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")original = api.save_config(_full_config_payload())assert original.show_duration is True@@ -196,8 +253,9 @@ def test_save_config_defaults_include_time_info_to_true_for_new_config(monkeypatassert created.include_time_info is True-def test_save_config_accepts_typing_ack_mode(monkeypatch, tmp_path):+def test_save_config_accepts_typing_ack_mode(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")updated = api.save_config({**_full_config_payload(), "ack_mode": "typing"})@@ -251,8 +309,10 @@ def test_remote_access_legacy_config_keeps_cloudflared_ipv4_default() -> None:def test_save_config_rejects_unassigned_remote_access_bind_address(monkeypatch,tmp_path,+ sqlite_schema_db_factory,) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())monkeypatch.setattr(remote_access,@@ -288,8 +348,10 @@ def test_save_config_rejects_unassigned_remote_access_bind_address(def test_save_config_rejects_remote_access_bind_family_mismatch(monkeypatch,tmp_path,+ sqlite_schema_db_factory,) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())monkeypatch.setattr(remote_access,@@ -327,8 +389,10 @@ def test_save_config_rejects_remote_access_bind_family_mismatch(def test_generic_config_save_rejects_connector_control_changes(monkeypatch,tmp_path,+ sqlite_schema_db_factory,) -> None:monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())with pytest.raises(ValueError, match="/api/remote-access/settings"):@@ -408,8 +472,9 @@ def test_generic_policy_save_does_not_validate_an_unchanged_stale_bind_address(assert updated.remote_access.vibe_cloud.auto_recovery is False-def test_save_config_merges_audio_asr_settings(monkeypatch, tmp_path):+def test_save_config_merges_audio_asr_settings(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")created = api.save_config(_full_config_payload())assert created.audio_asr.enabled is True@@ -428,8 +493,9 @@ def test_save_config_merges_audio_asr_settings(monkeypatch, tmp_path):assert payload["audio_asr"]["echo_transcript"] is False-def test_save_config_marks_explicit_audio_asr_disable_patch(monkeypatch, tmp_path):+def test_save_config_marks_explicit_audio_asr_disable_patch(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())@@ -495,8 +561,9 @@ def test_config_payload_default_instance_name_ignores_malformed_remote_url(monkeassert payload["ui"]["default_instance_name"] == "macbook"-def test_save_config_preserves_show_pages_prompt_toggle(monkeypatch, tmp_path):+def test_save_config_preserves_show_pages_prompt_toggle(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")created = api.save_config(_full_config_payload())assert created.show_pages_prompt is True@@ -508,12 +575,13 @@ def test_save_config_preserves_show_pages_prompt_toggle(monkeypatch, tmp_path):assert payload["show_pages_prompt"] is False-def test_save_config_preserves_status_bubble_settings_on_partial_save(monkeypatch, tmp_path):+def test_save_config_preserves_status_bubble_settings_on_partial_save(monkeypatch, tmp_path, sqlite_schema_db_factory):"""An unrelated partial save must NOT reset agent_progress_style / intervals.Regression for the config_to_payload omission that wiped these on any UI save."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")full = _full_config_payload()full["agent_progress_style"] = "verbose"@@ -532,7 +600,7 @@ def test_save_config_preserves_status_bubble_settings_on_partial_save(monkeypatcassert payload["agent_status_heartbeat_ms"] == 12000-def test_save_config_preserves_harness_runtime_knobs_on_partial_save(monkeypatch, tmp_path):+def test_save_config_preserves_harness_runtime_knobs_on_partial_save(monkeypatch, tmp_path, sqlite_schema_db_factory):"""The config-only Harness knobs must survive an unrelated UI save (Codex P1).``config_to_payload`` is the deep-merge base for every ``/api/config`` save, so a@@ -542,6 +610,7 @@ def test_save_config_preserves_harness_runtime_knobs_on_partial_save(monkeypatchstatus-bubble regression above."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")full = _full_config_payload()full["runtime"]["harness_prompt_echo"] = False@@ -562,8 +631,10 @@ def test_save_config_preserves_harness_runtime_knobs_on_partial_save(monkeypatchdef test_show_page_api_timeout_defaults_round_trips_and_survives_partial_save(monkeypatch,tmp_path,+ sqlite_schema_db_factory,):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")defaulted = V2Config.from_payload(_full_config_payload())assert defaulted.runtime.show_page_api_timeout_seconds == 90.0@@ -610,8 +681,9 @@ def test_config_load_preserves_pre_upgrade_audio_asr_false_as_opt_out():assert created.audio_asr.enabled_configured is True-def test_save_config_preserves_explicit_audio_asr_opt_out(monkeypatch, tmp_path):+def test_save_config_preserves_explicit_audio_asr_opt_out(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")payload = _full_config_payload()payload["audio_asr"] = {@@ -626,8 +698,9 @@ def test_save_config_preserves_explicit_audio_asr_opt_out(monkeypatch, tmp_path)assert created.audio_asr.enabled_configured is True-def test_config_to_payload_redacts_remote_access_secrets_and_save_preserves_them(monkeypatch, tmp_path):+def test_config_to_payload_redacts_remote_access_secrets_and_save_preserves_them(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")payload = _full_config_payload()payload["remote_access"] = {"provider": "vibe_cloud",@@ -661,8 +734,9 @@ def test_config_to_payload_redacts_remote_access_secrets_and_save_preserves_themassert updated.remote_access.vibe_cloud.session_secret == "session-secret"-def test_config_to_payload_redacts_platform_and_gateway_secrets_and_save_preserves_them(monkeypatch, tmp_path):+def test_config_to_payload_redacts_platform_and_gateway_secrets_and_save_preserves_them(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")payload = _full_config_payload()payload["slack"] = {**payload["slack"],@@ -742,8 +816,9 @@ def test_config_to_payload_redacts_platform_and_gateway_secrets_and_save_preservassert updated.gateway.client_secret == "client-secret"-def test_save_config_accepts_slack_disable_link_unfurl(monkeypatch, tmp_path):+def test_save_config_accepts_slack_disable_link_unfurl(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")payload = _full_config_payload()payload["slack"]["disable_link_unfurl"] = True@@ -753,8 +828,9 @@ def test_save_config_accepts_slack_disable_link_unfurl(monkeypatch, tmp_path):assert updated.slack.disable_link_unfurl is True-def test_save_config_preserves_platforms_metadata(monkeypatch, tmp_path):+def test_save_config_preserves_platforms_metadata(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")payload = _full_config_payload()payload["slack"]["bot_token"] = "xoxb-valid-token"@@ -789,8 +865,9 @@ def test_save_config_migrates_legacy_single_platform(monkeypatch, tmp_path):assert payload["platforms"] == {"enabled": ["discord"], "primary": "discord"}-def test_save_config_rejects_enabled_platform_without_config(monkeypatch, tmp_path):+def test_save_config_rejects_enabled_platform_without_config(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")import pytest@@ -931,8 +1008,9 @@ def test_save_config_allows_redacted_lark_round_trip_for_legacy_missing_secret(m)-def test_save_config_preserves_disabled_platform_credentials(monkeypatch, tmp_path):+def test_save_config_preserves_disabled_platform_credentials(monkeypatch, tmp_path, sqlite_schema_db_factory):monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")payload = _full_config_payload()payload["platform"] = "avibe"@@ -1095,11 +1173,12 @@ def test_config_to_payload_includes_avault_agent():assert payload["agents"]["avault"]["cli_path"] == "/opt/managed/avault"-def test_save_config_preserves_avault_cli_path_on_unrelated_partial_save(monkeypatch, tmp_path):+def test_save_config_preserves_avault_cli_path_on_unrelated_partial_save(monkeypatch, tmp_path, sqlite_schema_db_factory):"""A partial UI save (e.g. toggling ``show_duration``) must NOT reset apreviously-persisted ``agents.avault.cli_path`` (set by ``vibe runtimeprepare`` -> ``_persist_avault_cli_path``)."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")full = _full_config_payload()full["agents"]["avault"] = {"cli_path": "/opt/managed/avault"}@@ -1112,11 +1191,12 @@ def test_save_config_preserves_avault_cli_path_on_unrelated_partial_save(monkeypassert api.config_to_payload(updated)["agents"]["avault"]["cli_path"] == "/opt/managed/avault"-def test_save_config_preserves_ui_fields_on_unrelated_partial_save(monkeypatch, tmp_path):+def test_save_config_preserves_ui_fields_on_unrelated_partial_save(monkeypatch, tmp_path, sqlite_schema_db_factory):"""The owner-facing scenario: after enabling ``show_agent_activity`` (and acustom font size / instance name), an unrelated partial save must keep them.Guards the ``ui`` sub-block of the deep-merge base."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")full = _full_config_payload()full["ui"] = {@@ -1135,13 +1215,14 @@ def test_save_config_preserves_ui_fields_on_unrelated_partial_save(monkeypatch,assert updated.ui.instance_name == "OwnerBox"-def test_full_config_serializers_cover_every_config_field(monkeypatch, tmp_path):+def test_full_config_serializers_cover_every_config_field(monkeypatch, tmp_path, sqlite_schema_db_factory):"""Mechanism guard for the whole class: both full-config serializers(``V2Config.save`` on disk and ``config_to_payload``, the save merge base)must emit every persisted field — top-level, every ``UiConfig`` sub-field,and every agent backend. A newly-added field hand-listed into only oneserializer (or neither) fails here, so it cannot silently drop on save."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")config = api.save_config(_full_config_payload())@@ -1170,12 +1251,13 @@ def test_full_config_serializers_cover_every_config_field(monkeypatch, tmp_path)_assert_complete("V2Config.save", json.loads(paths.get_config_path().read_text(encoding="utf-8")))-def test_save_config_strips_codex_relay_marker_from_generic_patch(monkeypatch, tmp_path):+def test_save_config_strips_codex_relay_marker_from_generic_patch(monkeypatch, tmp_path, sqlite_schema_db_factory):"""The relay marker is auth-owned state like ``api_key``: a genericSettings save that round-trips a stale full-config snapshot (loadedbefore an OAuth transition captured the marker) must not null thefresh marker."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")original = api.save_config(_full_config_payload())original.agents.codex.oauth_relay_marker = {@@ -1375,7 +1457,7 @@ def _walk(root: object, path: tuple[str, ...], *, attr: bool) -> object:def test_wrong_typed_settings_writes_are_refused_instead_of_silently_defaulted(- tmp_path, monkeypatch+ tmp_path, monkeypatch, sqlite_schema_db_factory,):"""``/api/config`` stores what the caller sent, or it refuses the write.@@ -1392,6 +1474,7 @@ def test_wrong_typed_settings_writes_are_refused_instead_of_silently_defaulted(answers alike."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())def _stored() -> dict:@@ -1822,11 +1905,12 @@ def test_save_config_list_ops_merge_against_lock_fresh_base(monkeypatch, tmp_patassert "lark" in updated.platforms.enabled-def test_list_ops_enable_requires_credentials(monkeypatch, tmp_path):+def test_list_ops_enable_requires_credentials(monkeypatch, tmp_path, sqlite_schema_db_factory):"""List-op additions are validated like explicit list saves: enablinga platform without credentials through the verb is rejected (#1458stage ③ list semantics)."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())import pytest@@ -1835,11 +1919,12 @@ def test_list_ops_enable_requires_credentials(monkeypatch, tmp_path):api.save_config({"__avibe_list_ops": {"platforms.enabled": {"add": ["lark"]}}})-def test_list_ops_reject_unwhitelisted_paths(monkeypatch, tmp_path):+def test_list_ops_reject_unwhitelisted_paths(monkeypatch, tmp_path, sqlite_schema_db_factory):"""Only whitelisted list paths accept operations — arbitrary dottedpaths (e.g. model_hub.sources, which must go through ModelHubService)are rejected instead of silently mutating the persisted base."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())import pytest@@ -1860,9 +1945,10 @@ def test_list_ops_reject_unwhitelisted_paths(monkeypatch, tmp_path):{"add": ["discord"], "replace": ["slack"]},],)-def test_list_ops_reject_malformed_operands(monkeypatch, tmp_path, operations):+def test_list_ops_reject_malformed_operands(monkeypatch, tmp_path, operations, sqlite_schema_db_factory):"""Malformed list operations are client errors, never a server 500."""monkeypatch.setenv("AVIBE_HOME", str(tmp_path))+ sqlite_schema_db_factory(tmp_path / "state" / "vibe.sqlite")api.save_config(_full_config_payload())with pytest.raises(ValueError, match="Config list operation"):