Skip to content

fix(runtime): stop chat-usage test stranding active tasks that flip sweeper tests (CHE-1810) - #278

Merged
congvc-dev merged 2 commits into
mainfrom
fix/che-1810-sweeper-idle
Oct 16, 2026
Merged

congvc-dev merged 2 commits into
mainfrom
fix/che-1810-sweeper-idle

Conversation

@congvc-bot-x99

@congvc-bot-x99 congvc-bot-x99 Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

Status
Ready for Cheese's review and merge. Test cleanup fix only. No product code.

Conditions

Change

  • Root cause: TestChatSessionUsageRefusesCrossWorkspaceLikeSessionGet registers a cleanup that deletes the chat_session before the seed's own cleanup runs. agent_task_queue.chat_session_id is ON DELETE SET NULL, so the seeded running and dispatched tasks keep their rows with no chat session. The seed cleanup DELETE ... WHERE chat_session_id = $1 then matches nothing.
  • Those two active tasks stay on a shared integration agent for the rest of the package run. RefreshAgentStatusFromTasks reports working when an agent has any dispatched or running task. The sweeper tests TestRefreshAgentStatusFromTasks, TestSweepStaleTasksReconcileAgentStatus and TestSweepDispatchedStaleTask pick the integration agent with LIMIT 1 and no ORDER BY, so they hit the leaked agent only on some runs.
  • Fix: the cross-workspace test's cleanup deletes the session's tasks before the session. 3 lines in server/cmd/server/chat_usage_test.go.
  • No idle assertion is weakened, skipped or retried.

Evidence

  • Commit 1 44e3cf529 is tests only. It adds TestChatSessionUsageCrossWorkspaceCleanupLeavesNoActiveTasks. Against its parent it fails on the stated behavior:
=== RUN   TestChatSessionUsageCrossWorkspaceCleanupLeavesNoActiveTasks/body
    chat_usage_cleanup_test.go:53: cleanup stranded active tasks with no chat session or issue: [9ba0cf7e-9213-46a6-8423-f4dddeee2949:running 86bbd19e-177a-4942-b5b8-53eae74529ec:dispatched]
--- FAIL: TestChatSessionUsageCrossWorkspaceCleanupLeavesNoActiveTasks (0.07s)
FAIL	github.com/multica-ai/multica/server/cmd/server	0.245s
  • Commit 2 758c5cecd is the fix. The same test passes. go test -race -run TestChatSessionUsage ./cmd/server: 8 PASS.
  • Base f37d08ba1, full package ./cmd/server with -race, default order, my disposable database: 6 of 12 runs failed. Each failing run listed one to three of the sweeper tests above, with the messages in CHE-1810. 9 of those 12 runs used a binary with extra logging in the failure path only, which does not change test behavior.
  • Fix head 758c5cecd, same command, 6 runs: 6 PASS, 0 failures.
  • A trigger on the disposable database logged every insert or update that left a running or dispatched task with no issue and no chat session. The DELETE FROM chat_session rows were the stranded tasks. The other writers were cleaned by their own tests.
  • Shuffle: seeds 1810, 20261016 and 7 on both binaries. The package already fails many unrelated tests under shuffle on base (13, 14 and 3 failures). The three sweeper tests failed on base with seed 7 and failed on none of the fix runs. Shuffle is not a pass signal for this package. The order dependence in other tests is out of scope and I did not change it.
  • Toolchain: go1.26.2 linux/amd64 on X99. Database: pgvector/pgvector:pg17 in a throwaway container on a loopback port, migrated with go run ./cmd/migrate up. No live profile and no production database was used.
  • Cleanup: the container is removed, the temporary worktree and /tmp files are removed, and the port is closed.
  • At publication: NOT-RUN: GitHub CI on this head, OCR, independent final verifier. The verification update below supersedes this publication snapshot.

Verification update — 2026-10-16

  • Exact pair: base f37d08ba1f61610d2266a05ee3ee4a353bf94157, head 758c5cecd0e33dd9cf111e1e658e3f2ffd96e140.
  • Independent review: PASS, non-OCR fallback. P0/P1: 0/0. The reviewer verified the cleanup oracle and the recorded red/green and repeated-suite evidence.
  • GitHub CI: 12 SUCCESS, 7 SKIPPED, 0 failed, 0 pending. Full backend-tests passed.
  • OCR: skip, because this is a tiny test-only cleanup fix covered by a behavioral regression (CHE-1527 Skip OCR column).
  • OCR status: NOT-RUN. Prior exact-pair OCR session 8ac3f457-31c1-4640-8d1a-ad0d36b55e2b was unavailable. Both selected files failed before review with provider HTTP 401/503/403 errors and 0 tokens. This is not a clean OCR result. The signed reviewer records the non-OCR fallback and all P0/P1 dispositions.
  • Non-blocking P3 retained: server/cmd/server/chat_usage_cleanup_test.go:36 does not check rows.Err(). No correction is included at this reviewed head.
  • Cleanup verified: the abandoned Luna container is absent and port 32895 is closed.

Review report and OCR receipt: CHE-1810 comment 01a14221-4696-7135-a049-c9abeb802bba.
Reviewer: x99-agy-gemini (gemini-3.8-flash-high, Google; independent non-author, different-lab from x99-claude-sonnet/Anthropic).
Signed: 2026-10-16 07:35 ICT — PASS, non-OCR fallback.

STE advisory receipt: passive-voice warnings=true positives (9). Synonym-rotation=false positive (cleanup terms).

Changelog: none
Refs CHE-1810

@congvc-bot-x99
congvc-bot-x99 Bot marked this pull request as ready for review October 16, 2026 00:41
@congvc-dev
congvc-dev merged commit c378405 into main Oct 16, 2026
20 checks passed
@congvc-dev
congvc-dev deleted the fix/che-1810-sweeper-idle branch October 16, 2026 02:33
congvc-bot-x99 Bot pushed a commit that referenced this pull request Oct 16, 2026
congvc-bot-x99 Bot pushed a commit that referenced this pull request Oct 16, 2026
Brings the CHE-1810 runtime sweeper fix (PR #278).
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