Repository navigation
fix(tests): three more causes of the red Tier 3 night are test defects — a shared ask queue, a unit test in the live tier, three stale assertions (#4620) - #4805
Merged
Conversation
…s — a shared ask queue, a unit test in the live tier, three stale assertions (#4620) Three of the seven causes behind the red nightly (#4788 takes two; the placeholder model key and one product defect stay open). No product code changes. A module shared one agent's ask queue (unit job, 4 tests per red seed). tests/unit/test_ent1109_credential_handover.py raises every ask for one agent, in a database that outlives the test. TestDelivery leaves 18 asks pending and TestTheAsk raises 11, against a cap of 25 pending per agent. In file order TestTheAsk runs first and never meets the cap; in a shuffled order the next raise is refused with queue_full: four tests on each of the night's two red seeds, a different four on each. The real_db fixture now empties that agent's queue before and after each test. A unit test ran in the live tier (7 tests). tests/test_cb_probe_execution_close.py stubbed `database`, `utils.helpers`, `redis` and more into sys.modules with setdefault, which keeps whatever an earlier-collected file left there. In the live selection that was tests/git_sync/test_s5_conflict_classifier.py's load-time `database` stub, whose `db` is None, so every service execute_task reaches was bound to None. The module moves to tests/unit/, where the conftest provides the real `database` on a per-process file, and loses its own stubs; it imports the service at collection so the service's collaborators are bound to that database. #1895 had left it in the root because it was red at the time: against #1804, which #2242 fixed the next day, and on a seed-dependent ImportError from its own sanitizer stub, which is gone now. The move never followed. The per-PR unit job now runs it. tests/registry.json and the two lint baselines follow the move. The root placement list goes 10 -> 8: this module left, and test_public_links.py now takes a live fixture. Three assertions described the product as it used to be (3 tests). - test_avatars: the 501 for a missing Gemini key carries copy for the person in the dialog since #957, and no error code. The test no longer asserts wording; on a 501 it checks only that there is a message. - test_settings: POST /api/settings/ops/reset leaves the retention windows alone on purpose (#1638), and a fresh install seeds some of them with a value that is not the code default. The test now says what reset promises: every other ops setting returns to its default, and each retention window keeps its value and stays a stored row where it was one. The window names and sources come from GET /api/settings/retention. - test_public_links: the email requirement is the agent's access policy (#311) and a new agent is created with it on (#1129). TestPublicChat put its link on whichever running agent `docker ps` listed first, with the policy that agent happened to have. The link now goes on the module's own agent (the suite's created_agent), and the fixture sets the policy the test is named after there, sending the whole policy because the route replaces it. This fixture no longer touches an agent the suite did not create. A learnings note (docs/memory/learnings/) records the first cause as a class: a per-agent cap is state shared between tests, even when every request id is unique. The same defect had been fixed once before, in a sibling module (#4401). Refs #4620 Co-Authored-By: Claude Fable 5.2 <[email protected]>
obasilakis
approved these changes
Nov 27, 2026
obasilakis
left a comment
Contributor
There was a problem hiding this comment.
/review + /validate-pr — #4805
Lane B (tests only, with deletions). No product code. Scope matches the description: causes 6, 3 and 5 of #4620.
Execution coverage
| changed file | executed by | verdict |
|---|---|---|
tests/unit/test_ent1109_credential_handover.py (real_db clears ASKER's queue) |
the module itself, seeds 67890 / 99999 | ✅ |
tests/unit/test_cb_probe_execution_close.py (moved, stubs removed, collection-time import) |
per-PR unit job now collects it | ✅ |
tests/test_avatars.py, tests/test_settings.py, tests/test_public_links.py |
live tier only | ✅ by the PR's live run; not re-run here |
lint baselines, registry.json |
lint_sys_modules.py, lint_root_test_placement.py |
🛡 guard |
Reproduced locally on the PR head:
- Both unit modules together, seed 67890: 84 passed.
test_ent1109_credential_handover.py, seed 99999: 74 passed. - Mutation: with both
_clear_asker_queue()calls removed, seed 99999 gives 4 failed, 70 passed. The fixture change is what makes it green. tests/lint_sys_modules.pyandtests/lint_root_test_placement.pyexit 0.
Critical
None.
Informational
- I1
test_public_links.py: thefinallyrestore (httpx.put(policy_url, …, json=prior_policy)) ignores its status. If the restore fails, the module's agent keepsrequire_email: Falsefor later tests in the module. The agent belongs to the suite and is deleted at teardown, so the blast radius is that module. Anasserton the restore status would surface it. Non-blocking. - I2
test_avatars.py: the 501 assertion now checks for a non-emptydetailand no wording. Fine as a contract. A regression that returns a 501 from a different cause would also pass, since the route carries no error code. Adding an error code to that 501 is product work and out of scope here. - I3
test_ent1109_credential_handover.pyclears the queue with raw SQL (parameterized, scoped to one agent name). The cleanup keeps working if the agent name stays constant. The learnings note already recommends a per-test uuid agent name as the sturdier pattern.
Process
- Security greps (keys, emails, IPs, host paths, file modes): clean.
Refs #4620with no closing keyword is deliberate: the nightly workflow closes #4620. The issue will not auto-promote tostatus-in-dev.- Learnings fragment added under
docs/memory/learnings/, in the right shape. - Merge gate:
pytest (head, seed 12345)was still pending when this was posted. Tier 1 has to finish green before merge.
Verdict: APPROVE.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The nightly Tier 3 run on
devis red (#4620). #4788 takes two of its seven causes. This PR takes three more: causes 6, 3 and 5 of the table in #4620, numbered 1 to 3 below. All three are defects of the tests, not of the product. The PR changes tests and adds one learnings note; no product code changes.1. One agent's ask queue shared by a whole module (unit job, 4 tests per red seed).
tests/unit/test_ent1109_credential_handover.pyraises every ask for one agent, in a database that outlives the test.TestDeliveryleaves 18 asks pending andTestTheAskraises 11, against a cap of 25 pending asks per agent. In file orderTestTheAskruns first and never meets the cap. In a shuffled order the next raise is refused withqueue_full: four tests on each of the night's two red seeds (67890 and 99999), a different four on each.real_dbfixture empties that agent's queue before and after each test.docs/memory/learnings/2026-11-27-a-constant-agent-name-fills-the-per-agent-ask-cap.md): a per-agent cap is state shared between tests, and the same defect was fixed once before in a sibling module (feat(credentials): name a registered instance as a credential ask's destination (abilityai/trinity-enterprise#1158) #4401).2. A unit test that ran in the live tier (7 tests).
tests/test_cb_probe_execution_close.pyneeds no stack, but it sat intests/root, where only the live-tier jobs collect it. It stubbeddatabase,utils.helpers,redisand more intosys.moduleswithsetdefault, which keeps whatever an earlier-collected file left there. In the live selection that istests/git_sync/test_s5_conflict_classifier.py's load-timedatabasestub, whosedbisNone. Every serviceexecute_taskreaches was then bound toNone, and the seven tests died on'NoneType' object has no attribute 'get_setting_value'before they reached the circuit breaker or the cancel handler. Alone, the module passes.tests/unit/and loses its own stubs: there the conftest provides the realdatabaseon a per-process file. The ten tests and their assertions are unchanged.databasedouble bound intosettings_serviceand reproduced the same seven failures. A whole-suite run never showed that, because collection imports the service first.ImportErrorfrom the module's own sanitizer stub. bug: stale test mocks drifted from #1804, #2015 and ent#237 — 9 failures of lost coverage #2242 fixed the first the next day, and the stub is gone with this PR. The move never followed.tests/registry.jsonand thesys.modulesbaseline follow the move, as do two one-line mentions of the file: the header texttests/lint_root_test_placement.pywrites into its baseline, and a path in a docstring oftests/unit/test_terminal_write_cas_gate.py. The root-placement baseline goes 10 → 8: this module left, andtest_public_links.pynow takes a live fixture, so it no longer needs the exemption.3. Three assertions that described the product as it used to be (3 tests).
test_avatars.py: the 501 for a missing Gemini key carries copy written for the person in the dialog since bug: 'Failed to generate avatar' surfaces in Agent Avatar dialog with no actionable error detail #957, and no error code. The test asserted the old wording (GEMINI_API_KEY). It no longer asserts wording: on a 501 it checks only that the body carries a message, which any 501 from this route does. What the test still pins is the set of statuses the route may answer.test_settings.py:POST /api/settings/ops/resetleaves the retention windows alone on purpose (bug: retention floor (#1065) silently deletes pre-existing execution history on upgrade — currently dev-only, ships to everyone at next release #1638), and a fresh install seeds some of them with a value that is not the code default. The test expected every ops setting at its default after a reset. It now says what reset promises: every other setting returns to its default, and each retention window keeps its value and stays a stored row where it was one. The window names and where each value comes from are read fromGET /api/settings/retention, so the test carries no list of its own.test_public_links.py: the email requirement is the agent's access policy (feat: Unified channel access control — verified-email identity, per-agent allow-list, access requests (web / Telegram / Slack) #311), and a new agent is created with it on (Make 'require verified email' access policy a fleet-wide default config (secure-by-default) #1129).TestPublicChatput its link on whichever running agentdocker pslisted first, with the policy that agent happened to have, and got 401. The link now goes on the module's own agent (the suite'screated_agent), and the fixture sets the policy the test is named after there. It sends the whole policy, because the route replaces it. This fixture no longer touches an agent the suite did not create. Older fixtures and tests in the same file still pick the first running agent and still send a two-field policy, which resets that agent'sgroup_auth_mode; they are not changed here (bug(tests): live-tier fixtures change an agent the suite did not create, and put it back incompletely #4801).Not in this PR
placeholder; those tests need a real turn.test_public_links.py::test_chat_without_email_requirementno longer fails, but on a stack without a working model key it skips: its chat turn answers 502 and the test treats that as "agent not responsive". Its pass has not been observed; it will run for real once the key is there.requires_modelmarker here. The marker comes with the change that brings the model key, because with a placeholder key it would turn this skip into a twelfth red test.git_syncmodules still leave theirdatabasestubs behind for the rest of the live session. Nothing collected there depends on it any more after this PR; cleaning them up is a separate change (refactor(tests): load-timesys.modulesstubs that outlive the file that needed them #4803).test_web_file_upload.py(in either order) or withtest_slack_file_uploads.pybehind it, its three background-wrapper tests cannot importrouters.internal, because those files leave a partialservices.docker_utilsstub at collection. A whole-suite collection, which is what every CI worker does, imports the real module first and all ten pass. The fix belongs in the two upload files (refactor(tests): load-timesys.modulesstubs that outlive the file that needed them #4803).Related Issue
Refs #4620
No closing keyword, for the reason #4788 gives: #4620 is the nightly's own tracking issue,
dev-nightly.ymlcloses it on the first green night, and after this PR the night is still red on the 11 tests above.Journey Impact
Journey Impact: none: test fixtures and assertions, one test module moved between test tiers, two lint baselines, the test registry and one learnings note; no product code and no journey promise changes
Type of Change
Testing
No new tests: every change is to an existing test. Each one was seen red for the stated reason first. The branch is based on
30ce96ecb; the diff also applies cleanly ondevat85dd5d143(two commits later, one of which edits the service these unit modules drive), and both unit modules pass there. It also merges cleanly onto9ddef927e, one commit later, which touches none of the files involved.Cause 1 (ask queue).
TestDeliverythenTestTheAsk, no shufflequeue_fullA probe that counts the agent's pending asks before each test shows the count reach 25 and the next raise fail.
The same four tests are red in CI for seed 99999 outside the Tier 3 job too:
backend-unit-nightly, run 45861192007 (2026-11-26),AskRejected: queue_full.Cause 2 (the moved module).
tests/rootgit_sync/test_s5_conflict_classifier.py+ the module, in rootStubbing the collaborator the traceback names does not fix it in place: the next one fails on the same
None(tried three in a row), which is why the module moves instead.Pair sweep: the moved module run directly after each of the 80 unit files that write
databaseintosys.modulesor name it in a stub mapping (grep -lE "sys\.modules, *[\"']database[\"']|sys\.modules\[[\"']database[\"']\]|setdefault\([\"']database[\"']|[\"']database[\"']: " unit/*.py, minus the module itself). Before the collection-time import, 5 of the 80 pairings failed its seven tests; with it, none of the 79 that can run does. The 80th file does not collect by itself in my environment, at the base commit too.Whole unit suite with the nightly's unit command (
--dist loadfile -p randomly --randomly-seed=…, 8 workers where the workflow says-n logical), base against this PR on the same machine:TestTheAsktestsgit ls-filesin a copy without.git, and two are timing checks that come and go. The four files those 12 belong to pass on the real checkout of this commit (68 passed). One of those two is the single difference in the 12345 row (test_ent1176_managed_hooks::test_a_same_size_rewrite_with_its_mtime_restored_is_read_again); it was red at base under seed 67890. The only other status change on that seed is atest_2742_git_status_lock_freewitness that went from passed to skipped: it skips by design when its control arm does not reproduce a lock race in that run.nohup … &), which leaves SIGHUP and SIGINT ignored. Four tests oftest_ent1094_marketplace_release.pysend those signals to a shell script and fail under that launcher; the same module is 142 passed when started in the foreground on the same tree. A foreground run of this PR on 67890, made before the last review edits, had exactly the 14.Cause 3 (stale assertions), live, on a stack booted the way
dev-nightly.ymlboots it (PostgreSQL, placeholder model key):test_generate_returns_501_without_gemini_key'GEMINI_API_KEY' in "Avatar generation isn't configured…"test_reset_restores_default_valuesexecution_log_retention_days should be at default after resettest_chat_without_email_requirementSession token required for this linkThe whole live selection (
-m "not slow" --ignore=unit) on a tree with this PR and #4788 together:Compared test by test:
test_parallel_task.py) and the duplicate-subscription 500 (1). Nothing went from pass to red.test_cb_probe_execution_close.pytests (7 red, 3 passing).test_operator_queue.pywent from skipped to pass (test_get_existing_item,test_respond_to_pending_item). They skip when the stack's queue happens to be empty; nothing in this PR touches them.The live run was made before the last three edits to
test_settings.pyandtest_public_links.py(the stored-row check, two skips turned into assertions). Those two classes, with the file's other policy classes, were rerun on the same stack afterwards: 12 passed, 1 skipped.Mutation, each made in a scratch copy and run against the changed unit tests. Each of the moved module's ten tests goes red under at least one:
transport_open = False) → the threetest_cb_open_*tests fail.test_cb_closed_proceeds_normallyfails.execute_task's cancel handler no longer matches (except GeneratorExit:) →test_cancelled_error_marks_execution_failedfails.test_cancelled_error_skips_already_terminal_executionfails.returnwhere it re-raises) → all threeTestCancelledErrorInExecuteTasktests fail,test_cancelled_error_is_reraisedamong them.test_background_cancelled_marks_execution_failed,test_background_cancelled_skips_already_terminal, and all threeTestCancelledErrorInBackgroundtests, in that order.queue_full).test_backlog.py.The three live tests cannot be mutated without rebuilding the stack; their red state is the base run in the table above.
Lints:
tests/lint_sys_modules.pyandtests/lint_root_test_placement.pypass; their own unit tests pass (51). #4788's diff applies cleanly on top of this one and its seam guard passes with both applied."All existing tests pass" is left unticked: the whole unit suite ran in an environment where some tests fail for reasons of that environment (above), and the live selection stays red on the 11 tests listed under "Not in this PR".
Checklist
git commit -s) — required for contributors outside the core teamWritten with Claude Code.
🤖 Generated with Claude Code