Skip to content

feat: notes v2, lossless screen sync, and paid-tier screen vectors — enabled in beta only - #11865

Merged
Git-on-my-level merged 6 commits into
mainfrom
agent/m4-air/beta-enable-notes-v2
Aug 19, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
agent/m4-air/beta-enable-notes-v2

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Turns the conversation notes v2 rollout on for the beta ring only. Production stays dark.

Why the dev environment is the beta lever

Beta is a deployment, not a cohort. The mobile mobile_beta profile and the beta desktop bundle com.omi.computer-macos.beta are both pinned to api.omiapi.com — the dev backend — while authenticating against the production Firebase project, and dev's data_plane_project is based-hardware. Setting the rollout flags in the dev runtime environment therefore reaches beta users, on their real data, without reaching production users.

This is also the only mechanism available: _flag_enabled reads process environment, so the backend has no per-user flag evaluation.

The gap this closes

#11834 declared the three CONVERSATION_* flags on backend-listen only. process_conversation runs in two services — backend-listen finalizes a live conversation, and the Cloud Run backend service runs it inline for POST /v1/conversations/{id}/reprocess. With the flags on one host, os.getenv falls through to the False default on the other, so a meeting would summarize under v2 and then regenerate under the legacy pipeline. Both return a well-formed summary, so the discrepancy reads as model nondeterminism rather than as missing configuration.

Declared false in _base.yaml (no production behaviour change) and true in the dev overlay.

The deploy validator already enforces this. Adding the flags to the Cloud Run service made three existing validator tests fail, because their Cloud Run state fixtures did not carry the variables — the validator correctly reporting that a deploy would omit them. The fixtures now carry them, scoped to the backend service.

The desktop half

The two client features are gated by PostHog, which targets users and cannot express "the bundle pointed at the dev backend". A cohort wide enough to include beta would also match stable users, whose backend has the consuming flags off — they would be prompted for calendar access to produce uploads nothing reads.

So beta defaults on and keeps a kill-switch flag, letting a bad build be disarmed without shipping a new one; stable still requires its own positive flag. The decision is a pure function of its inputs, so it is exercised without a bundle, a process environment, or a PostHog client.

Resulting state

dev (beta) prod
CONVERSATION_NOTES_V2_ENABLED true false
CONVERSATION_CALENDAR_CONTEXT_READ_ENABLED true false
CONVERSATION_OCR_CONTEXT_ENABLED true false

Asserted on both summary-pipeline services, and the Helm values file is checked against the composed manifest, since Helm reads the values file rather than runtime_env.yaml.

Verification

  • 89 backend tests: test_backend_runtime_env_validator.py (85) and the new test_conversation_notes_v2_beta_rollout.py (4).
  • A real swift build of the macOS SwiftPM package — build complete, not a typecheck.
  • 19 Swift tests via swift test, including the 6 new gating cases.

Not verified: no deploy was run, so the dev rollout is asserted from the composed manifest and chart values rather than from a live service. Prod values are asserted unchanged.


Part 2 — lossless screen-activity sync

Previously #11868, folded in here so beta gets one merge rather than two.

Screen-activity sync silently discards ~99% of what it captures. This makes it lossless, and cheaper per delivered row than the broken version is per delivered row.

The defect

ScreenActivitySyncService selected WHERE id > ? AND embedding IS NOT NULL and advanced a monotonic cursor past everything it shipped. Embeddings are computed asynchronously after insert, so any row whose vector had not landed when the sweep passed was skipped permanently — not retried, not queued, not reported.

Measured on a live store: 705 of 26,822 rows over 30 days ever left the device. It reads as a working sync, because rows keep arriving.

Three further mechanisms independently denied a row its embedding, so repairing the cursor alone recovers little:

  • cross-batch content-hash dedup returned early without ever queueing the row,
  • gated or failed embedding batches were dropped rather than requeued,
  • the backfill that comments describe as the safety net had been stuck completed=1, processedCount=0 since 2026-04-16.

What changed

Durable per-row delivery state (pending → textSynced → fullySynced, plus compacted) on an indexed column, replacing the cursor. A row that was not ready when a sweep passed is picked up by a later sweep. OCR-bearing rows ship without waiting for a vector; the vector attaches afterwards. Migration is safe on a populated store and starts existing rows pending, so history is recoverable.

