Skip to content

app tests: a read-loops factory that writes after its backend closed is named - #2174

Merged
santoshkumarradha merged 4 commits into
app/v3from
c34/readloops-stop
Nov 2, 2026
Merged

santoshkumarradha merged 4 commits into
app/v3from
c34/readloops-stop

Conversation

@santoshkumarradha

Copy link
Copy Markdown
Member

What changes

TestStartOnItsOwnLaunchesWhatTheStartRulesAllow failed once on a busy machine during cleanup: "TempDir RemoveAll cleanup: unlinkat …/v3/factory: directory not empty". Something wrote into the factory folder while the test's temporary home was being removed.

The backend already closes before that removal. Its close stops the poll, intake, triage, runner and server, and waits for them. I could not reproduce a late write, either at normal speed or at reduced CPU, so the writer is still unknown.

This PR makes the next occurrence say what wrote. Every backend in the read-loops tests now closes through one helper, closeQuietly. It is registered after the home exists, so it runs before the home is removed. The helper:

  1. closes the backend;
  2. watches the factory folder for up to 4 × 50 ms;
  3. fails if any file appears or changes in that time. The failure names each file with its relative path, size and modification time, plus the test name.

The helper covers every backend in the file, including the restarted one (reopened) and both engines in the joined-factory test.

Evidence

  • TestALateFactoryWriteIsNamedWithItsSizeAndTime is the helper's own test. It writes a file into the watched folder after the watch starts.
    • Red, with the watch stubbed out: "late write not named with its path, size and time: []".
    • Green: passes 3 runs out of 3. A folder that stays still reports nothing.
  • All 7 read-loops tests pass 3 runs out of 3 with the helper.
  • Added time, measured as the mean of 3 runs per test on this branch against app/v3:
Test Base (s) Branch (s)
ANewHostInTheSameProcessStartsItsOwnPoll 0.123 0.283
StartOnItsOwnLaunchesWhatTheStartRulesAllow 0.393 0.640
AJoinedFactoryGetsNoReadLoops 0.273 0.470
StartRulesNeverLaunchAJobOnThisMac 0.310 0.503
ThisMacsFactoryPollsAndNeverAsksAModel 0.860 0.847
TriageNeverFallsBackFromAnUnmetOneModel 0.280 0.270
TheTerminalTriageStartStillHoldsOneActiveLoop 0.040 0.040

The total added time for cmd/codeaf is about 0.8 s. A quiet factory costs the full 200 ms watch; a test with no started factory costs nothing.

Limits

  • This does not fix the late writer, because it could not be reproduced. It turns the next occurrence into a failure that names the file.

🤖 Generated with Claude Code

santoshkumarradha and others added 4 commits November 2, 2026 03:50
…is named

TestStartOnItsOwnLaunchesWhatTheStartRulesAllow failed once under load with
'TempDir RemoveAll cleanup: unlinkat .../v3/factory: directory not empty'.
backend.Close already runs before that removal and stops the poll, intake,
triage, runner and server, and no late write could be reproduced (idle and
at reduced CPU), so the writer is unknown. Every backend in the read-loops
tests now closes through closeQuietly, registered after the home exists so
it runs before its removal: it closes the backend, watches the factory
folder for 4 x 50 ms, and fails naming each file written after the close
with its relative path, size and mtime, plus the test name. The next red
says what wrote.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@santoshkumarradha
santoshkumarradha marked this pull request as ready for review November 2, 2026 14:08
@santoshkumarradha
santoshkumarradha merged commit 3b5dca6 into app/v3 Nov 2, 2026
@santoshkumarradha
santoshkumarradha deleted the c34/readloops-stop branch November 2, 2026 14:09
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