REGRESSION(313609@main): visionOS debug uid 1 == main thread invariant
WTF's Thread and WorkQueue classes share one monotonically-increasing UID namespace. The main work queue is hard-coded with mainThreadID == 1; sequence-safety assertions across IDB, DOMCacheEngine, and NativePromise resolution depend on the invariant that the main thread's Thread::uid() is also 1. Before this fix, UID assignment was purely positional — whichever thread constructed its Thread object first won uid 1.
Source/WTF/wtf/Threading.h
Source/WTF/wtf/posix/ThreadingPOSIX.cpp
Source/WTF/wtf/MainThread.cpp
On visionOS debug, the RefCountDebugger path inside CStringBuffer's constructor called Thread::currentSingleton() from the libxpc bootstrap queue before initializeMainThread() ran — stealing uid 1 and pushing the real main thread to uid 2. The fix introduces an IsMain enum, uses pthread_main_np() on Cocoa to detect the main thread reliably, and adds a RELEASE_ASSERT enforcing the invariant.
Significance
The uid 1 == main thread invariant is load-bearing across WebKit's entire concurrency model; a stolen uid silently misfires RELEASE_ASSERTs in unrelated code paths, making crashes appear in the wrong place and masking real threading bugs.
Audit directions
The IsMain::Unknown path on Windows and generic POSIX still relies on startup ordering — any future code that constructs a Thread on a non-main thread before initializeMainThread() runs misassigns uid 1 and the RELEASE_ASSERT fires at startup. The ScriptExecutionContextDispatcher refactor replaces a magic-number uid comparison with isMainThread(); on platforms with USE(WEB_THREAD), isMainThread() returns true on both the UI thread and the WebKit WebThread — the same ambiguity the Thread constructor explicitly avoids via pthread_main_np(). Audit whether the new isCurrent() logic handles the WebThread identity correctly under all dispatch scenarios.