Bucket-aligned eligibility. Compaction keeps the longest OCR text per (app, window, 5-min bucket). The original implementation tested each row's own timestamp against now - slack, which makes eligibility slide: the early rows of a bucket become ready while its later rows do not, so a bucket is ranked more than once and ships more than one winner. Replayed over 7,346 real OCR-bearing rows, the sliding form ships 5,517 where bucket-aligned ranking ships 3,842 — 44% more than the design intends, which is most of the compaction saving. The same alignment now applies to the embedding flush and the backfill queries, so all three agree on what a bucket is.

A closed bucket's winner waits up to 15 minutes for its embedding before shipping text-only. Without that wait almost every row shipped twice: sync sweeps at 5 minutes, and the embedding flush also buffers to 5 minutes and then batches on a 60s timer, so the vector reliably lost the race. The second push wrote a byte-identical Firestore document and rewrote all of its index entries for no data change. Losslessness is preserved — the grace period is a delay, not a gate.

ocrText, windowTitle, deviceName, clientDeviceId exempted from Firestore single-field indexing. Firestore auto-indexes every field in both directions, and nothing queries these — ocrText is only ever read back, never filtered or ordered on; semantic search goes through Pinecone. Measured per document, index bytes were ~75% of this collection's storage and the ocrText index alone was the majority of it. The one composite index is unaffected.

Bounded deferred buffer. Requeueing gated batches fixes real data loss but restores an unbounded buffer for a user whose backend gates every call. Oldest deferred items are shed first.

Re-armed backfill for the stranded history, capped per launch so it cannot stampede.

The timestamp check, which came back negative

All 26,797 measured local rows already use the space-separated %Y-%m-%d %H:%M:%S.%f form that the backend's lexicographic range filters assume; zero use ISO T/Z. So no production date-range query over screen activity is currently returning wrong results.

Two latent paths are closed anyway: the client had a live ISO fallback, and upsert_screen_activity_vectors computed the Pinecone timestamp for a naive string in the process timezone rather than UTC (inert wherever the container runs UTC, wrong everywhere else). Both now canonicalize at the boundary.

Cost

Independently modelled from the live store rather than asserted. Per user per month, at this store's capture volume:

rows delivered month 1 month 12
today (broken) 705 $0.11 $0.14
this change 3,842 $0.36 $0.54
lossless without compaction 7,213 $1.09 $1.48

Rows delivered go up 5.3x and spend goes up about 5x. That increase is real and permanent — it is the cost of not throwing the data away. The dominant term is per-row flow (embedding + vector writes), which does not compound; permanent storage accrual is ~$0.017/user/month.

This store is a heavy dogfooder (26.8k captures over 19 active days), so treat per-user figures as an upper bound. Unit prices are list prices, not billed rates.

Not addressed here, deliberately: truncating OCR to 1,000 chars before embedding would cut the embedding bill by more than half, and Firestore already stores only the first 1,000 chars. But the embedding is what makes text searchable, and nothing has measured retrieval quality past that point — so it is a product call, not a cleanup, and it is left out.

There is still no server-side retention of any kind. The only deletion path is account deletion. Volume is unbounded and losslessness makes that more pressing, not less. Out of scope here; it needs its own decision.

Tiering: cloud vectors are a paid desktop capability

Second commit. Free-tier desktop users sync their rows without vectors — they keep cloud screen history readable by time and app, and they keep on-device semantic search, which reads embeddings from the local store and never touches Pinecone. The OCR text is still stored, so vectors can be backfilled on upgrade: the gate defers the cost rather than destroying the ability to recover.

Gated on the desktop access tier, not is_paid_plan — screen activity is a desktop capability and a mobile-only paid plan did not buy it. BYOK does not grant it either: BYOK covers the user's own LLM keys, but the vector store is ours. Enforced server-side at ingest, since the client cannot be trusted about its own entitlement. Fails open on a lookup error, matching should_defer_desktop_processing.

Correction to the cost table above. The Gemini embedding spend ($0.32/user/month) is not attributable to sync. Embeddings are computed for local Rewind search on every capture regardless of whether the row ever syncs, through our own proxy — sync merely piggybacks on them. So this gate saves the Pinecone half ($0.20/user/month), not the embedding half, and the "this change" row above overstates what tiering can recover. Tiering the embedding as well would mean tiering on-device search; that is a separate product decision and is not made here.

Verification

  • swift build of the macOS package — a real build, not a typecheck.
  • 9 Swift tests: migration on a populated store, a row unready at sweep time delivered later, an open bucket shipping nothing, a closed bucket shipping exactly one winner and never shipping again, the embedding wait and its expiry, compaction keeping the longest text, and gated/failed requeue.
  • 8 backend tests covering timestamp canonicalization at ingest and the Pinecone UTC fix.

Not verified: no deploy was run; no production Firestore sample was read (network and credentials unavailable); the Pinecone index configuration is not in the repo, so its storage class is unconfirmed.


Part 3 — closing the beta gap between the two

Merging the two exposed a gap. The lossless-sync flag was PostHog-only for every production-family bundle, so beta — the channel it exists to be exercised on — would have shipped it dark while the rest of the rollout was live there.

The gating helper is renamed BetaDogfoodRollout and now backs all three client features: system calendar context, on-device meeting identity, and lossless screen sync. Beta is on unless killed; stable still requires its own positive PostHog flag; dev bundles keep their environment override. A test asserts all three share one decision and that each kill switch is derivable from its flag name, so a feature added past this helper fails the suite instead of going silently missing on beta.

What is live where, after this merges

beta prod
CONVERSATION_NOTES_V2_ENABLED (+ calendar, OCR reads) on off
system_calendar_meeting_context on (kill switch) PostHog flag
on_device_meeting_identity on (kill switch) PostHog flag
screen_activity_lossless_sync on (kill switch) PostHog flag
Firestore field-index exemptions on on
Timestamp canonicalization on on
Cloud screen vectors gated to paid desktop on on

The last three are not flagged: two are corrections with no behaviour change to gate, and the vector gate is a cost boundary that should not differ by environment.

Combined verification

  • swift build of the macOS package, and 29 Swift tests.
  • 109 backend tests across five suites.

Not verified: no deploy was run; no production Firestore sample; the Pinecone index configuration is not in the repo.

One deferred definition

The failure-class protocol admits exactly one added class definition per PR, and consolidating brings two. FC-high-water-cursor-skips-unready-row is kept — the cursor defect that silently discarded 99% of captured screen rows.

FC-rollout-flag-absent-from-a-cohost-of-its-code-path is deferred to its own PR, not dropped. Its guard ships here regardless: test_conversation_notes_v2_beta_rollout.py still asserts that backend-listen and the Cloud Run backend can never disagree on a summary rollout flag, which is the behaviour the class protects. Only the prose definition moves.

Product invariants affected

  • INV-AUTH-1 — touched only by adding one migration to RewindDatabase's ledger. Ownership is unchanged: the migration registers after every existing component migration and runs inside the pool the owner transition already configures. Embedding writes keep taking an owner-bound LocalMutationAuthorization lease, and the requeue paths still check generation == ownerGeneration before returning items to the buffer, so a batch spanning a retarget is dropped rather than seeding the next owner's buffer with the previous owner's rowids.

Failure-Class: new

Line-Count-Exception: desktop/macos/Desktop/Sources/Rewind/Core/RewindDatabase.swift | 3450 -> 3470 | the schema migration and its callable boundary belong with the other migrations in the ledger; splitting the file to add one column would separate this migration from the ones it must stay ordered after
Line-Count-Exception: backend/utils/subscription.py | 1491 -> 1535 | the entitlement helper belongs beside should_defer_desktop_processing, whose tier semantics and fail-open contract it deliberately mirrors; splitting it out would separate two gates that must stay consistent

Git-on-my-level and others added 6 commits August 19, 2026 12:38
Beta is a deployment, not a cohort. The `mobile_beta` profile and the beta desktop
bundle are both pinned to the dev backend (`api.omiapi.com`) while authenticating
against the production Firebase project, and dev's `data_plane_project` is
`based-hardware`. Setting the rollout flags in the dev runtime environment therefore
reaches beta users on their real data without reaching production users, which is the
only mechanism available: `_flag_enabled` reads process environment, so the backend has
no per-user flag evaluation.

Declares the flags on the Cloud Run `backend` service as well, which the merged PR
missed. `process_conversation` runs in two services — backend-listen finalizes a live
conversation, and Cloud Run runs it inline for POST /v1/conversations/{id}/reprocess.
With the flags on backend-listen alone, `os.getenv` fell through to the False default on
the reprocess host, so a meeting would have summarized under v2 and then regenerated
under the legacy pipeline. Both paths return a well-formed summary, so the discrepancy
would have read as model nondeterminism rather than as missing configuration. Declared
false in `_base.yaml` (no production behaviour change) and true in the dev overlay.

The deploy validator already enforces this: adding the flags to the Cloud Run service
made three existing validator tests fail because their fixtures did not carry them,
which is the validator correctly reporting that a deploy would omit the variables. The
fixtures now carry them, scoped to the `backend` service only.

The desktop half is gated by PostHog, which targets users and cannot express "the bundle
pointed at the dev backend". A cohort wide enough to include beta would also match stable
users, whose backend has the consuming flags off — they would be prompted for calendar
access to produce uploads nothing reads. So beta defaults on and keeps a kill-switch flag
so a bad build can be disarmed without shipping a new one; stable still requires its own
positive flag. The decision is a pure function of its inputs so it is exercised without a
bundle, a process environment, or a PostHog client.

Verified: 89 backend tests (validator + the new rollout contract), a real `swift build`
of the macOS package, and 19 Swift tests including the new gating suite. Prod values are
asserted unchanged in both the composed manifest and the Helm values file, since Helm
reads the values file rather than runtime_env.yaml.

Failure-Class: new

Co-Authored-By: Claude Opus 5 <[email protected]>
…ill never revisit

ScreenActivitySyncService selected `WHERE id > ? AND embedding IS NOT NULL` and
advanced a monotonic cursor past everything it shipped. Embeddings are computed
asynchronously after insert, so any row whose vector had not landed when the sweep
passed was skipped permanently. Measured on a live store: 705 of 26,822 rows over 30
days ever left the device. It reads as a working sync because rows keep arriving.

Three further mechanisms independently denied a row its embedding, so repairing the
cursor alone recovers little: cross-batch content-hash dedup returned early without
queueing, gated or failed batches were dropped rather than requeued, and the backfill
described in comments as the safety net had been stuck completed=1/processedCount=0
since 2026-04-16.

Delivery is now durable per-row state (pending, textSynced, fullySynced, compacted) on
an indexed column, so a row that was not ready when a sweep passed is picked up later.
OCR-bearing rows ship without waiting for a vector; the vector attaches afterwards.

Eligibility is evaluated per *closed* five-minute bucket, not per row. Comparing each
row's own timestamp against `now - slack` makes eligibility slide: the early rows of a
bucket become ready while its later rows do not, so the bucket is ranked more than once
and ships more than one winner. Replayed over 7,346 real OCR-bearing rows, the sliding
form ships 5,517 where bucket-aligned ranking ships 3,842 — 44% more than intended,
which is most of the compaction saving. The same alignment applies to the embedding
flush and to the backfill queries, so all three agree on what a bucket is.

A closed bucket's winner now waits up to 15 minutes for its embedding before shipping
text-only. Without that wait almost every row shipped twice, because sync sweeps at
5 minutes while the embedding flush also buffers to 5 minutes and then batches on a 60s
timer. The second push wrote a byte-identical Firestore document and rewrote all of its
index entries for no data change. Losslessness is preserved: the grace period is a
delay, not a gate — a row whose vector never arrives still ships.

Exempts ocrText, windowTitle, deviceName, and clientDeviceId from Firestore
single-field indexing. Firestore auto-indexes every field in both directions, and
nothing queries these — ocrText is only ever read back, never filtered or ordered on.
Measured per document, index bytes were 75% of this collection's storage and the
ocrText index alone was the majority of it. The one composite index is unaffected.

The deferred embedding buffer is bounded. Requeueing gated batches fixes real data loss,
but restores an unbounded buffer for a user whose backend gates every call; oldest
deferred items are shed first.

Timestamps are canonicalized at both the client and the ingest boundary. All 26,797
measured local rows already use the space-separated form the backend's lexicographic
range filters assume, and zero use ISO `T`/`Z`, so no production query is currently
returning wrong results — but the client had a live ISO fallback path, and the Pinecone
timestamp for a naive string was computed in the process timezone rather than UTC.

Verified: `swift build` and 9 Swift tests covering migration on a populated store, a row
unready at sweep time, an open bucket shipping nothing, a closed bucket shipping exactly
one winner and never shipping again, the embedding wait, and gated/failed requeue; plus
8 backend tests. Not verified: no deploy, and the cost model rests on list prices.

Failure-Class: new

Co-Authored-By: Claude Opus 5 <[email protected]>
Screen rows are cheap; the vector is not. Embedding and storing a 3,072-dim vector
per delivered row is the large majority of what a synced screen row costs, and the
vector's only server-side purpose is semantic screen search.

Free-tier desktop users now sync their rows without vectors. They keep cloud screen
history readable by time and app, and they keep on-device semantic search, which reads
embeddings from the local store and never touches Pinecone. Because the OCR text is
still stored, vectors can be backfilled from it when a user upgrades — this gate defers
the cost rather than destroying the ability to recover.

Gated on the desktop access tier rather than `is_paid_plan`, because screen activity is
a desktop capability and a mobile-only paid plan did not buy it. BYOK does not grant it
either: BYOK means the user supplies their own LLM keys, but the vector store is ours,
and so is the cost being avoided.

Enforced server-side at ingest rather than on the client. The client cannot be trusted
to know its own entitlement, and gating there would also have to disable local embedding
to save anything, which would break on-device search for free users.

Fails OPEN on a lookup error, matching should_defer_desktop_processing: a Firestore blip
must never silently strip a paying user's screen search. The failure mode is a small
overspend, not a lost capability. Entitlement is cached for 5 minutes because sync runs
on a 60s cadence.

One correction to this PR's cost framing. The Gemini embedding spend (~$0.32/user/month)
is NOT attributable to sync: embeddings are computed for local Rewind search on every
capture regardless of whether the row ever syncs, through our own proxy. So this gate
saves the Pinecone half (~$0.20/user/month) and not the embedding half. Tiering the
embedding too would mean tiering on-device search, which is a separate product decision
and is not made here.

Verified: 11 backend tests, including that an unentitled user still stores the row and
its text, that an entitled user still gets vectors, and that a lookup failure fails open.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
…s-screen-sync-79a585be75' into agent/m4-air/beta-enable-notes-v2
…od decision

Merging the lossless sync work in exposed a gap: its flag was PostHog-only for every
production-family bundle, so beta — the channel it exists to be exercised on — would
have shipped it dark while the rest of the rollout was live there.

The gating helper is no longer meeting-identity specific, so it is renamed
BetaDogfoodRollout and now backs all three features: system calendar context, on-device
meeting identity, and lossless screen sync. Beta is on unless killed; stable still
requires its own positive PostHog flag; named/dev bundles keep their environment
override, including lossless sync's existing default-on-for-dev semantics.

A test asserts all three share one decision and that every kill switch is derivable from
its flag name, so a feature added past this helper fails the suite rather than going
silently missing on beta.

Verified: swift build, 29 Swift tests, 109 backend tests.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
The failure-class protocol admits exactly one added class definition per PR, and
consolidating the beta rollout with the lossless sync work brings two. The substantive
one is kept: FC-high-water-cursor-skips-unready-row, the cursor defect that silently
discarded 99% of captured screen rows.

