Skip to content

fix(memory): require adjudication before TTL expiry - #11962

Merged
Git-on-my-level merged 10 commits into
mainfrom
codex/memory-adjudication-gap
Aug 21, 2026
Merged

Git-on-my-level merged 10 commits into
mainfrom
codex/memory-adjudication-gap

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Summary

  • keep an active Short-term memory readable when its 48-hour deadline passes until canonical lifecycle apply records a terminal disposition
  • prioritize users with globally earliest approaching expiries ahead of the rotating UID registry, bypassing the 20-hour cooldown and continuing even when the registry inventory is unavailable
  • distinguish newly discovered unadjudicated expiry, an already-recorded disposition, and successful terminal apply in lifecycle telemetry
  • keep confident third_party aboutness as a promotion veto while allowing unclear aboutness through the existing relationship, source-authority, and usefulness checks

Why this design

The expiry-ordered inventory gives maintenance 24 hours of headroom without changing the 48-hour TTL. It uses metadata-only collection-group queries for stored and policy-derived expiry, merges them by effective_short_term_expiry, prepends those users to the bounded registry page, and bypasses the dreaming cooldown for them. The registry and expiry inventories fail independently, so a registry outage no longer prevents urgent work.

That queue improves timeliness but cannot be the correctness boundary: it is still bounded, and no queue can guarantee progress while its deployable is disabled or unavailable. The clock therefore no longer hides an otherwise active Short-term row. Only canonical lifecycle apply can make it unreadable by changing its status/tier after a persisted promote/archive/review/reject decision. Rejection and archival remain terminal and hidden, so this does not extend retention or turn Short-term into a junk drawer.

Transition idempotency is keyed to the item revision/content and decision rather than the maintenance run timestamp. This makes retries recognize a previously persisted decision, which in turn makes the disposition telemetry meaningful.

Observability

  • expired_without_recorded_disposition: the lifecycle owner had to create the terminal transition record
  • expired_with_recorded_disposition: a retry found that record already persisted
  • expired_terminal_disposition_applied: canonical apply completed the terminal state change
  • cron summaries expose urgent users/items, already-expired active candidates, new/existing disposition records, and completed terminal applies
  • default reads log expired_active_pending_terminal_apply and record the shared degraded-fallback event without pretending the read path can determine whether a transition record exists

Attribution contract

This PR also includes the requested narrow unclear correction because the prompt and Pydantic validator can be changed and tested together. Confident third_party remains a hard veto. unclear is not automatically promotable: weak/unclear relationships, missing authoritative attribution, restricted sensitivity, and failed usefulness checks still reject it.

Verification

  • bash backend/test.sh — passed all 888 isolated backend unit-test files (BACKEND_TEST_EXIT=0)
  • BACKEND_UNIT_TEST_FILE_LIST=/private/tmp/memory-adjudication-focused-tests.txt bash test.sh — passed 197 tests across 13 affected files after rebasing onto current origin/main
  • bash backend/scripts/typecheck.sh — 0 errors (3,744 existing warnings)
  • backend/.venv/bin/python backend/scripts/memory-continuity-gauntlet.py --self-check — passed
  • backend/.venv/bin/python backend/scripts/generate_firestore_indexes.py — generated manifest matches the index registry
  • OMI_PR_BODY_FILE="$PWD/PR_BODY.md" make preflight — passed 27 checks

The behavior was exercised through the production read, maintenance, lifecycle persistence/apply, vector, chat, developer, and router seams using hermetic Firestore fakes. It was not run against live Firestore or a production account; this PR performs no production mutation.

Line-Count-Exception: backend/utils/memory/canonical_consolidation.py | 2198 -> 2337 | the prompt rule and its matching authoritative-attribution validator must change together in the existing consolidation owner, and the owner-rejection feedback loop (recent rejected-memory examples, pending-id filtering, fallback telemetry) belongs on that same consolidation path
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 2297 -> 2359 | the owner's recent rejected memories are fetched at the conversation orchestration boundary so L1 prompting honors live rejection feedback before new memories are proposed
Line-Count-Exception: backend/utils/memory/memory_service.py | 2772 -> 2774 | clearing the rejected-memory feedback cache when memories change keeps the review loop from re-admitting a verdict the owner already recorded
Line-Count-Exception: desktop/macos/Desktop/Sources/MainWindow/Pages/MemoriesPage.swift | 3484 -> 3576 | the keep-or-reject review controls and verdict recording are part of the Short-term adjudication surface this PR adds

Product-Invariant: INV-MEM-1

Failure-Class: none


Reviewer callout (added by supervising agent, not by the authoring agent)

This PR removes the read-time TTL gate: _base_policy_checks no longer returns
short_term_expired, and an expired-but-active Short-term row stays readable until
canonical apply records a disposition. The argument for that is in "Why this design"
above — a clock does not know whether a decision was made, so a clock should not be
the thing that hides a row.

