Repository navigation
Conversation
…cache EXPERIMENT_LAYER_MAPPINGS is a process-global DashMap populated by experiments::init, which several test helpers call (including the shared test_util::terminal). It's never cleared, so this test sees more than its own two test experiments once other tests have run first in the same process -- masked by nextest's per-test process isolation, but real under plain `cargo test`. Clear the map before asserting, and run #[serial] so a concurrently running experiments::init can't repopulate it mid-test. Part of warpdotdev#13974.
… global queue The telemetry event queue (warpui::telemetry, a 1024-cap BoundedVecDeque behind a global Mutex) is process-global and append-only. Any prior test that emits telemetry (e.g. ExperimentTriggered, itself a symptom of the experiments-layer leak fixed alongside this commit) leaves events queued, so this test sees more events than it recorded itself once other tests have run first in the same process. Drain the queue via the existing clear_event_queue() helper before recording this test's events, and run #[serial] so a concurrently running event emitter can't repopulate it mid-test. Part of warpdotdev#13974.
script_for_shell memoizes the fully-interpolated bootstrap script in a process-global MemoMap keyed only on ShellType. The AssetProvider argument determines the script's actual contents but wasn't part of the key, so the first caller to populate a given ShellType's cache entry wins for the rest of the process. Production only ever uses one AssetProvider (crate::ASSETS), so this was invisible there, but any other AssetProvider for the same ShellType -- a test fixture, for instance -- silently receives the first provider's cached script instead of its own. Widen the cache key to (ShellType, TypeId), where the TypeId identifies the concrete AssetProvider implementation. This requires adding Any as a supertrait of AssetProvider so callers holding a &dyn AssetProvider can key off .type_id(); Any is blanket-implemented for all 'static types, so every existing implementor satisfies it with no changes. This is a real correctness fix, not just test hygiene: it also resolves terminal::bootstrap::tests::test_trims_whitespace, which was masked by nextest's per-test process isolation but fails under plain `cargo test` once a real-ASSETS Zsh bootstrap has already populated the cache in the same process. Part of warpdotdev#13974.
|
Every PR must be linked to a same-repo issue before Oz can review it. This PR is linked to #13974, but no linked issue is marked See the contribution guidelines for the full readiness model. Powered by Oz |
There was a problem hiding this comment.
Every PR must be linked to a same-repo issue before Oz can review it.
This PR is linked to #13974, but no linked issue is marked ready-to-implement yet. Only repository maintainers apply that label, so please wait for a maintainer to mark the issue. Once it is marked, push a new commit or comment /oz-review to re-trigger review.
See the contribution guidelines for the full readiness model.
Powered by Oz
|
Hi @fbartho — a reviewer requested changes on this PR and it hasn't had activity from you in 7 days. When you get a chance, please push updates or reply to the review so a reviewer can take another look. Without activity, this PR will be automatically closed after 14 days of inactivity. |
|
(Just commenting so stale-bot doesn't think this is dead). |
…eyed cache `test_trims_whitespace` only catches the BOOTSTRAP_CACHE cross-provider leak by test-ordering luck (it can flaky-pass when no production-asset test runs first). Add `test_cache_is_keyed_on_asset_provider`, which asserts within a single test that two distinct `AssetProvider` types for the same `ShellType` each receive their own script. This fails deterministically before the `(ShellType, TypeId)` cache-key fix and passes after, regardless of ordering. Co-Authored-By: Warp <[email protected]>
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I completed the review and no human review was requested for this pull request. Comment Powered by Oz |
There was a problem hiding this comment.
Overview
This PR resets two process-global test caches before affected tests and widens the bootstrap script cache from ShellType to (ShellType, TypeId) with a regression test for distinct asset provider types.
Concerns
- The new
#[serial]annotations do not prevent unannotated tests from concurrently repopulating the same process-global experiment/telemetry state after the clears, so the shared-process tests can still be flaky under the default Rust test harness. - The bootstrap cache key is still based on provider type rather than provider instance or asset contents, leaving the same wrong-script collision for two providers of the same concrete type with different backing data.
Verdict
Found: 0 critical, 3 important, 0 suggestions
Request changes
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
…he-test-isolation
`#[serial]` only serializes against other `serial_test` tests. Roughly a hundred tests reach `experiments::init` through `test_util::terminal`, none of them annotated, so any of them can repopulate the process-global `EXPERIMENT_LAYER_MAPPINGS` between this test's clear and its assertions. Split the mapping builder into `build_experiment_layer_mappings`, which writes into a caller-supplied map, so the test asserts on a map it owns and never touches the global.
`#[serial]` only serializes against other `serial_test` tests, not against every test that can emit telemetry, so a non-serial emitter can enqueue onto the process-global `warpui::telemetry` queue after `clear_event_queue()` and before the flush. Build the events with `create_event`, which does not enqueue, and call `persist_events_at_path` directly. This exercises the same UGC filtering without reading the shared queue.
Keying `BOOTSTRAP_CACHE` on the provider's `TypeId` collapses two instances of one provider type onto a single entry, so a provider whose contents vary per instance is served the first instance's script. Replace the `TypeId` key with `AssetCacheKey`, which `AssetProvider` declares via `cache_key`. The default keys on the concrete type, which stays correct for the stateless providers in the tree; a provider whose contents vary per instance overrides it with `AssetCacheKey::for_instance`.
|
/oz-review |
|
I'm re-reviewing this pull request in response to a review request. You can view the conversation on Warp. I reviewed this pull request and requested human review from: Comment Powered by Oz |
Oz no longer requests changes for this pull request after the latest automated review.
There was a problem hiding this comment.
Overview
This PR isolates tests from process-global caches by moving experiment and telemetry assertions onto local state, and fixes the bootstrap script cache by including the asset provider cache key alongside ShellType. It also adds deterministic regression coverage for distinct provider types and per-instance providers.
Concerns
- No blocking correctness, security, or spec-alignment concerns found in the annotated diff.
Verdict
Found: 0 critical, 0 important, 0 suggestions
Approve
Comment /oz-review on this pull request to retrigger a review (up to 3 times on the same pull request).
Powered by Oz
|
Hi @fbartho. Thanks for looking into this but we're only committing to supporting |
|
I understand @acarl005. That said: did you notice the correctness bug for |
Closes #13974
Summary
Three process-global, append-only caches leak state across tests in a shared-process run (plain
cargo test -p warp --lib);cargo nextest's per-process isolation masks all three in CI. One of them is a real product bug beyond tests.EXPERIMENT_LAYER_MAPPINGS(experiments/mod.rs) — populated byexperiments::initfrom shared test helpers, never cleared, sotest_create_experiment_layer_mappingssees other tests' experiments.telemetry) — global 1024-cap queue; prior tests' events maketest_persist_events_doesnt_include_ugc_eventssee more than it recorded.BOOTSTRAP_CACHE(bootstrap.rs) — keyed only onShellType, but theAssetProviderargument determines the script contents, so the first provider to populate a shell's entry wins for the life of the process. This is a latent correctness bug, not just test hygiene: harmless in production today only because a singleAssetProviderexists there; any process with two providers (already true in tests) silently gets the wrong cached script.Fixes
EXPERIMENT_LAYER_MAPPINGSat test entry +#[serial].clear_event_queue()at test entry +#[serial].(ShellType, AssetCacheKey), whereAssetCacheKeyis declared by the provider: type identity by default (no implementor changes), andAssetCacheKey::for_instancefor providers whose contents vary per instance.Testing
Full plain
cargo test -p warp --lib: 12 failures → 9; the delta is exactly the three ticketed tests. The remaining 9 are pre-existing and tracked in the sibling flake tickets (terminal::view: 5 tests fail in full-suite runs due to leaked global FeatureFlag state (AgentView never reset) #13972, terminal secrets: redaction tests race on the shared process-global SECRETS_REGEX, failing nondeterministically in parallel runs #13973, workspace::view: test_terminal_model_isnt_leaked fails under full-suite load — detached PTY reader thread outlives tab close #13975).Isolated run of the three ticketed tests:
ok. 3 passed.CI-parity gate:
cargo nextest run -p warp→ 5792/5792 passed, 6 skipped.cargo clippy -p warp -p warpui_core --lib --tests --all-targets: zero warnings.I have manually tested my changes locally with
./script/runAdded regression test (bootstrap product fix)
The bootstrap product fix previously relied on
test_trims_whitespaceto catch the cross-provider leak, but that test is order-dependent — in a shared-process run it can flaky-pass when no production-asset-provider test happens to populate theZshentry first. Addedterminal::bootstrap::tests::test_cache_is_keyed_on_asset_provider, which within a single test callsscript_for_shell(ShellType::Bash, ...)with two distinctAssetProvidertypes returning different content and asserts each gets its own script. This is deterministic and order-independent.Re-verified in this environment (
cargo test -p warp --lib, shared-process):test_create_experiment_layer_mappingsFAILED,test_persist_events_doesnt_include_ugc_eventsFAILED,test_cache_is_keyed_on_asset_providerFAILED (test_trims_whitespaceflaky-passed that run — hence the deterministic test).cargo clippy -p warp -p warpui_core --lib --testsandcargo fmt -p warp -- --check: clean.No UI / computer-use proof: this is a headless test-infrastructure and internal-caching change with no user-facing surface.
Agent Mode
Changelog
CHANGELOG-BUG-FIX: Fixed a bug where the bootstrap script cache could return the wrong script for a shell if more than one asset provider populated the cache for that shell type in the same process.
Originating thread: #13974