FC-rollout-flag-absent-from-a-cohost-of-its-code-path is deferred, not dropped. Its
guard ships here regardless — test_conversation_notes_v2_beta_rollout.py still asserts
that backend-listen and the Cloud Run backend can never disagree on a summary rollout
flag, which is the behaviour the class exists to protect. Only the prose definition
moves to a follow-up; the definition text is parked in the knowledge base so it lands
verbatim rather than being rewritten from memory.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level Git-on-my-level changed the title feat(deploy): enable the conversation notes v2 rollout in beta only feat: notes v2, lossless screen sync, and paid-tier screen vectors — enabled in beta only Aug 19, 2026
@Git-on-my-level
Git-on-my-level merged commit 091a65b into main Aug 19, 2026
37 of 38 checks passed
@Git-on-my-level
Git-on-my-level deleted the agent/m4-air/beta-enable-notes-v2 branch August 19, 2026 18:40
Git-on-my-level added a commit that referenced this pull request Aug 19, 2026
Lands the failure-class definition that
[#11865](#11865) could not
carry.

The protocol admits exactly one added class definition per PR. #11865
consolidated two branches, so the screen-activity cursor class took the
slot and this one was deferred.

**The guard already shipped.**
`test_conversation_notes_v2_beta_rollout.py` asserts that
`backend-listen` and the Cloud Run `backend` service can never disagree
on a summary rollout flag, in any environment, and that the deployed
Helm values file matches the composed manifest. Only the prose
definition was missing.

## The class

`process_conversation` runs in two services: backend-listen finalizes a
live conversation, and the Cloud Run backend runs it inline for `POST
/v1/conversations/{id}/reprocess`. The three `CONVERSATION_*` rollout
flags were originally declared on backend-listen alone, so `os.getenv`
fell through to the `False` default on the reprocess host.

Enabling the rollout would then have produced a v2 note when a meeting
ended and a legacy note when the user pressed regenerate on that same
conversation. Both paths return a well-formed summary, so the
discrepancy reads as model nondeterminism rather than as missing
configuration — which is what makes it worth naming.

The definition text is unchanged from when it was written, so it reads
as it was reasoned rather than reconstructed. Evidence cites both the PR
that introduced the single-host declaration (#11834) and the one that
closed it (#11865).

Failure-Class: new


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/11870?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
Archit-lal pushed a commit to Archit-lal/omi that referenced this pull request Aug 19, 2026
BasedHardware#11865 could not carry this definition: the failure-class protocol admits exactly
one added class per PR, and the screen-activity cursor class took the slot. The guard
shipped there regardless — test_conversation_notes_v2_beta_rollout.py asserts that
backend-listen and the Cloud Run backend can never disagree on a summary rollout flag,
in any environment, and that the deployed Helm values match the composed manifest.

This is the definition text, unchanged from when it was written, so the class reads as
it was reasoned rather than reconstructed. Evidence cites both the PR that introduced
the single-host declaration and the one that closed it.

Failure-Class: new

Co-Authored-By: Claude Opus 5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Aug 20, 2026
`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 added a commit that referenced this pull request Aug 20, 2026
… make field exemptions appliable (#11872)

* fix(backend): count explicit app selections, reject invalid ones, and make field exemptions appliable

Three follow-ups from the beta rollout, each validated before it was fixed. Two of my
three original claims held; the third was partly wrong and the report says so.

**Explicit app selections were never counted.** `record_app_usage` was skipped whenever
`is_reprocess` was true, and client app selection goes through the reprocess route on
both Flutter and macOS — so the one interaction opt-in mode exists to measure produced
no usage history. Attribution is now typed rather than inferred from a boolean:
automatic processing and a successfully executed explicit selection are recorded; plain
regenerate, sync reprocessing, and lazy enrichment of deferred desktop conversations are
not. My brief claimed lazy enrichment reached this through `is_reprocess=True`; it does
not — it passes `is_reprocess=False` — so it is now marked non-user explicitly instead
of relying on a flag that never distinguished it.

**An invalid app_id silently produced a successful no-app response.** Under opt-in that
is worse than before, because there is no default app to fall back on: the caller asked
for something specific, got a 200, and received the first-party note. Selection is now
validated before processing mutates anything — 404 unknown, 403 not available to this
user, 400 cannot summarize, 409 disabled or not enabled — and `_trigger_apps` raises if
it is ever handed an unvalidated id, so the two cannot drift. Both clients already
enable an app before selecting it (macOS does so with a comment naming this exact
footgun), so the enablement check matches what they do rather than restricting them.

**Firestore field exemptions were declared but nothing applied them.** The reconciler
reads only `indexes` and shells out only to `gcloud firestore indexes composite`, so the
`fieldOverrides` #11865 added saved nothing. Exempting a field deletes existing
single-field indexes, which is precisely the destructive class the create-only
reconciler refuses by design, and it targets the production data plane. So automatic
reconciliation stays create-only and a separate manual operation owns the deletion:
prod-only, exact-confirmed, dispatched-SHA-verified, restricted to generated
`indexes: []` overrides. The automatic run now also fails visibly when exemptions are
declared but unapplied, so the gap cannot be implied-but-absent again.

Note the consequence: this workflow will fail on main until that manual operation is
run. That is the intended signal, not a regression.

Contracts regenerated for the new response codes; only the OpenAPI and TypeScript
projections changed.

Verified: 142 tests across six suites, run per-file. Not verified: no live Firestore
state was read and the exemptions are not applied; Swift was not compiled (the delegated
sandbox denied SwiftPM's nested sandbox-exec), though no Swift source changed.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>

* fix(backend): keep the apps chain out of the conversations router's import graph

CI caught a real regression, not a flake. Adding `database.apps` and `utils.apps` as
module-level imports broke test_conversation_search_date_validation (collection error)
and test_conversations_date_range_validation (9 errors), both deterministically.

Those suites load routers.conversations through the sanctioned isolation seam
(backend/docs/test_isolation.md) to test pure request validation, stubbing the heavy
chains the router otherwise pulls at import time. `utils.apps` reaches the memory and
social graph, so a module-level import forces every such suite to stub a graph it never
calls — and the next module added to that chain breaks them again.

The router already solved this once: it imports from `utils.apps` inside a function
around line 1510 for exactly this reason. The selection validator now follows that
precedent, with a comment saying why so it is not "tidied" back to the top later. Its
tests patch at the source modules rather than on the router, which is where the
functions actually live now.

Verified: the two suites CI failed now pass (23 and 9), the selection suite still passes
(8), and usage attribution, enrichment wiring, and the beta rollout contract are
unaffected (37, 10, 4). No other test patched these names on the router.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>

* Bound apt network calls in CI so a stalled mirror fails fast.

Two jobs on this PR failed by hanging, not by failing: `Linux package ·
helper smoke` rode out the full 6h GitHub Actions job ceiling, and
`Replay Harness Phase 0A Feasibility (advisory)` burned its entire 20m
budget. Both stopped producing output mid-`apt-get update` while fetching
package indices, and both surfaced only as an opaque cancellation.

Neither is caused by this branch. The Linux job has hung for exactly 6h
on several unrelated PRs and on main; the replay-harness job shares its
`Install Redis server` step verbatim with two sibling gauntlets that
passed in the same run. The common defect is that `apt-get update` has no
built-in fetch timeout and these steps set no `timeout-minutes`, so a
half-open connection to a mirror has nothing to stop it.

Bound both: `Acquire::Retries` plus explicit http/https timeouts so a
stalled mirror fails over in seconds, and `timeout-minutes` on the steps
(and on the previously uncapped `build-linux` job) as a backstop. This
does not make a mirror outage succeed -- it makes one fail in minutes
with a legible error instead of silently consuming the job.

Co-Authored-By: Claude Opus 5 <[email protected]>

* test(backend): pin bounded apt-get in hermetic gauntlet wiring

The previous commit bound apt network calls so a stalled mirror fails
fast, but the static wiring tests still required the unbounded
`sudo apt-get install --yes redis-server` form. That is a deterministic
contract miss, not a flake: both gauntlet jobs failed in the unit suite
for the same substring.

The contract now requires Acquire retries/timeouts, a 5-minute step
timeout, and that the unbounded install form is absent from the
workflow. Job slices are scoped to the named job so a later gauntlet
cannot satisfy the assertion.

Co-authored-by: David Zhang <[email protected]>

* test(backend): bind lazy-enrich persist seam even if the module is partial

CI failed test_lazy_enrichment_uses_non_user_usage_attribution with
AttributeError on the real file-backed proactive_engine module: a circular
import can leave that module in sys.modules without
persist_desktop_meeting_arrival_best_effort. monkeypatch.setattr then
raises before the route is exercised.

Patch the in-function import with create=True, and parametrize a partial
module so that missing-attribute case is the regression, not a flake.

Co-authored-by: David Zhang <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Co-authored-by: Cursor Agent <[email protected]>
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