Repository navigation
ci-flake: load utils.task_sync once per file in cloud export dedup tests - #23359
Git-on-my-level wants to merge 1 commit into
Conversation
The fast-unit CPU duration guard failed this file twice on CI (1.04s and 1.08s over the 1.00s fail budget; both runs passed on re-run). Each of the four tests ran its own stub_modules + load_module_fresh pair, and the block teardown evicts every transitively imported module (httpx and friends), so every test re-paid the full import inside the guard's measured call phase: 0.50-0.68s CPU on a quiet runner, 0.78-1.08s under the file-isolated runner's saturation, sitting on the 1.0s cliff. utils.task_sync has no module-level mutable state, so one module-scoped import shared by the four tests is behaviorally identical. The per-test store/create_calls/fail_on move onto a mutable _Harness the stub closures dispatch through, and each test seeds it first. The single import lands in the first test's setup phase, which the guard deliberately does not charge (tests/conftest.py measures the call phase only so shared file setup is not misattributed), matching the module-scoped stub_modules pattern already used by tests/unit/test_sync_reprocess_coalesce.py. Measured locally (nice -n 19, guard thresholds 0.1/1.0): before, the file warned at 0.11-0.36s CPU per test; after, no guard output at all, also with six parallel pytest processes saturating the machine, and file wall time 1.18s -> 0.27s. Test isolation unchanged: sibling task_sync files pass in the same process before and after this file.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Folding batch (2026-11-04): this branch's tip was merged into the survivor PR #24477 ( |
|
Hey @Git-on-my-level 👋 Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request. After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:
Before your next PR, please skim:
If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing. Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out. Thank you for being part of the Omi community! |
CI flake fixed at the root
cpu-duration-guard-test_task_sync_cloud_export_dedup-1.04s— the fast-unit CPU duration guard failedtests/unit/test_task_sync_cloud_export_dedup.pywhen a single test's call phase exceeded the 1.00s fail budget.This is a standing CI-flake fix request from David (2026-10-22: every caught CI flake gets fixed at the root; caching and flake fixes approved). No
.github/changes were needed — the fix is test-file only.Evidence it is a flake, not a regression
The file was last touched in #19468; the two failing runs are on unrelated branches and both passed on re-run (attempt 2) with no code change:
lane/finops-schema-evolvelane/memory-undecided-visiblelane/cap-staging-resilienceSame file, same code: 0.5s CPU on a quiet runner vs 1.0s+ under load — the ~2x contention inflation
backend/tests/conftest.pyandbackend/test.shalready document for CPU time under the file-isolated runner.Root cause
Each of the four tests ran its own
stub_modules(...)+load_module_fresh('utils.task_sync', ...)pair.stub_modulesteardown evicts every module imported inside the block (httpxand its transitive dependencies,utils.executors, ...), so all four tests re-paid the full transitive import inside the guard's measured call phase. That is 4x the import cost per file, landing right on the 1.0s blocking budget.Fix (smallest durable change)
utils/task_sync.pyhas no module-level mutable state, so one import shared by the four tests is behaviorally identical:stub_modulesblock and runs oneload_module_fresh, yielding the module plus a mutable_Harness.get_action_item,update_action_item,create_task_internal) dispatch through the harness, and each test seeds its ownstore/create_calls/fail_onfirst — per-test isolation of the fakes is unchanged.tests/conftest.pymeasures the call phase only "so that shared class/file setup ... per-process module import ... is not misattributed as a per-test regression"). This is the same sanctioned pattern astests/unit/test_sync_reprocess_coalesce.py's module-scopedpipelinefixture.No test was skipped, xfailed, deleted, or allowlisted; the guard and its thresholds are untouched.
Verification (local,
nice -n 19, thresholds 0.1s/1.0s)BACKEND_UNIT_TEST_FILE_LIST=<this file> bash backend/test.sh(the CI rerun path): 4 passed, exit 0.test_task_sync_*/ dedup files before and after this file: 46 passed, no contamination.python scripts/check_module_stub_pollution.py: clean for this file (one pre-existing violation elsewhere on main, untouched).black --line-length 120 --skip-string-normalization --check: clean.tests/unit/test_fast_unit_duration_guard.py(the guard's own tests): 5 passed.scripts/pr-preflight --suggest: no product invariants affected, no failure-class declaration required (nofix:commit).