Skip to content

test-remediation: 10 tests/services files fail scoped (8 real assertion failures + 2 conftest-stub artifacts) #11248

Closed

Description

@mrveiss

Body repaired 2026-07-15: the original body was accidentally posted as a literal scratchpad file path (@/tmp/...) from a prior session and its content is lost. Reconstructed from the title; findings below re-verified 2026-07-15.

Original scope (from title)

10 autobot-slm-backend/tests/services files fail when run scoped (not via the full repo-wide pytest invocation): 8 real assertion failures + 2 conftest-stub artifacts.

Re-verified 2026-07-15 (while implementing #11717)

The conftest-stub layer is the structural cause of the artifact class:

ACs

  • slm-backend conftest attempts real import before stubbing (light-module real-load pattern), or provides a canonical real-load fixture
  • tests/services and tests/api pass when run scoped, independent of collection order
  • The 8 real assertion failures triaged/fixed or filed individually

Activity

  1. mrveiss commented on Jul 8, 2026

    @mrveiss
    OwnerAuthor

    Triage progress (via a py3.12 venv — closer to target py3.14 than local py3.10):

    • ✅ notification_service_test::test_raises_on_4xx_response — FIXED (PR test(#11248): fix notification 4xx mock + conflict_resolver stale redis attr #11273). Fails on both py3.10 and py3.12 → real bug. Root cause was the test's mock: ClientResponseError(None, None, status=400) (request_info=None) makes str(exc) raise inside the except-block logger.error(..., exc), crashing before the service's real re-raise. Built a well-formed RequestInfo; now 45 passed on both versions. Service code was correct.
    • ⏳ conflict_resolver — fails on both py3.10 + py3.12 (real; investigating next).
    • ❓ causal_inference_engine / concurrent_limiter / grounded_agent / rag_service_events — inconclusive on py3.12 (my minimal venv errors at collection on their deps); need the venv completed before classifying.
    • The 2 stub artifacts (tool_output_filter, llm_api_key_service) remain ci: backend unit tests not enforced — stale assertion merged via #10623 undetected #10691-class.

    Continuing the triage.

  2. mrveiss commented on Jul 8, 2026

    @mrveiss
    OwnerAuthor

    Triage update (py3.12 venv):

    • ✅✅ notification_service_test + test_conflict_resolver — FIXED & merged (PR test(#11248): fix notification 4xx mock + conflict_resolver stale redis attr #11273, squash d912048). Both clean test-rot (malformed ClientResponseError mock; stale _redis_client→_redis after the AsyncRedisClientMixin migration). Verified on both py3.10 and py3.12.

    • ⚠️ test_causal_inference_engine::test_critical_severity — confirmed fails on both py3.10 + py3.12, but it's a severity-semantics design question, not clean test-rot. The report (chain_depth=4, confidence=0.85) correctly yields base=CRITICAL, but _assess_severity (causal_inference_engine.py:670-674) intentionally downgrades CRITICAL→DEGRADED when a high-confidence fix exists (intervention.predicted_success_rate≥0.8 AND confidence≥0.8; the test's intervention is 0.9/0.9), per the explicit comment "High-confidence fix available, not critical." So the code behaves as documented and returns DEGRADED. Decision needed: is that downgrade intended (severity = urgency of manual attention → fixable errors are less urgent) — in which case fix the test (lower the intervention confidence so it verifies the true CRITICAL path, or rename to expect DEGRADED) — or should a critical error stay CRITICAL regardless of fix availability (then the downgrade at :671 is the bug)? Not resolving blind since it changes severity semantics used by alerting/prioritisation.

    • ❓ concurrent_limiter / grounded_agent / rag_service_events — still inconclusive: my scratch py3.12 venv is dep-incomplete for these (collection error / mismatched pass-counts vs py3.10), so I can't cleanly separate real bugs from env noise yet. Need a complete backend venv (ideally py3.14) to classify.

    Net: 2 of the 8 fixed; 1 escalated as a design decision; 3 need a complete target-env venv; 2 are #10691 stub-class.

  3. mrveiss commented on Jul 8, 2026

    @mrveiss
    OwnerAuthor

    More triage (py3.10 reliable baseline):

    • ✅ rag_service_events_test — 37 of 38 FIXED (PR test(rag): patch real publish_event (was stale publish_live_event) — fixes 37/38 (#11248) #11282). Clean test-rot: the test patched services.rag_service.publish_live_event but the code calls publish_event (from events.bus; no publish_live_event exists) → every patch raised AttributeError at setup. Renamed 14 patch targets + a stale docstring. 1 residual anomaly: test_calls_publish_event reports 0 mock calls while its 7 identical siblings intercept fine and the code demonstrably publishes (debug log) — a per-test mock-interception oddity, pre-existing, flagged for follow-up.

    • ⚠️ test_grounded_agent::test_reconstruct_response_with_annotation — a real (small) code robustness bug, but with a behavior question. _reconstruct_response (grounded_agent.py:527) does case-sensitive if claim_text in reconstructed. The test's claim "Latency increased" (capitalised) doesn't match the response "the latency increased", so no annotation is inserted → assertion fails. LLM-extracted claims routinely differ in case from the source text, so annotations silently drop today. Fix direction is case-insensitive matching — but the test also asserts the claim's capitalisation appears in the output, so a fix must decide whether the annotation preserves the response's original case or rewrites to the claim's case. Flagging rather than blind-fixing since it changes user-visible annotation output.

    #11248 running tally: notification ✅ · conflict_resolver ✅ · rag 37/38 ✅ · causal ⚠️(severity-downgrade design Q) · grounded ⚠️(case-match code Q) · concurrent_limiter ❓(needs complete venv) · tool_output_filter + llm_api_key_service = #10691 stub-class. 3 clean-fixed, 2 flagged-for-decision, 1 needs-env, 2 systemic.

  4. mrveiss commented on Jul 8, 2026

    @mrveiss
    OwnerAuthor

    Progress — 2026-07-08 remediation loop

    Real assertion failures: 7 of 8 resolved.

    Test Resolution
    notification_service_test::test_raises_on_4xx_response Fixed — well-formed ClientResponseError (#11273, merged)
    test_conflict_resolver::test_init_lazy_loads_redis Fixed — _redis_client→_redis rename (#11273, merged)
    rag_service_events_test::test_calls_publish_live_event Fixed — patch target publish_live_event→publish_event (#11282, merged)
    test_causal_inference_engine::test_critical_severity Fixed — intervention rates lowered so the documented CRITICAL→DEGRADED downgrade doesn't fire (#11285, merged)
    test_grounded_agent::test_reconstruct_response_with_annotation Fixed — case-insensitive claim reconstruction, real bug (#11285, merged)
    test_llm_cost_tracker::test_model_has_pricing[claude-opus-4-20250514] Not a bug — ANTHROPIC_CLAUDE_OPUS4 (claude-opus-4-20250514) IS present in MODEL_PRICING ({'input':15.0,'output':75.0}, ssot_constants.py:280). The py3.10 triage was a module-import artifact (deps missing → whole file errored, all params reported failed). Verified passing via direct import.
    test_scheduler_registry::test_all_scheduler_files_registered Fixed — PR #11288: registered the 2 real LLC schedulers (llc/scheduler/heartbeat_scheduler.py, routine_scheduler.py — both started in initialization/lifespan), excluded migrations/ false positive. 5/5 pass.
    test_concurrent_limiter::test_queue_still_waits Remaining — code reads correct; suspected py3.10 asyncio.Event artifact; needs py3.14 verification before touching concurrency logic.

    Conftest-stub artifacts (2) — test_tool_output_filter, test_llm_api_key_service — remain folded into the #10691/#11153 conftest-reconciliation effort (not logic bugs).

    After #11288 merges, only test_concurrent_limiter (py3.14 verify) + the 2 #11153 stub artifacts remain.

  5. mrveiss commented on Jul 8, 2026

    @mrveiss
    OwnerAuthor

    Progress — strip_ansi artifact fixed (PR #11329)

    Remaining in this umbrella:

  6. mrveiss commented on Jul 8, 2026

    @mrveiss
    OwnerAuthor

    Progress — llm_api_key_service artifact fixed (PR #11332)

    test_llm_api_key_service (conftest-stub artifact) — FIXED via #11332 (Closes #11331): conftest.py now real-loads services.llm_api_key_service via a pytest_configure hook (runs after all module-level stubs). Real-loading surfaced two masked bugs, both fixed in the same PR: (1) _r() ignored the injected self._redis the tests rely on; (2) test_issue_key mocked pipeline() as async when redis-py's is synchronous. 8 failed/10 passed → 18 passed, zero regressions (full-suite collection identical to baseline).

    Remaining in this umbrella: only test_concurrent_limiter::test_queue_still_waits — code reads correct; suspected py3.10/3.12 asyncio.Event artifact, needs a py3.14 env to verify before touching concurrency logic. Both #11153 conftest-stub artifacts (tool_output_filter #11329, llm_api_key_service #11332) are now resolved.

  7. mrveiss commented on Jul 9, 2026

    @mrveiss
    OwnerAuthor

    Correction — test_concurrent_limiter is NOT a py3.14 asyncio artifact

    Root-caused on py3.12: the test fails at collection, not logic. Import chain services.workflow_automation.concurrent_limiter → workflow_automation/__init__ → manager → orchestrator hit ImportError: cannot import name 'GemmaClassificationAgent' from 'orchestration.orchestrator_stubs' — a missing import fallback (fixed via #11392/#11390). It never reached the test body, so the 'py3.10/3.14 asyncio.Event' hypothesis was never actually exercised.

    After #11392, collection advances to the next blocker: knowledge/base.py's unguarded from llama_index.core import ... (llama_index is in no requirements file) — tracked as #11391. test_concurrent_limiter needs that chain resolved (guarded imports or conftest stubs), not a py3.14 environment.

  8. mrveiss commented on Jul 9, 2026

    @mrveiss
    OwnerAuthor

    Correction to my earlier note: the second test_concurrent_limiter collection blocker I attributed to a 'latent llama_index issue (#11391)' was a mistake — llama-index is a fully-declared prod dependency (requirements.txt:65-69), imported at startup. The local ModuleNotFoundError is just this dev venv missing ~54 deps, not a codebase gap. So in CI's full-dep env, test_concurrent_limiter collects fine after #11390 (the GemmaClassificationAgent fallback). Whether its logic (test_queue_still_waits) passes there is the only remaining open question — and backend pytest is not a gated CI job. #11391 closed as invalid.

  9. mrveiss commented on Jul 15, 2026

    @mrveiss
    OwnerAuthor

    Additional scoped-run failure found 2026-07-15 (while implementing #11719): tests/api/test_require_permission.py::test_services_auth_imports_shared_permission has a brittle string-match assertion against the services/auth.py import line — fails on a clean checkout even standalone, independent of the conftest-stub artifacts above. Should be fixed alongside this remediation (assert on behavior/import success, not source text).

  10. mrveiss commented on Jul 15, 2026

    @mrveiss
    OwnerAuthor

    One more scoped-run artifact found 2026-07-15 (while fixing #11748): autobot-slm-backend/slm/.../health_collector_state_change_test.py fails with ModuleNotFoundError: No module named 'services.notification_service' — pre-existing, reproduces on clean base; same conftest/path-resolution family as the rest of this issue.

  11. mrveiss commented on Jul 16, 2026

    @mrveiss
    OwnerAuthor

    Cross-ref/update: #11737 (PR #11795, merged c7afcc7) repaired 33 tests/services runtime failures incl. sso_security and sync_orchestrator clusters, and #11794 (PR #11799, in CI) fixes the sweep collection errors — several of this issue's 10 files are likely now green. Re-verify against current base before working; remaining run-phase inventory lives in #11798.

  12. mrveiss commented on Jul 17, 2026

    @mrveiss
    OwnerAuthor

    Filed #11833 with a measured instance of this family: collecting any autobot-slm-backend test alongside autobot-backend/api/ yields 44 collection errors (user_management.models.base ... not a package), because slm-backend's conftest pre-populates sys.modules session-wide with hollow stubs. The repo's existing workaround is the separate-process convention documented only in co-located-smoke.yml:95. Per-test isolation was attempted and discarded — the leak just moves to the next stub; the fix belongs in the conftest scoping this issue tracks.

  13. github-actions commented on Jul 22, 2026

    @github-actions
    Contributor

    PR #12113 (merged to Dev_new_gui) references this issue with a close keyword.

    test: remediate scoped-failing services tests (#11248)

    If this issue is fully resolved, close it manually. If work remains, no action is needed.

  14. mrveiss commented on Jul 22, 2026

    @mrveiss
    OwnerAuthor

    Closed — merged via PR #12113 (609901168). 3 files remediated (Redis-hang autouse mocks + conftest inert-patch real-load); 396 passed, 0 hangs. Test-infra follow-up #12114.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions