Skip to content

fix(desktop): project embedding into the compacted backfill CTE - #11885

Merged
Git-on-my-level merged 1 commit into
mainfrom
fix/desktop-swift-suite-flakes
Aug 20, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
fix/desktop-swift-suite-flakes

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Aug 19, 2026 •

Copy link
Copy Markdown
Member

Summary

getCompactedScreenshotsMissingEmbeddings filtered its CTE on embedding IS NULL
while the CTE projected only id, ocrText, appName, windowTitle, bucketRank.
SQLite resolves column references at prepare time, so the statement failed with
no such column: embedding on every call, for every user, independent of data.

The throw propagates out of OCREmbeddingService.runBackfill, so no account on the
lossless-compaction path has ever backfilled a screen vector — paid-tier screen
search was silently inert for those users.

Failure-Class: new

Evidence

Reproduced deterministically in isolation, red before and green after the change:

xcrun swift test --package-path Desktop --filter 'ScreenshotEmbeddingBackfillRecoveryTests/'

The existing regression test already covered this. It read as a CI flake because the
desktop Swift phase only runs when a PR touches desktop/; the intervening green
main runs had skipped the suite, not passed it.

The defect reached main because #11865 merged at 18:40Z with both desktop Swift
checks red. main has no required status checks.

Scope

Ranking still precedes the filter, so idempotency is unchanged: a bucket's winner is
chosen among all its rows and drops out once it has an embedding. The two sibling CTEs
(the EXISTS variant in this file, and ScreenActivitySyncService) were audited and
each already projects every column its outer query references.

🤖 Generated with Claude Code

Review in cubic

`getCompactedScreenshotsMissingEmbeddings` filtered `ranked` on `embedding
IS NULL`, but the CTE selected only id, ocrText, appName, windowTitle and
bucketRank. SQLite resolves that at prepare time, so the statement failed
with `no such column: embedding` on every call for every user, independent
of whether any bucket had a winner. The throw propagates out of
`OCREmbeddingService.runBackfill`, so no account on the lossless-compaction
path has ever backfilled a screen vector.

Reproduced deterministically in isolation before the change and green after:

  xcrun swift test --package-path Desktop \
    --filter 'ScreenshotEmbeddingBackfillRecoveryTests/'

The existing regression test already covered this. It read as a CI flake
because the desktop Swift phase only runs when a PR touches `desktop/`, so
the intervening green `main` runs had skipped the suite rather than passed
it. #11865 merged at 18:40Z with both desktop Swift checks red, which is
how the defect reached `main` at all.

Ranking still precedes the filter, preserving idempotency: a bucket's
winner is chosen among all its rows and drops out once it has an embedding.
The two sibling CTEs in this file and in ScreenActivitySyncService were
audited and each already projects every column its outer query references.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 87b47f4 into main Aug 20, 2026
32 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/desktop-swift-suite-flakes branch August 20, 2026 04:54
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