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): reuse private schemas for media and nested stores (#1912)
Call Whitee72b9870a0aa
diff --git a/docs/plans/ci-media-store-preparation.md b/docs/plans/ci-media-store-preparation.mdnew file mode 100644index 000000000..03912448c--- /dev/null+++ b/docs/plans/ci-media-store-preparation.md@@ -0,0 +1,87 @@+# CI Media and Nested Store Preparation++## Scope and Evidence++This is the second phase after wait attribution (#1909) and the independent+atomic Memory repair (#1910). It changes only explicit preparation in+`tests/test_workbench_media.py` and `tests/test_harness_failure_visibility.py`.+No application, workflow, dependency, timeout, runner, shard, or selection change.++The media profile passed 28 cases: 25 migration calls from 18 source callsites+took 8.302 seconds of 19.127 profiled seconds. The current unprofiled local+baseline passed in 7.21 seconds, demonstrating why profile and wall timings+cannot be compared as a speedup. The complete green master run 34017192558+took 408 seconds; media consumed 19.91 seconds, 17.30 CPU seconds, and 174 MB+of Linux write bytes.++The malformed-metadata Harness writer test initializes seven nested stores+outside its existing fixed-path fixture. A three-test profile attributed 2.728+seconds to eight migrations. The unmodified full module passed 225 cases in+18.51 seconds locally; the nested test's call took 1.63 seconds. Existing+query-history batching is not changed.++## Invariants++- Use the existing lazy, closed/checkpointed raw migration schema through+ `sqlite_schema_db_factory`. Each test or nested writer owns an exclusive+ private copy; no imported JSON state or default Agent markers are preseeded.+- All original media registration, HTTP download, legacy filename/row,+ authorization, rewrite, and failure assertions remain. These cases test+ legacy media data behavior, not historical schema upgrades.+- Every nested Harness store still calls its real constructor and original+ serializers, claims, terminal writers, and raw metadata reads. Only empty+ database preparation moves before construction.+- The factory's existing whole-schema, all-row, pragma, integrity, mutation+ isolation, no-overwrite, and path-boundary contracts remain the proof of+ equivalent preparation. Historical migrations and importer/locking tests+ retain their real paths. Global autouse selection is unchanged.+- Keep one Python process per file, the 300-second visible-stack watchdog,+ the 20-minute outer bound, all 17 CI checks, and fail-closed aggregates.++## Installation-Chain Review++The remaining chain has independent value. In run 34013888907 the existing+installer job took 216 seconds: distribution contracts consumed 99.17 seconds+and installation/upgrade cases 97.15 seconds. Fresh Docker installation and+released-wheel upgrade took 37.17 and 44.03 seconds. The distribution suite's+six private virtual environments verify actual wheel/sdist installation,+dependency resolution, exact peer versions, and core-only isolation.++The producer already uses a minimal isolated builder. Reusing mutable installed+environments or bypassing dependencies would remove the behavior these tests+exercise. No further installation-chain patch is selected without an independently+measured, contract-preserving benefit. After the repair, master run 34017192558+spent 70 seconds producing artifacts and 315 seconds from producer start through+the installation aggregate. Distribution and installation tests took 99.68 and+109.23 seconds, respectively; the Python tail, not installation, set the 408-second+workflow duration. The orchestrator's phase-three decision is no further+installation change: retain the independently valuable isolation and real upgrade+coverage. Recheck final successful PR/master timestamps before delivery. Keep six+shards unchanged.++## Validation++All 460 local cases passed in separate file processes: media 28, Harness 225,+private-fixture contracts 12, workflow 60, shard 6, and real migrations 129.+The initial media run took 10.86 seconds, including 8.88 seconds in the first+UI-module-consuming call on the fresh environment; no wall-time improvement is+claimed from that comparison. A subsequent read-only profile passed all 28 cases+in 2.55 seconds and recorded exactly one raw migration (0.359 seconds), rather+than 25. This verifies removed repeated work, not a hosted-CI speedup.+Harness passed in 17.25 seconds versus the 18.51-second local baseline.++AST comparison retained all 291 original definitions and 1,227 assertions after+normalizing only the 19 explicit fixture signatures/preparation sites. Ruff 0.4.9,+dependency consistency (84 packages), and whitespace checks passed. Initial+editable dependency bootstrap began before the ignored UI placeholder existed;+after creating that existing workflow prerequisite, installation succeeded.+No production UI or environment was changed.++Before the first PR push, latest master #1911 (073d277fe) was inspected and+integrated. Its Model Hub route normalization and config consumers do not overlap+this scope. All 420 post-integration cases passed in separate file processes:+media 28, Harness 225, Model Hub config 155, and private-fixture contracts 12.+Require current-head bot PASS,+complete review/thread inventory, every exact-head lint run successful, and+post-merge source CI. Compare complete first-attempt green file metrics; failed+runs and local profile values are not CI performance samples.diff --git a/tests/test_harness_failure_visibility.py b/tests/test_harness_failure_visibility.pyindex 28f52dc92..3d93a1602 100644--- a/tests/test_harness_failure_visibility.py+++ b/tests/test_harness_failure_visibility.py@@ -1627,7 +1627,7 @@ def _write_raw_metadata_json(sqlite: SQLiteBackgroundTaskStore, run_id: str, bloassert _raw_metadata_json(sqlite, run_id) == blob, "the fixture blob must survive the write"-def test_a_terminal_writer_never_rewrites_unparseable_metadata(tmp_path: Path) -> None:+def test_a_terminal_writer_never_rewrites_unparseable_metadata(tmp_path: Path, sqlite_schema_db_factory) -> None:"""Subordinate to HFR-084/HFR-072 — malformed metadata is READ-ONLY to the stamp.``_merge_owed_failure_notice`` decoded the column with ``_json_loads(..., {})``@@ -1658,6 +1658,7 @@ def test_a_terminal_writer_never_rewrites_unparseable_metadata(tmp_path: Path) -# exercised on one writer; the truncated blob is exercised on all four.if blob != "{broken" and writer != "record_run_output":continue+ sqlite_schema_db_factory(tmp_path / f"{writer}-{blobs.index(blob)}" / "state" / "vibe.sqlite")sqlite, requests = _store(tmp_path / f"{writer}-{blobs.index(blob)}")if writer == "coalesced":run = requests.enqueue_agent_run(diff --git a/tests/test_workbench_media.py b/tests/test_workbench_media.pyindex 98730206e..219cf7a61 100644--- a/tests/test_workbench_media.py+++ b/tests/test_workbench_media.py@@ -20,7 +20,6 @@ from sqlalchemy import selectfrom core.workbench_media import MAX_WORKBENCH_ATTACHMENT_BYTES, rewrite_agent_mediafrom storage import media_service, settings_servicefrom storage.db import create_sqlite_engine-from storage.migrations import run_migrationsfrom storage.models import agent_sessions, media_object_references, media_objects@@ -75,9 +74,9 @@ def _seed_scope_and_session(conn) -> str:return scope_id-def test_register_and_get_by_token(tmp_path):+def test_register_and_get_by_token(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)shot = tmp_path / "shot.png"@@ -110,9 +109,9 @@ def test_register_and_get_by_token(tmp_path):assert row["session_id"] == "sess_x"-def test_rewrite_in_place_image_file_and_external(tmp_path):+def test_rewrite_in_place_image_file_and_external(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)img = tmp_path / "a.png"@@ -144,13 +143,15 @@ def test_rewrite_in_place_image_file_and_external(tmp_path):@pytest.mark.parametrize("legacy", [False, True], ids=["new", "existing"])@pytest.mark.parametrize("filename", ["report.pdf", "报告 (最终).docx", "data.v2.tar.gz", "README"])-def test_agent_download_and_metadata_preserve_real_filename(tmp_path, monkeypatch, filename, legacy):+def test_agent_download_and_metadata_preserve_real_filename(+ tmp_path, monkeypatch, filename, legacy, sqlite_schema_db_factory,+):from tests.ui_server_test_helpers import _save_configfrom vibe import ui_server_save_config(tmp_path)db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)monkeypatch.setattr(ui_server, "_projects_engine", lambda: engine)document = tmp_path / filename@@ -190,13 +191,13 @@ def test_agent_download_and_metadata_preserve_real_filename(tmp_path, monkeypatcengine.dispose()-def test_uploaded_download_keeps_original_name_instead_of_storage_basename(tmp_path, monkeypatch):+def test_uploaded_download_keeps_original_name_instead_of_storage_basename(tmp_path, monkeypatch, sqlite_schema_db_factory):from tests.ui_server_test_helpers import _save_configfrom vibe import ui_server_save_config(tmp_path)db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)monkeypatch.setattr(ui_server, "_projects_engine", lambda: engine)document = tmp_path / "random-upload-id_report.docx"@@ -218,9 +219,9 @@ def test_uploaded_download_keeps_original_name_instead_of_storage_basename(tmp_pengine.dispose()-def test_rewrite_angle_wrapped_file_links(tmp_path):+def test_rewrite_angle_wrapped_file_links(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)image = tmp_path / "图片 文件.png"@@ -245,9 +246,9 @@ def test_rewrite_angle_wrapped_file_links(tmp_path):assert sorted(row["kind"] for row in rows) == ["file", "image"]-def test_rewrite_legacy_bare_space_link_and_reject_malformed_authority(tmp_path):+def test_rewrite_legacy_bare_space_link_and_reject_malformed_authority(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)report = tmp_path / "My Report.md"report.write_text("report", encoding="utf-8")@@ -270,9 +271,9 @@ def test_rewrite_legacy_bare_space_link_and_reject_malformed_authority(tmp_path)assert [row["local_path"] for row in rows] == [str(report.resolve())]-def test_rewrite_legacy_bare_space_link_after_malformed_prefix(tmp_path):+def test_rewrite_legacy_bare_space_link_after_malformed_prefix(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)report = tmp_path / "Good Report.md"report.write_text("report", encoding="utf-8")@@ -294,9 +295,9 @@ def test_rewrite_legacy_bare_space_link_after_malformed_prefix(tmp_path):assert [row["local_path"] for row in rows] == [str(report.resolve())]-def test_rewrite_does_not_materialize_file_links_inside_code(tmp_path):+def test_rewrite_does_not_materialize_file_links_inside_code(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)image = tmp_path / "code.png"image.write_bytes(b"image")@@ -311,9 +312,9 @@ def test_rewrite_does_not_materialize_file_links_inside_code(tmp_path):assert conn.execute(select(media_objects)).first() is None-def test_resolve_attachment_specs(tmp_path):+def test_resolve_attachment_specs(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)doc = tmp_path / "doc.pdf"doc.write_bytes(b"%PDF-1.4 hello")@@ -362,9 +363,9 @@ def test_message_context_accepts_files():assert ctx.files and ctx.files[0].local_path == "/tmp/a.png"-def test_rewrite_noop_without_file_links(tmp_path):+def test_rewrite_noop_without_file_links(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)text = "Plain reply with a [link](https://example.com) and no files."with engine.begin() as conn:@@ -394,9 +395,9 @@ def test_process_reply_keep_file_links():assert len(kept.files) == 2-def test_rewrite_allows_any_absolute_path(tmp_path):+def test_rewrite_allows_any_absolute_path(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)from core.workbench_media import rewrite_agent_media@@ -418,9 +419,9 @@ def test_rewrite_allows_any_absolute_path(tmp_path):assert rows[0]["local_path"] == str(outside.resolve())-def test_register_dedups_same_fingerprint(tmp_path):+def test_register_dedups_same_fingerprint(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)shot = tmp_path / "shot.png"@@ -477,9 +478,9 @@ def test_register_dedups_same_fingerprint(tmp_path):}-def test_register_reads_image_dimensions(tmp_path):+def test_register_reads_image_dimensions(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)img = tmp_path / "wide.png"@@ -508,11 +509,11 @@ def test_register_reads_image_dimensions(tmp_path):assert doc_row["width_px"] is None and doc_row["height_px"] is None-def test_register_image_dimensions_unreadable_is_null(tmp_path):+def test_register_image_dimensions_unreadable_is_null(tmp_path, sqlite_schema_db_factory):# A file flagged as an image but not actually decodable must not break# registration — dimensions degrade to NULL (UI measures it in the browser).db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)bogus = tmp_path / "broken.png"@@ -530,9 +531,9 @@ def test_register_image_dimensions_unreadable_is_null(tmp_path):assert row["width_px"] is None and row["height_px"] is None-def test_rewrite_appends_image_dimensions(tmp_path):+def test_rewrite_appends_image_dimensions(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)img = tmp_path / "chart.png"@@ -552,9 +553,9 @@ def test_rewrite_appends_image_dimensions(tmp_path):assert "?w=" not in out.split(" and ")[1]-def test_rewrite_angle_file_link_unescapes_path_and_ignores_title(tmp_path):+def test_rewrite_angle_file_link_unescapes_path_and_ignores_title(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)report = tmp_path / "report (final).md"report.write_text("report", encoding="utf-8")@@ -569,9 +570,9 @@ def test_rewrite_angle_file_link_unescapes_path_and_ignores_title(tmp_path):assert out.endswith('> "download")')-def test_rewrite_commonmark_owned_destination_preserves_source_syntax(tmp_path):+def test_rewrite_commonmark_owned_destination_preserves_source_syntax(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)report = tmp_path / "report & (final).md"report.write_text("report", encoding="utf-8")@@ -597,9 +598,9 @@ def test_rewrite_commonmark_owned_destination_preserves_source_syntax(tmp_path):assert [row["local_path"] for row in rows] == [str(report.resolve())]-def test_rewrite_failure_preserves_original_destination_source(tmp_path):+def test_rewrite_failure_preserves_original_destination_source(tmp_path, sqlite_schema_db_factory):db = tmp_path / "vibe.sqlite"- run_migrations(db)+ sqlite_schema_db_factory(db)engine = create_sqlite_engine(db)text = '[report](<file:///tmp/a&b.md> "download")'