Repository navigation
In progress
Labels
Description
Parent / source
- Parent: End-to-end red-to-green TLA+ fixes and upstream PR prep for flagship TypeScript 7 concurrency bugs #1
- Authoritative analysis:
verification/tla/ANALYSIS.md(Tier A Fix lost global-diagnostics push notification in project.Session (tsc/internal/project/session.go) #4, Pattern 1) andverification/tla/FINDINGS.md(Fix api.Session snapshot use-after-deref and post-close leak (tsc/internal/api/session.go) #3) on branchtla-concurrency-verification(3421f17). - Existing failing spec and reproducer:
verification/tla/specs/SessionGlobalDiag/SessionGlobalDiag.tla(NoLostGlobalDiagnostics, 7-state counterexample)verification/tla/reproducers/project_repro_test.go(TestReproSessionLostGlobalDiagnosticsNotification, fails deterministically in 0.00s)
What to build
Fix the coalescing latch between Session.EnqueuePublishGlobalDiagnostics() and Session.publishGlobalDiagnostics() in tsc/internal/project/session.go so global diagnostics accumulated in any project's checkerPool while a previous publish task is scanning or sending PublishDiagnostics RPC are never dropped.
Required observable behavior:
- Multiple rapid calls to
EnqueuePublishGlobalDiagnostics()before the background task runs still coalesce into one publish pass. - If new global diagnostics arrive after
TakeNewGlobalDiagnostics()/GetProjectDiagnostics()and beforepublishGlobalDiagnosticsexits, a follow-up publish pass runs so the client eventually receives the latest global diagnostics. - At quiescence (no pending/running publish task), no configured project has
globalDiagChanged == trueleft unpublished, andglobalDiagPublishPendingdoes not get stucktrueifbackgroundQueue.Enqueuedrops a task on cancellation/close.
Decisions and constraints
- Follow all shared constraints in End-to-end red-to-green TLA+ fixes and upstream PR prep for flagship TypeScript 7 concurrency bugs #1 (clean fix branch from
mainate0fce98, no unsolicited PR againstmicrosoft/TypeScript, officialtla2tools.jaronly). - Do not hold
snapshotMuorcheckerPool.muacrosss.client.PublishDiagnosticsRPC calls. - Leave exact latch design (e.g., clear before scan + re-check, or a 3-state
idle / running / rerunstate machine) to the implementer, provided the green TLA+ model verifies both safety (NoLostGlobalDiagnostics) and absence of stuck-flag states.
Acceptance criteria
- Green TLA+ model: Add a fixed configuration (and updated spec transitions on
tla-concurrency-verification) checked bytla2tools.jar/ TLC that verifiesNoLostGlobalDiagnostics(including across concurrent RPC delivery and background cancellation) with 0 errors across all reachable states, wired intoverification/tla/scripts/run-tlc.sh. - Go fix and regression test: On a clean fix branch off
main(e0fce98), fixtsc/internal/project/session.goand add a deterministic in-package regression test proving that global diagnostics arriving whilePublishDiagnosticsRPC End-to-end red-to-green TLA+ fixes and upstream PR prep for flagship TypeScript 7 concurrency bugs #1 is in flight trigger a second publish call and leaveglobalDiagChanged == falseat quiescence. - Verification:
go -C ./tsc test -race -timeout=120s ./internal/project/...passes, andnpx hereby check:formatandnpx hereby lintpass for touched files. - Upstream preparation: Include a concise ready-to-file upstream bug report and PR description (referencing the fix branch on
robertpenner/TypeScript) in an issue comment when done.
Dependencies
None. Independently executable.
Starting references
tsc/internal/project/session.go:196-200,1998-2024(globalDiagPublishPending,EnqueuePublishGlobalDiagnostics,publishGlobalDiagnostics)tsc/internal/project/checkerpool.go:405-425(mergeGlobalDiagnosticsFromCheckerLocked,TakeNewGlobalDiagnostics)tsc/internal/project/background/queue.goverification/tla/specs/SessionGlobalDiag/SessionGlobalDiag.tlaverification/tla/reproducers/project_repro_test.go
Activity
robertpenner commentedon Nov 26, 2026
Just-in-Time Agent Brief (#4)
e0fce98(main),3421f17(tla-concurrency-verification).tsc/internal/project/session.go:2004-2010usesglobalDiagPublishPending atomic.Boolcleared viadefer s.globalDiagPublishPending.Store(false)on exit ofpublishGlobalDiagnostics. Any new global diagnostic merged intocheckerPoolafterTakeNewGlobalDiagnostics()/GetProjectDiagnostics()and beforepublishGlobalDiagnosticsreturns seesCompareAndSwap(false, true) == falseand is dropped.deferwith a 3-state atomic latch (idle = 0,running = 1,rerun = 2):EnqueuePublishGlobalDiagnosticsreturns early ifs.backgroundContext().Err() != nil; otherwise transitionsidle -> running(enqueueing one background task) orrunning -> rerun(leavingrerununchanged).publishGlobalDiagnosticsloops: runs one publish pass, then attemptsCAS(running, idle)to exit; if state wasrerun, resets torunning(oridleifctx.Err() != nil) and repeats.PublishDiagnosticsRPC delivery), and (3) clean quiescent state.SessionGlobalDiag_Fixed.cfg, 0 errors onNoLostGlobalDiagnostics,NoOutOfOrderPublish,NoConcurrentPublishers), TDD regression test undergo -C ./tsc test -race ./internal/project/..., andnpx hereby check:format/lint.robertpenner commentedon Nov 26, 2026
Slice Complete: Red-to-Green Verified (#4)
fix/session-global-diag-push(8f416ad, based onmaine0fce98)robertpenner/TypeScript(Closes #4)SessionGlobalDiag_Fixed.cfgpassed with 0 errors (72 distinct states, 98 generated) onNoLostGlobalDiagnostics,NoOutOfOrderPublish, andEventuallyAllPublished.go -C ./tsc test -race -count=1 ./internal/project/...passed (5/5 packages, includingTestSessionEnqueuePublishGlobalDiagnosticsDuringInFlightPublish);gofmtandgo vetclean.Draft Upstream Bug Report (for
microsoft/TypeScript)Title:
project.Session.publishGlobalDiagnosticsdrops global diagnostic updates arriving while a publish RPC is in flightDescription:
In
tsc/internal/project/session.go,publishGlobalDiagnosticsclearsglobalDiagPublishPendingviadefer s.globalDiagPublishPending.Store(false)on function return. If another diagnostics checker merges new global diagnostics intocheckerPoolafterTakeNewGlobalDiagnostics()/GetProjectDiagnostics()and whiles.client.PublishDiagnosticsis in flight,EnqueuePublishGlobalDiagnostics()callsCompareAndSwap(false, true), observestrue, and drops the enqueue. When the first publish returns,deferclears the flag, leavingcheckerPool.globalDiagChanged == trueunpublished until an unrelated future trigger.Replacing the single boolean with a three-state atomic latch (
idle/running/rerun) preserves coalescing, prevents concurrent out-of-orderPublishDiagnosticsRPCs, and guarantees follow-up passes drain updates produced during an active publish.(Clean fix branch ready at
robertpenner/TypeScript:fix/session-global-diag-pushonce an upstream issue is milestoned.)test(verification): verify SessionGlobalDiag green TLA+ model (#4)