Skip to content

refactor(memory): retire memory-maintenance-job and its dead pipeline - #23705

Merged
Git-on-my-level merged 5 commits into
mainfrom
lane/memretire
Oct 26, 2026
Merged

Git-on-my-level merged 5 commits into
mainfrom
lane/memretire

Conversation

@Git-on-my-level

Copy link
Copy Markdown
Member

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 (feat(memory): forward-only maintenance window for memory-maintenance-job deploy readiness #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

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 (#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).
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-26T16:59:44.495185Z 02db7c6 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

…emreq wiring; retire the switch from universal-memory-operations and .env.template

Luna r1 (FIX-FIRST) findings addressed:
- P1: dream-agent.md and canonical_memory_architecture.md now state the inline
  required-intake + Dream-retry target as lane memreq's in-flight wiring with an
  explicit merge-order note, and name the interim truth (pending items have no
  scheduled retry anywhere — identical to production's status quo) with the anx
  tracking step (memretire-orphaned-duties).
- P2: universal-memory-operations.md no longer documents
  MEMORY_CANONICAL_MAINTENANCE_ENABLED as a control or rollback lever (incident
  actions now pause the Dream sweep Scheduler instead); backend/.env.template
  drops the retired variable and says validation rejects it.
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Luna r1 (FIX-FIRST) — both findings addressed in 0fafe95:

P1 (inline/Dream retry not wired): Correct observation — that wiring is lane
memreq's in-flight PR (same 10-26 ruling; bus-coordinated; their report is due
11:00Z). This PR's docs wrongly stated the target state as present. Fixed in
dream-agent.md and canonical_memory_architecture.md: the inline-at-write +
Dream-retry ownership is now stated as memreq's wiring with an explicit merge-order
note (merge memreq with or before this retirement), and the interim truth is named:
pending required items have no scheduled retry in any environment, which is exactly
the state production has always had (the job never served prod). The gap is tracked
in anx (memretire-orphaned-duties, due 2026-10-29) along with the other orphaned
duties (TTL settling, outbox drain, recurrence delivery).

P2 (universal-memory-operations.md + .env.template still taught the retired
switch):
Fixed — the Controls table no longer lists
MEMORY_CANONICAL_MAINTENANCE_ENABLED as a runnable control, incident action 3 now
pauses the dream-agent-sweep-hourly Scheduler instead of setting the retired env,
and backend/.env.template drops the variable and states validation rejects it.

Not a behavior change: both fixes are documentation/template truthfulness; the code
retirement is unchanged.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: bbe6795f70

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +157 to +159
text = text.replace("frame-request-retention-job", job_name)
text = text.replace("frame_request_retention_job", module_name)
text = text.replace("frame-request-retention-hourly", f"{job_name}-schedule")

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retarget the Scheduler identity in generated job workflows

When scaffolding a job with its own Scheduler service account, the generated workflow still binds SCHEDULER_SERVICE_ACCOUNT to vars.FRAME_REQUEST_RETENTION_SCHEDULER_SERVICE_ACCOUNT. The substitutions rename the Scheduler manifest lookup to the new job, but leave this retention-specific variable unchanged. Consequently, the generated Grant the declared Scheduler identity access to run this job step rejects the new job's declared account (or fails its nonempty check if the retention variable is unset), after the Cloud Run deployment has already occurred. Retarget this binding to a job-specific variable or derive the account from the selected Scheduler manifest entry.

Useful? React with 👍 / 👎.

Keeps #23710's inline required-memory intake wiring intact: the
captured_after/captured_before/cursor pagination params on
list_pending_required_processing_items, list_receipted_required_processing_items,
Dream completion/retry ownership in canonical_consolidation, the inline-intake
registry/env rows, and the runbook/AGENTS ownership pointers.

Keeps #23705's retirement intact: memory-maintenance-job manifest blocks and
workflows stay deleted, MEMORY_MAINTENANCE_CAPTURED_AFTER (helper, env rows,
call sites) and MEMORY_CANONICAL_MAINTENANCE_ENABLED stay retired, validator
guards from bbe6795 unchanged, feature-flag registry re-rendered without the
job surface. No behavioral code beyond deleting the retired window call sites;
targeted shard green (841 passed).
Second conflict round after #23739 reverted the FIRESTORE_READ_LEVERS flip
(#23731) on main. Resolution identical in shape to c58ac2c: the
memory-maintenance-job manifest blocks stay deleted (the revert's in-block lever
edit dies with the block), live-surface lever values take main's reverted state
via auto-merge, and the feature-flag registry is re-rendered from the resolved
manifests (reverted lever values, no job surface). Checker OK; targeted shard
873 passed.
@Git-on-my-level
Git-on-my-level merged commit 4bc44c3 into main Oct 26, 2026
62 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/memretire branch October 26, 2026 17:32
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