Isolate semantic-runtime tests from bridge storage overrides

Merged
AF
2d ago
+285-37

Test-only, plus one ignored reproduction.

  • Cause of the 18-vs-9 failure: views_on_worktrees_and_sessions_embed_each_chunk_once re-embedded every chunk in its second session. Configure gives the process-wide AFT_STORAGE_DIR priority over the request's storage_dir. The bridge tests set that variable under a bridge-only mutex, so a semantic-runtime test could configure its first session into a different storage root. The failure reproduces exactly when storage is switched between sessions.
  • Fix: bridge env guards now take the shared process-settings lock and restore the value before releasing it. Semantic-runtime fixtures clear inherited overrides under that lock and assert the resolved storage on every configure. storage_override_holds_shared_process_settings_guard checks from a sibling thread that the lock is held. It failed before the fix.
  • Separate gap, not fixed here: views_on_two_processes_reproduce_duplicate_checkout_chunk (ignored) shows that two standalone aft processes sharing one storage both embed an identical checkout-own chunk, because file claims and the batch gate are in-process only. It needs a reviewed cross-process design before views can become the default.

Verified: per_checkout_semantic_runtime plus the guard test, twice on Linux (9 passed, 1 ignored), the formatting check and the Windows target check.


Summary by cubic

Fixes a test isolation bug where bridge tests' AFT_STORAGE_DIR override leaked into semantic-runtime tests, causing a session to re-embed all chunks (18 instead of 9).

  • Bridge env guards now hold the shared process-settings lock and restore the env var before releasing it; they skip acquisition while a bridge runner owns the lock to avoid deadlocking the runner. Feature-gated bridge env helpers now use this same setter.
  • Semantic-runtime fixtures clear inherited overrides under the same lock and assert resolved storage on every configure.
  • Adds an ignored reproduction showing two standalone aft processes sharing one storage both embed an identical chunk; a cross-process claim design needs review before fixing.