The residual risk worth reviewing is operational, not configuration. ST→LT
maintenance is hosted by exactly one deployable (memory-maintenance-job, which
carries MEMORY_CANONICAL_MAINTENANCE_ENABLED: 'true'; manifest validation enforces
that every other surface and job keeps it false). There is no second writer by
design. So if that single job is down, wedged, or its Cloud Scheduler trigger breaks,
nothing adjudicates — and after this change nothing hides either, with no long-horizon
backstop. The failure mode moves from silent loss to unbounded visible accumulation.

That is plausibly the right direction, since visible failures get fixed and silent ones
do not, and the new expired_active_pending_terminal_apply telemetry is what makes it
visible. Two things worth deciding explicitly: whether that signal should alert
rather than only log, and whether a bounded backstop (hide at TTL + N days even without
a disposition) belongs here or in a follow-up.

(An earlier revision of this callout claimed the flag "defaults to false" in a way that
implied the feature ships disabled. That was wrong — it is a per-deployable routing
switch, correctly false off the maintenance job. Corrected here.)

🤖 Generated with Claude Code


Product invariants affected

  • INV-MEM-1
  • INV-MEM-3

INV-MEM-1 (exactly three product memory tiers). The tier set is unchanged —
short_term / long_term / archive, one canonical collection. What changes is
when a Short-term row is default-accessible: elapsed time alone no longer removes
it. Default access remains Short-term + Long-term, Archive still requires an
explicit Archive operation, and rejected/archived items stay hidden. No new
user-visible tier is introduced.

INV-MEM-3 (universal memory authority fails closed). The Short-term expiry check
moves out of _base_policy_checks and into is_default_access_eligible, where an
expired-but-active row returns short_term_expired_pending_adjudication instead of a
denial. Every genuine fail-closed check in _base_policy_checks — not-active,
processing-blocked, source tombstoned/purged, unknown consumer, restricted
sensitivity, unknown visibility — is untouched and still evaluated first. The claim
is that an unreachable clock was never a canonical authority check: only a recorded
promote/archive/review/reject decision makes a row unreadable. Archive access shares
_base_policy_checks and is unaffected, since an Archive-tier row is not
short_term.

Reviewers should weigh whether relaxing a time-based denial is compatible with
INV-MEM-3's fail-closed posture, given the single-host maintenance job noted in the
reviewer callout above.

@mintlify

mintlify Bot commented Aug 20, 2026 •

Copy link
Copy Markdown

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

Project Status Preview Updated (UTC)
omi 🟢 Ready View Preview Aug 20, 2026, 9:26 PM

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

# Time alone is not a terminal lifecycle decision. Active Short-term
# rows remain readable until canonical apply records promote/archive/
# review/reject and moves them out of this state.
return AccessDecision(True, "short_term_expired_pending_adjudication")

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Agentic Security Review
Severity: HIGH
[Privacy Guard] Expired active Short-term memory is now explicitly allowed for default access (short_term_expired_pending_adjudication) after removing the prior read-time TTL deny gate. Because canonical maintenance is feature-flagged off by default, this can leave post-TTL content readable indefinitely when maintenance is disabled or unhealthy.
Impact: Extends exposure of supposedly short-lived memory content beyond the documented 48-hour boundary across default-read surfaces (including granted external consumers), creating a retention/privacy control bypass when lifecycle adjudication does not execute.

Fix in Cursor Fix in Web

Reviewed by Cursor Security Reviewer for commit 9ebc394. Configure here.

Git-on-my-level and others added 8 commits August 21, 2026 07:17
Keep active short-term memories readable until canonical lifecycle apply records a terminal disposition, and prioritize globally expiry-urgent users ahead of the bounded registry rotation. Add disposition-aware lifecycle telemetry and expiry inventory coverage.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
Preserve the hard veto for confidently third-party content while allowing unclear aboutness to proceed through the existing relationship, source-authority, and usefulness validators.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
Only processed active rows exercise the read-time adjudication fallback. Keep pending rows out of that signal so visibility telemetry does not claim a fallback that was never served.

Failure-Class: none

Co-Authored-By: Claude Opus 5 <[email protected]>
The env template listed MEMORY_MODE and MEMORY_V3_GET_ENABLED -- both legacy
one-deploy aliases per config/memory_rollout.py -- and omitted MEMORY_ENABLED,
the actual user-facing switch. A reader reasonably concluded MEMORY_MODE was the
control.

MEMORY_CANONICAL_MAINTENANCE_ENABLED is per-deployable routing, not a rollout
flag, so its "false" default is correct rather than drift. Say so at the getenv
call, since that is what gets read first, and point both sites at the overlays as
the source of truth for deployed values.

Values unchanged; comments and one explicit fail-closed default only.

