Skip to content

fix(tests): gate _FakeLoop fakes that carry probe monitor state - #8301

Closed
dwu96 wants to merge 1 commit into
mainfrom
fix/autonudge-stop-auth-fakeloop-gate
Closed

fix(tests): gate _FakeLoop fakes that carry probe monitor state#8301
dwu96 wants to merge 1 commit into
mainfrom
fix/autonudge-stop-auth-fakeloop-gate

Conversation

@dwu96

@dwu96 dwu96 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Symptom (main breakage — blocks every open PR's backend shards)

The five terminal-subject tests #8201 added in test/test_autonudge_stop_auth.py fail on current main (b2320e02c) and on every branch cut from it, with monitor_update cannot apply legacy fields to a structured monitor (or 0 == 1 update-call counts). First seen as Backend Tests (Windows) (1) red on PR #8291; reproduced locally on a pristine origin/main worktree on Linux — it is platform-independent main breakage, not a shard flake.

Root cause: a merge race, not a bad fix

Fix (test-only, one invariant)

_FakeLoop now sets gate = monitor is not None, mirroring the production invariant, with a comment explaining why. No src/ change; #8201's production behaviour is correct once the fixture has the shape real loops have.

Verification

  • Red: the 5 tests fail on pristine origin/main (b2320e02c) locally, identical to CI.
  • Green: with this change, test/test_autonudge_stop_auth.py passes 50/50 (was 45 passed + 5 failed).
  • _FakeLoop is module-local (no cross-file imports); black (26.3.1) + flake8 clean.

Pattern harvest

Rule candidate: a test fake that carries a state field must also carry every invariant production couples to that field (here: probe monitor state exists only on gate=True loops) — otherwise a later dispatcher keyed on the coupled field silently reroutes the fake down a branch production never takes. Knowingly out-of-scope sibling: the general "PR merged with green-but-stale CI across a semantic conflict" class (merge-queue/re-run-on-merge policy) is a process question, not fixable in this test file.

Main breakage: the five terminal-subject tests #8201 added fail on every
branch. #8201 branched before #5184 landed is_structured_monitor_loop
(monitor set + gate falsy = structured controller record), and merged at
20:08Z with green-but-stale CI, so the semantic conflict was never run.

Its _FakeLoop fixtures carry probe 'monitor' state but never set 'gate',
a shape production never stores: the probe only runs on gated prompt
loops, so a real loop with monitor.terminal_pending always has gate=True.
The un-gated fakes misroute monitor_update into the structured branch,
which rejects legacy fields ('monitor_update cannot apply legacy fields
to a structured monitor').

Give _FakeLoop the production invariant: gate is True exactly when the
fake carries monitor state. Test-only change; all 50 tests in the file
pass, previously 45 passed + 5 failed.
@dwu96
dwu96 requested a review from a team as a code owner September 3, 2026 22:52
@dwu96
dwu96 requested a review from patrigao September 3, 2026 22:52
@jeeshofone

Copy link
Copy Markdown
Contributor

Independent verification, for merge confidence on this main-red:

@github-actions github-actions Bot added the readiness: checking Automated validation is still running label Sep 3, 2026
@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

GPT 5.6 Review — ✅ no blocking findings

GPT 5.6 completed its review of f4ec9d769e2ec4fc7141ac0c63e3697fa8643e61 and found no blocking issues.

This comment is updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] f4ec9d7

False positive or not applicable? A repository writer can comment:
/ai-review override gpt f4ec9d769e2ec4fc7141ac0c63e3697fa8643e61: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Opus 4.8 Review — ✅ no blocking findings

Reviewed f4ec9d769e2ec4fc7141ac0c63e3697fa8643e61 — this comment is updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] f4ec9d7

Verdict parsed from the review's SHA-scoped output markers for commit f4ec9d769e2ec4fc7141ac0c63e3697fa8643e61.

False positive or not applicable? A repository writer can comment:
/ai-review override fable f4ec9d769e2ec4fc7141ac0c63e3697fa8643e61: <one-sentence reason>

@github-actions

github-actions Bot commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

Design Review (Fable 5) — ✅ PASS

Design-level review of f4ec9d769e2ec4fc7141ac0c63e3697fa8643e61 — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS/CONCERNS are advisory.

All claims verified: is_structured_monitor_loop at autonudge.py:516-518 reads monitor and not gate as a structured record, the probe path guards on loop.gate, the five monitor-carrying fakes in this file were the only ones affected (other _FakeLoop definitions carry no monitor state), and the two tests that need explicit gate values already set .gate after construction, so the derived default conflicts with nothing.

Design-Verdict: PASS

Root-cause test-only fix at the right layer: the fixture now encodes the production invariant once, instead of patching five call sites.

[DESIGN-REVIEWED] f4ec9d7

@CrysisDeu

Copy link
Copy Markdown
Collaborator

Hi @dwu96 — thanks for picking this up! Heads-up that main moved again and this PR is now showing CONFLICTING, which also means its own CI can't dispatch.

This fix is currently the unblocker for the test_autonudge_stop_auth.py shard-1 red that several open PRs are inheriting through their merge refs — at least #7378, #7308, #8267, #8130, and #5539 are waiting on it to go green.

No rush at all, but whenever you get a chance, a rebase onto current main would unblock the queue. Happy to help verify on our side once it's re-pushed. 🙏

@dwu96

dwu96 commented Sep 4, 2026

Copy link
Copy Markdown
Contributor Author

Closing as superseded: #8317 (merged 2026-09-03T23:46Z) fixes the same main breakage with the same shape — gating the _FakeLoop double that carries probe monitor state — and landed first, which is also why this branch now shows a conflict (both PRs edit the same fixture lines). Verified on current main tip (5df44de2f): test/test_autonudge_stop_auth.py passes 50/50 locally.

The diagnosis this PR carried (the #8201/#5184 green-but-stale-CI merge race, the production invariant that probe state only exists on gated loops, and the independent macOS repro by @jeeshofone in the thread) matches what #8317 shipped, so nothing here is lost by closing. Thanks @bolichen97 for the fast fix.

@dwu96 dwu96 closed this Sep 4, 2026
@github-actions github-actions Bot removed the readiness: checking Automated validation is still running label Sep 4, 2026
@bolichen97
bolichen97 deleted the fix/autonudge-stop-auth-fakeloop-gate branch September 6, 2026 03:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants