Skip to content

tui3: the test harness sleeps 150ms for every command that never returns, which is 76% of the package's wall clock and past CI's ceiling #399

Closed

Description

@santoshkumarradha

Problem

The nightly full check at 779ed01 failed with internal/tui3 timing out:

panic: test timed out after 8m0s
	running tests:
		TestTheStripCannotOutliveTheRowItWasOpenedOn (2s)

The named test is an innocent bystander. It runs in 3.62s every time, alone or starved,
and its subtests are exactly 0.45s each. The whole tui3 test binary crossed CI's
eight-minute per-binary ceiling: 397s two nights ago, 409s last night, past 480s after
a day of merges. Whichever test is in flight at the cliff gets blamed, so this must
never enter known-red under any test's name.

Mechanism

The test harness's runCmd in tui3_test.go runs every command with a 150ms budget and
abandons the losers. Test fakes never feed the surface's wait channels, so every
waitEvent, waitPilot, waitRoom, waitTask and every tick longer than 150ms costs
exactly 150ms and leaks one goroutine. Measured over the full package with a counter in
runCmd:

drops 2415
time spent sleeping 362s of 478s
goroutines leaked by the cliff 806 of 886

Three quarters of tui3's wall clock is the harness sleeping. The budget was documented
as the way to handle commands that never return on their own. It was right at three
hundred tests and is the dominant cost at 2696.

The law

A harness pays nothing for a command it knows will never return. The set of such
commands is closed and checked, so a new waiter cannot quietly reintroduce a sleep per
call.

Fix shape

Test files only. The surface code is correct and untouched.

  • runCmd recognises the known never-returning commands by function name and drops
    them at once, with no goroutine: the app's wait* methods and bubbletea's Tick.
  • The 150ms budget stays as the fallback for anything unrecognised, so nothing real is
    dropped faster than today.
  • A structural test in the same file enumerates every wait* method on the app, and the
    tick uses, and fails when one is missing from the recognised set. That is what stops
    the list rotting.

The cleaner seam, fakes that own and close their channels, exists and is not done here:
the package has three other lanes in flight tonight and that refactor crosses all of its
test doubles. With the structural test in place it becomes an option rather than a debt.

Replication

go test ./internal/tui3/ -count=1 -timeout 8m

Fails at 480s with the timeout panic naming whatever was running.

Acceptance

  1. The full internal/tui3 package finishes under four minutes on a quiet machine.
  2. TestTheStripCannotOutliveTheRowItWasOpenedOn passes 50 of 50.
  3. The goroutine count at the end of the package run is flat, not in the hundreds.
  4. The structural test fails when a wait* method is added and not recognised.

Drafted with CodeAF · reviewed and owned by the author

Activity

  1. added
    bug
    on Sep 2, 2026
  2. santoshkumarradha commented on Sep 10, 2026

    @santoshkumarradha
    MemberAuthor

    Closed in the 2026-09-10 triage sweep — fixed, and the fix is your fix shape almost line for line. Verified at dev@95a0d0a9b:

    • The law you wrote is now stated in the code: internal/tui3/tui3_test.go:406 — 'THE LAW: A HARNESS PAYS NOTHING FOR A TICK THAT CANNOT REACH IT, AND IT KNOWS BY NAME WHICH OF ITS COMMANDS WILL NEVER ANSWER', citing this issue.
    • blockingCommands is THE ONE TABLE (tui3_test.go:483), twenty-two waiters named.
    • Two structural tests hold it: TestTheHarnessKnowsEveryCommandThatCannotAnswer reads the surface's own source so a new waiter cannot be added without landing in the table, and TestTheHarnessOverlapsEveryWaiterItNames builds real commands so a name the runtime spells differently is caught. go test -count=1 -run TestTheHarnessKnowsEveryCommandThatCannotAnswer ./internal/tui3/ passes.

    One correction to the issue as filed, worth recording: your mechanism section said the fakes never feed the surface's wait channels, so a recognised waiter could be dropped outright. #463 measured that and it is false — waitEvent answered 76 of 190, waitRoom 16 of 122, ticks 451 of 593 — and dropping them fails better than thirty tests. So the landed design does not shorten the waiters at all: harnessdriver_test.go takes the wait out of the COUNT instead, starting the named waiters and leaving them running while the harness gets on with the next message, so a call that parks five pays one budget rather than five. Only the tick was cheapened, by harnessTick/tickBudget, where the question needs no scheduler.

    The remaining load-shaped test failures are consolidated in #814.

  3. added
    area:chat
    and removed on Sep 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:chatbug

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions