Repository navigation
tui3: make the switch and plan test fakes safe for off-loop readers - #1836
Merged
Merged
Conversation
The -race failures in the held-send tests and the run-stop card test were in the test seams, not the surface. The kept conversation's watcher calls Attach from its own goroutine, and the door line asks PlanTasks, PlanTaskPage and the plan verbs off the loop; the real agents take their locks for all of these. The fakes did not: - switchAgent: Attach and its stop guard running/backlog/stops with a mutex; tests that flip running while a watcher is live use setRunning. - planFake: PlanTasks answers a copy as the store does; setStatus writes a new slice instead of over the one planAppWith handed the surface; pages are guarded, and the program-room test writes them through setPage. Fixes the four held-send races, TestStopOnTheRunsOwnPageRaisesTheCardAndTheCardStopsTheRun, and three more of the same class found on dev: TestAProgramRoomReadsTheLandingTheStoreEndedAhead, TestTheCancelKeyOnAPlanRowEndsItThroughTheStore, TestPOnAPlanRowPausesThenResumes. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…il counters Review follow-ups on #1836: - railPlanCounter's rows/pages counts are atomic; they are bumped by the surface's off-loop reads. - planFake gains editRows (in place, keeping planAppWith's aliasing) and setPlan; every direct test write to fake.plan and fake.pages goes through them or setPage. - switchAgent.mu's comment says exactly what it covers. - The change entry's invalidates line is cut to the rules' length and drops surface for this test-only change. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
Fixes the pre-existing
-racefailures in tui3's held-send and plan tests. Every race was in a test fake; production code is unchanged.What changed
Why it's the fakes, not production
Attach, or the door line calling the plan reads and verbs.Attachis locked in production:session/agent.goholdsa.mu, andremote/observe.goholdsc.mu.session/plandb_tasks.go(PlanTasks,PlanTaskPage) opens its own store handles each time and builds a new slice.session/plandb_steer.go(the verbs) writes the store, not anything the surface holds.remote/client.gois RPC that unmarshals a fresh value per call, so it needs no lock.Changes (test files only, plus the change entry)
switchAgent: a mutex guardsrunning/backlog/stopsforAttachand its stop. Tests that fliprunningonce a watcher may be live usesetRunning.planFake:PlanTasksreturns a copy.setStatuswrites a new slice instead of the oneplanAppWithgave the surface.planandpagesare locked, and test writes go throughsetPage/editRows/setPlan.railPlanCounter: therows/pagescounters are atomic.Tests fixed
TestAFailedHeldSendStaysWaitingWithItsAttachmentsAndNotesTheFailureTestAWaitingPictureSendsInItsHeldConversationAndTheWatcherAdoptsItsTurnTestComingBackDuringAHeldSendNeverSendsItTwiceTestHeldWaitingMessagesGoOnePerLandingAfterSessionFollowUpsAndNeverTwiceTestStopOnTheRunsOwnPageRaisesTheCardAndTheCardStopsTheRunTestAProgramRoomReadsTheLandingTheStoreEndedAheadTestTheCancelKeyOnAPlanRowEndsItThroughTheStoreTestPOnAPlanRowPausesThenResumesHow it was checked
go test -race -count=1FAILfor the 8 above, with 10WARNING: DATA RACEreports.TestHeldWaitingMessagesUsePasteAndRemoteFileDoorsandTestAHeldWaitingChatTitleRedrawsWithoutAnotherAttentionNotice.-race -count=5--- PASS5/5 for all 10 andok internal/tui3, with 0DATA RACEreports.-race -count=1DATA RACE.make changelog-check11 entries, all well formed.GOFLAGS=-mod=readonly go test -race -count=5 -run 'HeldSend|HeldWaiting|WaitingPicture|ComingBackDuringAHeldSend|TestStopOnTheRunsOwnPage|TestAProgramRoomReadsTheLanding|TestTheCancelKeyOnAPlanRow|TestPOnAPlanRow' ./internal/tui3/Checklist
docs/changes/unreleased/1836-held-send-race-fakes.md(kind: internal)..github/known-red.txt: none added (the file doesn't exist on dev).git add -A.🤖 Generated with Claude Code