Co-Authored-By: Claude Opus 5 <[email protected]>
POST /v3/memories/{id}/review has existed and worked for a while, but no client
called it -- neither macOS nor mobile -- so user_review was never set on any
memory and the only feedback the owner could give was deleting a row. Rejecting
hides the memory from default reads and drops it from the keyword index and
knowledge graph, which is the signal we actually want.

Controls sit in the card footer, revealed on hover so long lists stay clean, and
stay visible once a card is judged so a review pass remains legible while it is in
progress. Verdicts are held in a session map because ServerMemory is immutable and
a rejected row only disappears on the next load.

`value` is a bare scalar on the route, so FastAPI binds it from the query string;
sending it in the body would 422. Tests pin that wire shape in both directions.

Co-Authored-By: Claude Opus 5 <[email protected]>
Feed bounded sensitivity-safe rejection examples into L1 extraction and canonical consolidation, add stable text-free capture and promotion telemetry, and tighten the narrow L1 rules that produced unattributed or generic-product noise.

Add behavioral coverage for filtering, cache invalidation, prompt construction, hard promotion rejection, instrumentation, and Firestore query contracts.

Co-Authored-By: Claude Opus 5 <[email protected]>
Add the required unreleased user-facing changelog fragment for the owner memory review UI already on this branch.

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

Commit d5596a6 moved settings_notifications_snapshot and
set_notification_settings into DesktopAutomationBridge+Notifications.swift
but did not add that file to ACTION_SOURCE_RELATIVE_PATHS, so
desktop-flow-lint reports both actions as unknown on any PR whose diff
touches an action-source file. Register the relocated owner so flow
validation sees the actions where they live now.
Git-on-my-level and others added 2 commits August 20, 2026 20:40
test_memory_replace_policy.py ran in 0.36s alone and 3953s after
test_working_observations_extractor.py -- the same 20 tests, passing either way.
Six memory test files together took 1:06:03.

database.notifications binds its Firestore handle at import time
(`from ._client import db`), so swapping sys.modules["database._client"] afterwards
cannot reach a copy another test already imported. install_ws_i_heavy_import_stubs()
will not displace a real module -- several callers depend on the real one surviving --
so the stub was skipped, _extract_memories_canonical reached the real
get_user_time_zone, and the test sat in google.api_core retry backoff against a live
client. Nothing failed, so only the clock showed it, and CI runs files in separate
processes, which is exactly why it stayed invisible.

Adds drop_client_binding_modules() for callers that need the stub to win, and calls
it from the one fixture that re-imports process_conversation. _set() now also updates
the parent package attribute: `import database.notifications as notification_db`
resolves through getattr(database, "notifications") and only falls back to
sys.modules on AttributeError, so a stale parent attribute defeats a stub that looks
correctly installed. restore_sys_modules() already unwound that on teardown; this is
the matching half on the way in.

Displacing real modules unconditionally was tried first and rejected: it broke eight
tests in test_memories_validation and the two merge suites, which legitimately want
the real module.

Six-file set: 3963.39s -> 9.51s, same 179 tests. Verified against a no-fix baseline
over 111 files that this adds no failures; 25 failures in that combination are
pre-existing order-dependent pollution of other kinds and are not addressed here.

Co-Authored-By: Claude Opus 5 <[email protected]>
Both failures predate this branch and arrive from main; neither touches memory.
Fixing them here because they block this PR's CI.

DesktopAutomationSecondaryActionTests asserted registration by reading
Sources/DesktopAutomationBridge.swift as text. The notification actions were moved
to DesktopAutomationBridge+Notifications.swift to satisfy a line-count ratchet, so
settings_notifications_snapshot and set_notification_settings were registered but
invisible to the contract. Read every DesktopAutomationBridge*.swift instead, which
keeps the assertion about whether an action is registered rather than which file
happens to hold it -- the next relocation will not re-break it. A case that had been
silently XCTSkip-ing because actionBody() could not find its action now runs.

PermissionsPagePresentationTests pinned the settings-section order without .referral,
but SettingsPage.swift gained `case referral = "Refer a Friend"` and the expectation
was never updated. Added it in the position the app actually renders, between
.advanced and .about.

RuntimeOwnerIdentityTests also failed in CI on a drain-ordering assertion
(effect_finished vs effect_cancelled_and_finished). It passes locally on this commit
and is not addressed here -- it looks order- or timing-dependent rather than broken.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 4d7c209 into main Aug 21, 2026
37 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/memory-adjudication-gap branch August 21, 2026 04:09
cursor Bot pushed a commit that referenced this pull request Aug 21, 2026
Resolve the second-wave conflicts from #11962: both sides added the
notifications bridge to the flow-lint source list and taught the
automation-bridge tests to read every DesktopAutomationBridge*.swift
file. Keep main's versions of those two helpers.

Co-authored-by: David Zhang <[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