Skip to content

ci-flake: load real models.goal in goals/wrapped/firmware test fixture - #23608

Merged
Git-on-my-level merged 1 commit into
mainfrom
agent/m1-studio-zcode-glm-5-3/1978de6b1eac
Oct 25, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
agent/m1-studio-zcode-glm-5-3/1978de6b1eac

Conversation

@Git-on-my-level

Copy link
Copy Markdown
Member

What

tests/unit/test_goals_wrapped_firmware_hardening.py errored on every Backend Unit Tests run since #22220 merged (3486e8a2d6, 2026-10-25 14:42 UTC): all 7 tests fail at fixture setup with

E   ModuleNotFoundError: No module named 'models.goal'
utils/llm/goals.py:20: ModuleNotFoundError

This is not a product regression — backend/models/goal.py exists and the production import works. It is a stale test fixture: #22220 added from models.goal import sanitize_suggestion_dict to utils/llm/goals.py, but this fixture stubs models as an empty package (__path__ = []) with a hand-listed fake set that does not include models.goal. Under CI's per-file pytest processes (BACKEND_PYTEST_FILE_ISOLATION) nothing pre-imports the real module, the empty-path stub blocks the on-disk import, and the fresh load_module_fresh("utils.llm.goals", ...) exec fails. In a shared local session the sibling test_goal_progress_history_atomic.py (module-scope from models.goal import ...) happens to populate sys.modules first, which is why the breakage was invisible locally — classic import-ordering/shared-state dependence, the drift mode documented as FC-hand-listed-test-isolation-membership in backend/testing/import_isolation.py.

Failing runs with the identical signature (first failure = #22220's merge): main push run 40203471575 (14:42Z), PR run 40204841086 (15:00Z), main push run 40205564034 (15:09Z), PR #23604 run 40206177742 job 121207480456 (15:16Z).

Change

One test file. The fixture now loads the real models.goal via load_module_fresh before the stub_modules block and registers it in the fakes mapping, next to the existing models.conversation entry:

  • the fixture becomes self-contained — no dependence on what other test files imported earlier in the process, so it is deterministic in both per-file and shared-session modes;
  • the suggestion tests keep asserting the real sanitize_suggestion_dict null-coercion behavior (null → 10.0/0.0/10.0), which an AutoMockModule stub would silently break.

No .github/ changes and no new workflows — the fix is entirely in the test fixture. (CI-flake fixes and CI dependency caching were approved by David on 10-22; this PR needs neither.)

Verification (run on this branch)

$ cd backend
$ .venv/bin/python -m pytest tests/unit/test_goals_wrapped_firmware_hardening.py -v          # per-file isolation, like CI
7 passed in 0.25s                      # was: 7 errors, ModuleNotFoundError: No module named 'models.goal'
$ .venv/bin/python -m pytest tests/unit/test_goals_wrapped_firmware_hardening.py -n auto --dist=loadfile -q
7 passed in 1.22s                      # CI's xdist mode
$ .venv/bin/python -m pytest tests/unit/test_goal_progress_history_atomic.py tests/unit/test_goals_wrapped_firmware_hardening.py -q
15 passed in 0.56s                     # shared-session mode still green
$ .venv/bin/python scripts/check_module_stub_pollution.py
Checked 2434 backend test file(s)      # gate passes (2 pre-existing violations in unrelated files, unchanged)
$ scripts/select_backend_unit_tests.py --changed-files <this file>   # CI selects exactly this test file
$ make preflight
PR preflight passed: 33 checks         # incl. backend-module-isolation (test/isolation-allowlist change)

Reproduction on origin/main before the fix (per-file process): 7 errors with the exact CI signature; with test_goal_progress_history_atomic.py in the same process: 15 passed — confirming the ordering dependence.

#22220 added 'from models.goal import sanitize_suggestion_dict' to
utils/llm/goals.py, but the fixture in test_goals_wrapped_firmware_hardening.py
stubs 'models' as an empty package whose hand-listed fakes omitted
'models.goal'. In CI's per-file pytest processes (BACKEND_PYTEST_FILE_ISOLATION)
nothing pre-imports the real module, so the fresh goals.py exec hit
ModuleNotFoundError and all 7 tests errored on every run since 3486e8a
(deterministic main-red; shared local sessions hid it because a sibling test
file imports models.goal at module scope).

Load the real models.goal via load_module_fresh before the stub block and
register it in the fakes mapping: the fixture becomes self-contained (no import
ordering / shared sys.modules state) and the tests keep asserting the real
sanitize_suggestion_dict null-coercion behavior instead of a mock.
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 25, 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-25T16:05:53.377046Z 72b288f 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
Git-on-my-level merged commit f3e669f into main Oct 25, 2026
58 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/m1-studio-zcode-glm-5-3/1978de6b1eac branch October 25, 2026 16:24
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