Repository navigation
fix(platform): close eight low-severity reliability leaks and races - #3191
Merged
Merged
Conversation
Squash of the wt-3 batch for rebase onto main; the PR body carries the per-finding record.
getOrCreateProjectFolder looked the folder up, then created it; two concurrent saves into a fresh folder (the project-text panel, two syncs) could both miss the lookup, and the loser's create refused with FOLDER_NAME_TAKEN — one of three concurrent project-text saves answered 400 in the integration check while the documents themselves converged on one row. The loser now re-reads the winner's folder and files into it.
larryro
force-pushed
the
fix/low-reliability-leaks-races
branch
from
September 4, 2026 04:00
3ac4150 to
5d267e2
Compare
larryro
marked this pull request as ready for review
September 4, 2026 04:00
This was referenced Oct 2, 2026
Closed
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.
Summary
Eight verified low-severity reliability defects (leaks, races, silent starvation) from the backend
deep-review triage, fixed with the invariant encoded where it belongs (schema or transaction), each
locked by a red-on-base regression test; one finding verified as already fixed.
Per-finding outcome
0067intents recorded the blob but the mint-path sweep dropped only the expired row (same in the REST twin).sweepUploadIntents(files/upload-intents.ts) now reclaims the blob of an intent that expired unconsumed and unvouched-for, then the row — on both ledgers;ownsUploadedBlobstampsbound_at_ms(0073) because the document multi-bind and outbound-mail-attachment lanes prove ownership without consuming (an outbound attachment lives only as astorageIdin message metadata, so "unconsumed" is not "unbound"). File-backed refs are excluded by anEXISTSguard; a failed delete keeps the row for the next sweep.completedindexing(finalizeVideoLinkFile); a lost CAS rolls back and reaps the blob. Mirror race closed too:cancelVideoLinkis a CAS on the state the user saw (advances with an in-flight job, leaves a settled one alone).runTaskAgentWatchdogcallssessionCancelExec(run.sessionId, run.execId)(best-effort) after winning the settle and before cancelling the op row — the in-chain deadline cut's seam.0072: partial unique index(org_id, resource_type, resource_id) WHERE resource_type = 'connector_operation' AND status = 'pending'(existing dup pendings closed the review lane's way:rejected+metadata.supersededBy); the gate insertsON CONFLICT … DO NOTHINGand the loser re-reads the winner's record.runSyncScanWith(OneDrive + Google Drive) is a keyset walk in id order (the#3167trigger-scanner idiom),pageSizeoption for tests.deregisterDomainraces concurrent registration without a transactionregisterDomain,registerUrlList,deregisterDomaineach run as one transaction; removal takes thewebsitesrowFOR UPDATEfirst, so the "last member?" check can never run between a registration's two writes.0071: partial unique(org_id, external_item_id) WHERE external_item_id IS NOT NULL(existing newer duplicates detached from the key, old key kept inmetadata.dedupedExternalItemId; the redundant plain index dropped).upsertAgentDocument,ensureProjectTextDocumentand the sync engine'screateDocumentinsertON CONFLICT … DO NOTHINGand refresh the winner's row on a lost race; project-text now brings a trashed twin back in place instead of parking a duplicate key.created_by IS NULLarm (NULL <> ALL(...)is NULL, so creator-less synced documents never expired under any hold).#3164(0f5f024da): every write routes throughemitBellHint, which passesuserId; the outbox narrows onuser_id IS NULL OR user_id = $me.Tests
Unit (vitest
server, 8 files / 30 tests — 21 red on the base tree, every file red):watchdogs, onedrive scan, crawl tx shape, gate claim, agent-write claim, retention SQL filter,
upload-intent stamp + sweep, video finalizer CAS + cancel CAS.
Integration (
backend/integration-check.ts), 9 probes — abandoned upload reclaimed while bound andvouched-for blobs survive (both ledgers, real MinIO); crawl removal racing registration ×8 rounds;
finalizer never overwrites a cancel + reaps the orphan blob; concurrent gate evaluations share one
card; concurrent agent upserts converge on one row; project-text concurrent saves + trashed twin
comes back; 1001 held trashed docs do not starve the unheld one; 1001 sync configs all enqueued;
deadline watchdog cancels the exec (fake spawner records the call).
Verification
tsc --noEmit: 0 errors;oxlint --type-awareon touched files: cleanbackend:integration(throwaway tale-db + MinIO, fresh per run): branch 392/394,base + probes 383/394 (the 11 base failures = the 9 new probes + the same 2 pre-existing failures the branch shows:
blob-ref authoritycompose andoutbound send lane, byte-identical on both trees)Cross-class discoveries (not in this batch)
#3187) enabled/disabled 2FA on the shared harness cookie;Better Auth's two-factor plugin deletes the calling session on both, so every later cookie-based
probe failed (
ERR,401) andcheckAutomationsdied on a404 Not Foundbody — onmaintoo.Fixed here in the harness (throwaway session for those calls).
blob-ref authority: outbound mail attaches only the sender's uploadsanswers403 FORBIDDENinstead of
403 attachment_not_ownedonmainas well — the conversation write gate from#3187now refuses before the ownership check; the probe's expectation needs a decision.
indexing(both at the same status) is not distinguished by thestatus CAS alone; a
storage_refguard would close it (the clone lane has no prior patch to key on).