Skip to content

ci-flake: load utils.task_sync once per file in cloud export dedup tests - #23359

Closed
Git-on-my-level wants to merge 1 commit into
mainfrom
agent/m1-studio-zcode-glm-5-3/9368d81f43c3
Closed

Git-on-my-level wants to merge 1 commit into
mainfrom
agent/m1-studio-zcode-glm-5-3/9368d81f43c3

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 22, 2026 •

Copy link
Copy Markdown
Member

CI flake fixed at the root

cpu-duration-guard-test_task_sync_cloud_export_dedup-1.04s — the fast-unit CPU duration guard failed tests/unit/test_task_sync_cloud_export_dedup.py when 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:

Run Branch Guard measurements (CPU, call phase)
39864803613 attempt 1 (PR #23354) lane/finops-schema-evolve 0.78 / 0.79 / 0.95s warn, 1.04s > 1.00s fail → shard 2/6 failed; attempt 2 green
39854871044 attempt 1 lane/memory-undecided-visible 0.84 / 0.93 / 0.95s warn, 1.08s > 1.00s fail → shard failed; attempt 2 green
39800974523 attempt 1 lane/cap-staging-resilience 0.50–0.68s warn only (quiet-runner baseline)

Same file, same code: 0.5s CPU on a quiet runner vs 1.0s+ under load — the ~2x contention inflation backend/tests/conftest.py and backend/test.sh already 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_modules teardown evicts every module imported inside the block (httpx and 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.py has no module-level mutable state, so one import shared by the four tests is behaviorally identical:

  • A module-scoped fixture enters one stub_modules block and runs one load_module_fresh, yielding the module plus a mutable _Harness.
  • The stub closures (get_action_item, update_action_item, create_task_internal) dispatch through the harness, and each test seeds its own store / create_calls / fail_on first — per-test isolation of the fakes is unchanged.
  • 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 that shared class/file setup ... per-process module import ... is not misattributed as a per-test regression"). This is the same sanctioned pattern as tests/unit/test_sync_reprocess_coalesce.py's module-scoped pipeline fixture.

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)

  • Before: file warned at 0.11–0.36s CPU per test locally; after: no guard output at all, including with six parallel pytest processes saturating the machine (all 6x4 tests passed, zero warnings).
  • File wall time 1.18s → 0.27s.
  • BACKEND_UNIT_TEST_FILE_LIST=<this file> bash backend/test.sh (the CI rerun path): 4 passed, exit 0.
  • Same-process runs with sibling 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 (no fix: commit).

View guided diff Turn on auto-fix

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.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 22, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-22T23:53:53.880952Z 22ae931 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Folding batch (2026-11-04): this branch's tip was merged into the survivor PR #24477 (feat/cv1-release-safety), which now carries origin/main plus all sixteen folded branches; pushed as 88c7ec5. Both sides' conflict intents were preserved (main's evolved implementations win where a successor of the same intent had already landed). Closing here so the batch lives on one PR. Reopen if something you need is missing from the survivor.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
Contributor

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:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant