Repository navigation
feat(memory): forward-only maintenance window for memory-maintenance-job deploy readiness - #23674
Merged
Merged
Conversation
… and observation intake memory-maintenance-job has never been deployed to prod, so required memory intakes stay pending forever (op1 2026-10-26 root cause). David ruled the fix forward-only with no backfill; the pending-required query and the observation rotation are both oldest-first, so a first prod run would otherwise replay the entire pre-deploy backlog. Add MEMORY_MAINTENANCE_CAPTURED_AFTER (RFC3339, empty/unset preserves current behavior). When set: - list_pending_required_processing_items adds a captured_at >= window range that rides the existing memory_items_required_processing_by_capture composite index (no new index); both required-processing runners pass the resolved window through. - _pending_observation_ids skips pre-window rows so the first post-deploy rotation cannot plan decisions for the historical observation backlog; the cursor still advances past skipped pages. An unparseable or offset-less value fails the run closed instead of silently replaying the backlog. Declared empty in both memory-maintenance-job runtime_env blocks; the first prod deploy sets it to the deploy timestamp. The outside query driver now drives captured_after as a domain (None and a frozen timestamp) so the contract suite proves the windowed shape is served by the existing composite index. Failure-Class: none
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Luna r1 P2 on #23674: _pending_observation_ids applied the forward-only window after fetching the 100-row page, so pre-window rows consumed the scan budget and one fresh observation behind 250 backlog rows waited multiple maintenance visits. Move the cutoff into _required_intake_page (optional captured_after; the required-intake completion path stays unwindowed), ride the same composite index, and drive captured_after as a query-driver domain so the contract suite proves the windowed shape is served. Regression test covers the 250-backlog-then-one-fresh case. Failure-Class: none
Git-on-my-level
added a commit
that referenced
this pull request
Oct 26, 2026
…#23705) ## refactor(memory): retire memory-maintenance-job and its dead pipeline David (2026-10-26 ~07:58Z): "retire/delete any old no longer active logic to avoid confusing future agents." Required intake moved **inline at write time with Dream as retry/backlog owner** (lane memreq, coordinated on the bus); the daily sweep and knowledge-ledger drain were already retired (DEC-MEM-002 10-18, DEC-FREE-006). `memory-maintenance-job` was **dev-only and never served production** (verified: ro-prod scheduler + Cloud Run job lists have no memory entries). ### Deleted (no live prod caller; evidence in data/run-2026-10-26-memretire/REPORT.md, workspace repo) - `backend/modal/memory_maintenance_job.py` + `Dockerfile.memory_maintenance_job` - `backend/utils/memory/canonical_short_term_maintenance_cron.py` (engine; only importer was the job) - `.github/workflows/gcp_memory_maintenance_job.yml` + `gcp_memory_maintenance_job_auto_dev.yml` (auto-dev redeployed the dead job to dev on every main push touching `backend/**`) - dev scheduler entry `memory-maintenance-hourly` (`backend/deploy/scheduler/jobs.yaml`) - `backend/scripts/validate_memory_maintenance_scheduler.py` (+ its test) - `backend/scripts/legacy_memory_retirement_readiness.py` (+ test + fixtures) — the one-time `DELETE-AFTER: INV-MEM-6` tool whose purpose this retirement completes - `MEMORY_MAINTENANCE_CAPTURED_AFTER` (#23674 window, merged but never used): flag rows, env declarations, `maintenance_captured_after()`, `captured_after` query params (default was empty = inert; inline intake does not use it — memreq acked) - `MEMORY_CANONICAL_MAINTENANCE_ENABLED`: flag rows, runtime_env entries (all surfaces × dev/prod), backend-listen chart entries ### Kept (live or shared) `canonical_required_processing` (memreq inline + Dream retry reuse), `canonical_consolidation` (live via `process_conversation`), `short_term_promotion` + `memory_outbox_worker` (e2e lifecycle contract, dev-harness runner, memory_admin router), the shared `memory-maintenance-scheduler@` service accounts (day3-reengagement-email uses them in dev AND prod), and all stored Firestore data. ### Guards added Runtime-env validation refuses reintroduction (`_validate_memory_job_retirement`: no `memory-maintenance-job` manifest block; no retired env on any job or surface; notifications-job keeps no memory bindings). Retirement tests replace the contract tests; `test_retired_daily_sweep_runtime_is_absent` now also asserts the job is absent. ### Orphaned duties flagged (were dev-only; prod behavior unchanged by this PR) Deterministic TTL settling, rotating canonical-outbox drains, and already-enqueued recurrence delivery now have **no scheduled owner anywhere**; required intake is covered inline + Dream. Tracked in anx for David/lead to place (fold into Dream's sweep, a new bounded owner, or accept as dead). ### Product invariants affected - INV-MEM-1: canonical memory tier boundaries are untouched — the retirement removes the scheduled maintenance host only; tier reads/writes and their fences are unchanged (targeted unit shard covers the tier lifecycle tests). - INV-MEM-4: `backend/deploy/runtime_env.yaml` regenerated from `_base.yaml` + overlays after removing the job block and flag entries; receipts unchanged. - INV-DATA-1: workflow deletion is code retirement only; no production data read or mutated by this PR. Dev cloud resources (schedulers/jobs) are retired separately by the lead from the report's command list; nothing here touches cloud state. ### Workflow/CI pins refreshed for the deletions checks-manifest, ci-budget (workflow budget entries + path lists), backend-unit-tests path filters, check-deployment-concurrency contracts, logging_rollout_pending, `scripts/pre-push` pin lists, `scripts/worktree_env_doctor.py`, `backend/testing/workflow_contracts.json`, `backend/runtime_images.json`, `backend/pyrightconfig.json`, `fast_unit_duration_allowlist.txt`, legacy memory surface baseline keys, FC-flex-budget-stop-swallowed marked dormant (host deleted; class cannot recur). `scaffold_cloud_run_job.sh` templates retargeted to the frame-retention job. ### Deploy needed None for prod (the job never existed there). The backend-listen chart env removal rides the next listen train harmlessly. Dev cloud retirement (5 Cloud Run jobs + 3 schedulers) is lead-executed from data/run-2026-10-26-memretire/REPORT.md. ### Verification Targeted backend unit shard green via `backend/test.sh` + `BACKEND_UNIT_TEST_FILE_LIST` (26 files: runtime-env validator/render, workflow contracts, scheduler reconcile, runtime images, canonical required/consolidation query, lifecycle/outbox/atomic-apply, notifications orchestrator, account deletion): **all passed** locally at lane/memretire HEAD. Layer: hermetic unit tests; no deploy claim. UI-Evidence: none -- reason: no web/admin/app changes in this PR. Failure-Class: none
kriegcloud
pushed a commit
to kriegcloud/omi
that referenced
this pull request
Oct 26, 2026
David (2026-10-26): retire no-longer-active logic so future agents are not misled. Required intake moved inline at write time with Dream's sweep as retry/backlog owner (lane memreq); the daily sweep and knowledge-ledger drain were already retired (DEC-MEM-002, DEC-FREE-006). memory-maintenance-job was dev-only and never served production. Deleted: - backend/modal/memory_maintenance_job.py + Dockerfile (job entrypoint) - backend/utils/memory/canonical_short_term_maintenance_cron.py (its engine; no non-test importer once the job is gone) - .github/workflows/gcp_memory_maintenance_job.yml and _auto_dev.yml (the auto-dev workflow redeployed the dead job on every main push) - dev scheduler entry memory-maintenance-hourly (backend/deploy/scheduler/jobs.yaml) - backend/scripts/validate_memory_maintenance_scheduler.py (+ test) - backend/scripts/legacy_memory_retirement_readiness.py (+ test + fixtures), the one-time DELETE-AFTER: INV-MEM-6 tool whose purpose this completes - MEMORY_MAINTENANCE_CAPTURED_AFTER window (BasedHardware#23674; merged but never used): flag rows, env declarations, maintenance_captured_after() and the captured_after query params in canonical_required_processing/ canonical_consolidation (default was empty = inert) - MEMORY_CANONICAL_MAINTENANCE_ENABLED flag rows, manifest env entries and backend-listen chart entries Kept: canonical_required_processing (inline intake + Dream retry reuse it, per memreq coordination), canonical_consolidation (live via process_conversation), short_term_promotion + memory_outbox_worker (e2e lifecycle contract and dev-harness callers), the shared memory-maintenance-scheduler service accounts (day3-reengagement uses them in dev and prod), and all stored Firestore data. Runtime-env validation now refuses reintroduction (_validate_memory_job_retirement): no memory-maintenance-job manifest block, no MEMORY_CANONICAL_MAINTENANCE_ENABLED / MEMORY_MAINTENANCE_CAPTURED_AFTER on any job or surface, notifications-job keeps no memory bindings. Orphaned duties flagged for follow-up (never live in prod, were dev-only): deterministic TTL settling, rotating canonical-outbox drains, and already-enqueued recurrence delivery now have no scheduled owner; required intake is covered inline + Dream. See data/run-2026-10-26-memretire/REPORT.md (workspace repo) for the cloud retirement list the lead executes (dev schedulers/jobs; prod verified clean). Invariants: INV-DATA-1 (workflow deletion is code retirement only; no data read or mutation). INV-MEM-4 (runtime_env.yaml regenerated from sources after removing the job block and flag entries; receipts unchanged).
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
memory-maintenance-job has never been deployed to prod (op1 2026-10-26 root cause: required memory intakes stay pending forever for every user; this job is the only prod caller of required processing). David ruled 2026-10-26: generalized forward fixes, no backfill.
Both the pending-required query and the observation-intake rotation select oldest-first, so a naive first prod run would replay the entire pre-deploy backlog. This PR adds the forward-only window that makes the job deployable:
MEMORY_MAINTENANCE_CAPTURED_AFTER(RFC3339; empty/unset preserves current behavior for dev and tests).list_pending_required_processing_items(..., captured_after=)adds acaptured_at >=range that rides the existingmemory_items_required_processing_by_capturecomposite index (no new index). Both required-processing runners resolve the window once per pass._pending_observation_idsskips pre-window rows; the cursor still advances past skipped pages, so rotation stays live without planning decisions for historical observations.An unparseable or offset-less value fails the run closed instead of silently replaying the backlog. Declared empty in both memory-maintenance-job
runtime_env.yamlblocks; the first prod deploy sets it to the deploy timestamp.Product invariants affected
INV-MEM-1
INV-MEM-4
INV-MEM-1(exactly three product memory tiers) — unaffected: the window only bounds which existing Short-term rows maintenance selects; no tier, collection, or access-policy change.INV-MEM-4(canonical promotion is the sole Long-term authority) — unaffected: required processing and observation intake keep their existing decision, receipt and ledger fences; the window only bounds which rows are selected. Theruntime_env.yamlchange adds an empty-value env key only.Declarations
Failure-Class: none
MEMORY_MAINTENANCE_CAPTURED_AFTERregistered inconfig/feature-flags.yaml(lifecycle ops_kill, fail closed, decision keep per David's 2026-10-26 forward-only ruling);backend/docs/feature-flag-registry.mdregenerated withscripts/render_feature_flag_registry.py..github/changes, no deploy, no flag default flip, no IAM change, no data mutation.Test evidence
BACKEND_UNIT_TEST_FILE_LIST:tests/unit/test_canonical_required_processing_query.py,tests/unit/test_canonical_consolidation_query.py): 13 passed (local, 2026-10-26).backend/scripts/typecheck.shfull-tree pyright: 0 errors.validate-backend-runtime-env.py --env dev --check-workflowsand--env prod --check-workflows: both passed.Deploy note (for the lead's train)
The deploy sets
MEMORY_MAINTENANCE_CAPTURED_AFTERto the deploy timestamp in the prod overlay. Kill switches that already exist: pause thememory-maintenance-hourlyscheduler, or setMEMORY_CANONICAL_MAINTENANCE_ENABLED=falseon the job.