Skip to content

fix(desktop): make Conversations repository authoritative - #9365

Closed
Git-on-my-level wants to merge 3 commits into
mainfrom
codex/conversation-repository
Closed

Git-on-my-level wants to merge 3 commits into
mainfrom
codex/conversation-repository

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Jul 9, 2026 •

Copy link
Copy Markdown
Member

Closes #8197

Summary

  • Add one account-scoped ConversationRepository as the authoritative desktop read/mutation boundary, with cache-first delivery, ID-based observation, and separate list/detail/transcript completeness and freshness.
  • Admit server responses by version, generation, and revocation state so stale searches, details, deletes, locks, or previous-account requests cannot resurrect or overwrite newer state.
  • Centralize durable title/star/folder mutations with coalescing, persisted pending intent, confirmation, retry, rollback, canonical-cache protection, and correct per-caller failure delivery.
  • Preserve sub-millisecond Firestore revisions through SQLite, serialize projection merges in one transaction, and fail account-pool changes closed.
  • Add lightweight versioned backend list/mutation contracts, real Firestore projections, minimal authorization reads, and an instrumented one-shot legacy endpoint fallback for rolling deploys.
  • Separate capture/finalization persistence from conversation read authority and migrate desktop UI consumers to the repository.
  • Add deterministic real-database, concurrency, rollback, account-isolation, and hermetic backend regression coverage.

Architecture direction

This is the intended 80/20 move toward the platonic model: one authoritative repository per signed-in account; the backend owns version truth; views observe IDs instead of carrying divergent object snapshots; mutation intent is durable and reconciled centrally; and tests exercise deterministic state transitions without live services or timing sleeps.

The remaining complexity is concentrated at the boundary—rollout compatibility, persistence, and reconciliation—instead of being repeated across views.

Product invariants affected

  • INV-AUTH-1 — account-scoped repository generations and cache guards preserve session isolation across sign-out/account changes.
  • INV-CHAT-1 — citation navigation now observes repository IDs while preserving the shared chat thread and citation-detail continuity.

Verification

  • Independent subagent review: approved; no actionable findings remain after final re-review
  • Desktop Swift suites: 183 suites passed in isolated shards
  • ConversationRepositoryTests: 38 passed
  • Real SQLite ConversationCacheStorageTests: 7 passed
  • Targeted backend lock/projection suites: 69 passed
  • Backend hermetic E2E: 103 passed, 3 skipped
  • Backend runtime-env validator: 21 passed
  • Desktop strict e2e-flow coverage: 17/17 changed Swift files covered
  • Import-purity, async-blocker, module-stub-pollution, route-policy, formatting, typecheck (0 errors), OpenAPI, generated-client, and pre-push checks passed
  • Named ad-hoc bundle omi-conversation-repository-ci built, launched, passed dependency audit, exposed a healthy automation bridge, and passed the tier-1 desktop harness (harness-smoke + navigation)

Manual-test limitation

The signed-in Conversations UI could not be exercised locally because the available Omi Dev profile contained no reusable auth session or Keychain credentials. The named bundle was exercised through its real automation bridge and tier-1 harness in signed-out mode; signed-in repository/UI behavior is covered by the deterministic repository and real-SQLite regression suites above.

Review in cubic

@mintlify

mintlify Bot commented Jul 9, 2026 •

Copy link
Copy Markdown

Preview deployment for your docs. Learn more about Mintlify Previews.

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Jul 9, 2026, 9:51 PM

💡 Tip: Enable Workflows to automatically generate PRs for you.

Preserve authoritative server revisions across Firestore and SQLite, serialize cache merges, isolate account-scoped pools, and make optimistic mutation drains deterministic. Add hermetic backend fakes and focused concurrency/rollback regressions.

Verification: 183 isolated Swift suites passed; 103 backend hermetic E2E passed (3 skipped); runtime env validator 21 passed; strict desktop flow coverage 17/17; tier-1 named-app harness passed; independent agent review approved.
Persisted conversation mutations use fractional ISO 8601 timestamps. Decode both the current fractional form and legacy non-fractional form so cache restoration works consistently across supported macOS runtimes.\n\nVerification:\n- xcrun swift test --package-path Desktop --filter 'ConversationCacheStorageTests/' (7 passed)\n- OMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh (183 suites passed)\n- independent agent review: approved with no remaining findings
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Closing as superseded by #9354, which is now the authoritative implementation for #8197. The useful remaining value from this branch is its deterministic failure corpus—especially account-switch/in-flight response isolation, overlapping mutation ordering, cache transaction interleavings, and revision precision. I’m extracting those against current main in a smaller follow-up; the reviewed source remains available at 560827e and the long-term durable outbox/change-feed work remains tracked by #9355.

@github-actions

Copy link
Copy Markdown
Contributor

Hey @Git-on-my-level 👋

Thank you so much for taking the time to contribute to Omi! We truly appreciate you putting in the effort to submit this pull request.

After careful review, we've decided not to merge this particular PR. Please don't take this personally — we genuinely try to merge as many contributions as possible, but sometimes we have to make tough calls based on:

  • Project standards — Ensuring consistency across the codebase
  • User needs — Making sure changes align with what our users need
  • Code best practices — Maintaining code quality and maintainability
  • Project direction — Keeping aligned with our product principles and locked invariants

Before your next PR, please skim:

  • PRODUCT.md — product north star
  • Product invariants — locked rules (shared chat, memory tiers, agent control plane, integrations, brand)

If this was declined for direction or taste, maintainers should cite an invariant ID or open a proposed one — ask if that citation is missing.

Your contribution is still valuable to us, and we'd love to see you contribute again in the future! If you'd like feedback on how to improve this PR or want to discuss alternative approaches, please don't hesitate to reach out.

Thank you for being part of the Omi community!

Git-on-my-level added a commit that referenced this pull request Jul 10, 2026
## Summary

- reject detail, mutation, delete, and cache work that belongs to a
reset/account session
- serialize remote edits and deletes per conversation while keeping
title, star, and folder changes instantly optimistic
- settle fields by operation UUID so sibling, duplicate, cyclic,
refreshed, failed, and cancelled edits cannot erase newer intent
- keep conversation cache admission session-aware without blocking the
main actor on SQLite work
- route the desktop star automation action through the repository
exactly once

This preserves the high-value hardening that remained after #9354
landed, supersedes the now-closed #9365, and is a focused follow-up to
#8197.

## Failure cases covered

- old-account detail/mutation/delete acknowledgements after reset
- reset while a detail cache write is suspended before transaction
admission
- overlapping title + star success and partial failure
- duplicate and A → B → A title operations, including a refresh
reflecting the older A
- two queued failures rolling back to the last confirmed value
- delete racing an in-flight mutation
- transport cancellation and cancellation while queued
- older canonical revisions and active-filter removal
- automation double-call/invalid async routing regression

## Verification

- `xcrun swift test --package-path Desktop --filter
'ConversationRepositoryTests|ConversationReconciliationPolicyTests|DesktopAutomationSecondaryActionTests'`
— 57 passed
- `OMI_SWIFT_TEST_SUITE_WORKERS=4 ./scripts/swift-test-suites.sh` — 184
suites passed in isolated processes
- every `desktop/macos/tests/test-*.sh` launcher/shell test passed
- strict desktop E2E flow coverage passed for all changed production
Swift files
- repository pre-push hook passed, including a clean desktop Swift
compile
- launched the ad-hoc-signed `omi-conversation-races` named bundle and
exercised the real `set_conversation_starred` semantic action; the cold
signed-out profile returned the expected safe `no conversations
available` failure
- independent subagent review iterated through concurrency, refresh,
delete, storage, and cancellation findings and approved the final diff
with no remaining findings

## Risk

No API, schema, or migration changes. The behavioral change is limited
to conversation cache/session admission and repository-owned mutation
ordering. Optimistic UI remains immediate; only remote acknowledgement
order is serialized per conversation.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/9371?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. -->
Git-on-my-level added a commit that referenced this pull request Jul 17, 2026
## Summary

- Project cancelled and superseded task statuses through one shared
lifecycle rule, so the local cache, Dashboard refresh, and To Do
reconciliation all retire the same task.
- Make Tasks-page first-load, loading, error, and retry behavior follow
the selected To Do or Done view instead of aggregate task rows.
- Add regression coverage for soft retirement, Dashboard visibility,
selected-view state, and both terminal statuses.

## Failure class

Failure-Class: FC-split-mutation-authority

The violated contract was that separate callers projected task
retirement differently. The fix converges this lifecycle transition in
`TaskActionItem.isRetired`, the shared domain model, rather than adding
another surface-specific observer. It covers the reported cross-surface
disagreement and follows the class's prior evidence in #9365 and #9597.

## Product invariants

None. `scripts/pr-preflight --suggest` found no product-invariant
citations required by these changed paths.

## Verification

- `xcrun swift test -c debug --package-path Desktop --filter
'ActionItemStorageVisibilityReconciliationTests|TasksStoreEmptyCloudReconcileTests|DashboardTaskRefreshPolicyTests|StartupWarmupPolicyTests|TasksViewModelCompletedToggleTests'`
(59 tests passed)
- `./scripts/agent-logic-harness.sh --cross-surface-smoke` (Swift,
agent, and Rust contract smoke passed)
- `./scripts/swift-format-wrapper.sh lint ...` and `python3
scripts/check_desktop_test_quality.py`
- Built and launched the named ad-hoc `omi-task-projection` bundle; its
automation bridge navigated to Tasks. The dev bundle was signed out, so
live account data could not be exercised.
- Independent Sol review approved the implementation with no blocking
findings.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/9940?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. -->
Git-on-my-level added a commit that referenced this pull request Jul 28, 2026
## What changed and why

Replace the remaining split memory lifecycle with one canonical
pipeline: broad, bounded intake always lands in Short-term; canonical
consolidation is the sole route into Long-term and atomically records
its promotion receipt and graph assertion. Retrieval now collapses
canonical lineage, while vector, keyword, compatibility, and graph
projections converge from a durable outbox instead of acting as memory
authority.

### High-level change map

- **Broad Short-term intake:** conversation extraction, explicit writes,
observations, imports, APIs, plugins, and integrations now enter the
same Short-term lifecycle. Capture is subject-aware, accepts useful
short utterances, preserves source state when grounding is invalid, and
retracts only genuinely empty extraction results.
- **One Long-term admission authority:** canonical consolidation gives
every pending item exactly one route—promote, archive, review, or
reject. Promotion is the only route into Long-term and atomically
commits the promotion receipt, canonical item, ledger state, structured
graph assertion, and derived-view outbox work. The old generic L2
promotion workers and helper paths are removed.
- **Cleaner, higher-context retrieval:** default access can use eligible
Short-term and Long-term memory, but collapses aliases and superseded
items by canonical lineage so one logical fact appears once. Vector
hydration is fenced to the authoritative item revision/commit,
restricted content stays provider-ineligible, and chat/developer/MCP
compatibility adapters preserve the canonical policy.
- **Reliable derived projections:** vector, keyword, V3 compatibility,
and graph cleanup are durable, retryable outbox effects rather than
competing memory owners. Workers reload authoritative state, use leases
and idempotent writes, reconcile after provider calls, and acknowledge
only successful convergence.
- **Correct replacement and privacy closure:** conversation reprocessing
replaces its complete source set atomically, restores independently
supported facts when a merged source disappears, and keeps
source-addressable lineage. Memory deletion, conversation cascades,
exact 100-item batches, and account deletion now close over canonical
lineage under durable deletion and processing fences.
- **Bounded cost and failure handling:** consolidation and
required-processing work use stable cursors, bounded Firestore queries,
capped batch sizes and LLM calls, retry leases/backoff, and terminal
review/quarantine after repeated failure. Sparse legacy scans rotate
durably so old rows cannot starve newer work.
- **Operational and contract updates:** the PR adds the canonical
maintenance schedule/runtime contract, Firestore indexes and rules,
malformed-document read-boundary coverage, deployment setting
classification, architecture/runbook updates, the proposed `INV-MEM-4`
lifecycle invariant, and a backend prevention artifact for
`FC-split-mutation-authority`.

## Why these are improvements

- **Simpler ownership:** capture, admission, mutation, and projection
responsibilities now have one named authority each. Removing parallel
promotion paths makes contradictory tier/graph state structurally harder
to create.
- **Better recall without simply returning more noise:** broad intake
retains potentially useful observations in Short-term, while
evidence/subject validation and the exact-one-route consolidation
boundary decide what deserves durable Long-term status.
- **Better precision:** promotion requires structured grounding and a
graph plan; retrieval rehydrates authoritative records and collapses
lineage before returning results, rather than trusting stale provider
rows or showing both an alias and its survivor.
- **Higher reliability and privacy:** canonical state and every derived
effect are journaled together, external work is retried from
authoritative state, stale generations are fenced, malformed Firestore
documents use the shared sanitized boundary, and deletion wins over
delayed projection work.
- **Controlled cost:** all new maintenance scans and LLM paths have
explicit query, batch, attempt, and per-pass bounds. Failed or poisoned
work is quarantined instead of being retried forever or starving the
queue.
- **Evidence, not only structure:** behavioral tests execute production
seams for capture, consolidation, atomic apply, replacement, deletion,
retrieval, projection delivery, scheduling, and malformed data. Fault
cases assert rollback, retry, redaction, and no-side-effect behavior.

The requested recall, precision, reliability, and cost percentages
remain design targets. This PR establishes the mechanisms expected to
improve those metrics but does not claim production benchmark results.

## Product invariants affected

- INV-MEM-1
- INV-MEM-2
- INV-MEM-4 (proposed)

## How it was verified

- `BACKEND_PYTEST_WORKERS=1 bash test.sh` swept all 776 backend test
files. It initially exposed nine integration-fixture regressions; after
repairing those seams, `BACKEND_UNIT_TEST_FILE_LIST=.unit-failures.txt
BACKEND_PYTEST_WORKERS=1 bash test.sh` passed every formerly failing
file.
- Focused canonical capture, consolidation, apply/outbox,
lineage/privacy, adapter, runtime-contract, and source-replacement
suites passed, including the hermetic canonical pipeline path.
- `make preflight` passed the complete diff-scoped local manifest.
- The bounded pre-push gate passed all 60 selected backend test files
with serial workers; the one prior parallel-only duration failure passed
its required guarded rerun (`22 passed in 0.80s`).
- Pyright (`0 errors`), Black, Ruff, Python compilation,
changed-workflow `actionlint`, Firestore index generation/coverage,
runtime validators, and the app-client OpenAPI drift check passed.
- `npx tsc --noEmit --incremental false` passed for the admin web
workspace.

No production deployment or live personal account data was used. A
live-service/user-facing production exercise therefore remains
intentionally unperformed.

## Tests

Core-path and error-path coverage was added or updated for broad
Short-term capture, sole-route consolidation, atomic graph-backed
promotion, required-processing retries, source replacement/reactivation,
lineage collapse, projection retries/read fences, privacy deletion,
account purge, bounded review queries, scheduler wiring, and
compatibility adapters.

## Failure class (fixes)

Failure-Class: FC-split-mutation-authority

## New guards (only when adding a check or ratchet)

Merged PRs #9365 and #9597 are the recorded instances this would have
caught. `backend/tests/unit/test_canonical_maintenance_ordering.py` is
intentionally a backend behavioral contract, not a new shared checker,
because it must execute the production memory-maintenance owner and
prove that no second promotion route can run when consolidation is
blocked; the shared cross-component primitive remains the
`FC-split-mutation-authority` registry contract.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/10772?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. -->
undivisible pushed a commit to undivisible/omi that referenced this pull request Sep 29, 2026
…dware#9940)

## Summary

- Project cancelled and superseded task statuses through one shared
lifecycle rule, so the local cache, Dashboard refresh, and To Do
reconciliation all retire the same task.
- Make Tasks-page first-load, loading, error, and retry behavior follow
the selected To Do or Done view instead of aggregate task rows.
- Add regression coverage for soft retirement, Dashboard visibility,
selected-view state, and both terminal statuses.

## Failure class

Failure-Class: FC-split-mutation-authority

The violated contract was that separate callers projected task
retirement differently. The fix converges this lifecycle transition in
`TaskActionItem.isRetired`, the shared domain model, rather than adding
another surface-specific observer. It covers the reported cross-surface
disagreement and follows the class's prior evidence in BasedHardware#9365 and BasedHardware#9597.

## Product invariants

None. `scripts/pr-preflight --suggest` found no product-invariant
citations required by these changed paths.

## Verification

- `xcrun swift test -c debug --package-path Desktop --filter
'ActionItemStorageVisibilityReconciliationTests|TasksStoreEmptyCloudReconcileTests|DashboardTaskRefreshPolicyTests|StartupWarmupPolicyTests|TasksViewModelCompletedToggleTests'`
(59 tests passed)
- `./scripts/agent-logic-harness.sh --cross-surface-smoke` (Swift,
agent, and Rust contract smoke passed)
- `./scripts/swift-format-wrapper.sh lint ...` and `python3
scripts/check_desktop_test_quality.py`
- Built and launched the named ad-hoc `omi-task-projection` bundle; its
automation bridge navigated to Tasks. The dev bundle was signed out, so
live account data could not be exercised.
- Independent Sol review approved the implementation with no blocking
findings.


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/9940?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. -->
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.

Desktop Conversations: clarify backend authority while preserving cache-first UX

1 participant