Repository navigation
feat(memory): enable full canonical maintenance for first-user whitelist in dev - #9295
Conversation
…ist in dev Wire notifications-job into the runtime env contract and turn on promotion cron + fast-track for the single allowlisted UID so merge+deploy yields real ST→LT maintenance without affecting non-whitelist or prod. Co-authored-by: Cursor <[email protected]>
Co-authored-by: Cursor <[email protected]>
|
Preview deployment for your docs. Learn more about Mintlify Previews.
💡 Tip: Enable Workflows to automatically generate PRs for you. |
There was a problem hiding this comment.
1 issue found across 9 files
Confidence score: 3/5
- In
.github/workflows/gcp_notifications_job.yml, the deploy label/tag SHA can diverge from the actual checked-out commit whenbranchdiffers from the workflow run ref, which risks deploying or recording the wrong revision and makes rollback/debugging unreliable — compute the short SHA from the checked-out HEAD (post-checkout) before merging.
You’re at about 92% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact [email protected].
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/workflows/gcp_notifications_job.yml">
<violation number="1" location=".github/workflows/gcp_notifications_job.yml:71">
P2: Deploy revisions can be labeled with a SHA that does not match the checked-out source when the `branch` input differs from the workflow run ref. Since this workflow now deploys the short-SHA tag, deriving it from `git rev-parse HEAD` after checkout would keep the image tag tied to the actual built commit.</violation>
</file>
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
| - name: Compute short SHA | ||
| id: image-tag | ||
| run: | | ||
| echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" |
There was a problem hiding this comment.
P2: Deploy revisions can be labeled with a SHA that does not match the checked-out source when the branch input differs from the workflow run ref. Since this workflow now deploys the short-SHA tag, deriving it from git rev-parse HEAD after checkout would keep the image tag tied to the actual built commit.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At .github/workflows/gcp_notifications_job.yml, line 71:
<comment>Deploy revisions can be labeled with a SHA that does not match the checked-out source when the `branch` input differs from the workflow run ref. Since this workflow now deploys the short-SHA tag, deriving it from `git rev-parse HEAD` after checkout would keep the image tag tied to the actual built commit.</comment>
<file context>
@@ -65,16 +65,35 @@ jobs:
+ - name: Compute short SHA
+ id: image-tag
+ run: |
+ echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT"
+
- name: Google Service Account
</file context>
| echo "short_sha=${GITHUB_SHA::7}" >> "$GITHUB_OUTPUT" | |
| echo "short_sha=$(git rev-parse --short=7 HEAD)" >> "$GITHUB_OUTPUT" |
💡 Codex Reviewomi/.github/workflows/gcp_notifications_job.yml Lines 81 to 82 in 8361d30 When this workflow is dispatched for ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
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". |
) ## Summary Follow-up to #9295 review feedback before any prod `notifications-job` deploy: - Pass `CLOUD_RUN_VPC_NETWORK` / `CLOUD_RUN_VPC_SUBNET` into the render step (same as `gcp_backend.yml`). Prod network flags are `env_var`-backed; without them `render_backend_runtime_env.py` exits before `notifications_job_*` outputs are emitted. - Derive the immutable image short SHA from `git rev-parse --short=7 HEAD` after checkout so the tag matches the `branch` input, not a divergent `GITHUB_SHA` workflow-file ref. ## Why - Codex P1 on #9295: prod workflow_dispatch could fail at render. - Cubic P2 on #9295: SHA/tag mismatch when `branch` ≠ run ref. ## Test plan - [x] `pytest backend/tests/unit/test_render_backend_runtime_env.py` (8 passed), including regression that prod render requires VPC vars and workflow source assertions - [x] `validate-backend-runtime-env.py --env dev|prod --check-workflows` - [ ] CI on this PR ## Notes - No memory flag / cohort / prod enablement changes. - Safe to land independently of whitelist dogfood; required before relying on prod notifications-job deploys. Made with [Cursor](https://cursor.com) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9296?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. -->
…anager binds (#9385) ## Summary Daily summaries silently stopped generating for every user on 2026-07-01. Root cause: the `notifications-job` Cloud Run Job's `OPENAI_API_KEY` was a **plain-literal env var** with a stale key value that OpenAI is now rejecting (`sk-proj-…wMAA` → `401 Unauthorized`). Every daily-summary run since caught the 401 in a broad `except Exception`, logged it, and returned without writing a summary or firing a push. The underlying architectural issue: **Cloud Run rejects updates when the same name is bound as both a plain-literal env-var and a Secret Manager secret**. If any earlier deploy hard-coded `OPENAI_API_KEY` (or any other secret name) into env, the literal silently wins forever — subsequent workflow runs that render `OPENAI_API_KEY` as a secret ref via `notifications_job_secrets` can't take effect because the deploy step never removes the conflicting literal. The `backend/deploy/runtime_env.yaml` manifest already correctly declares `OPENAI_API_KEY`, `PINECONE_API_KEY`, `SERVICE_ACCOUNT_JSON`, and `ENCRYPTION_SECRET` as Secret Manager binds on `notifications-job`. The workflow was just missing the cleanup step. ## How the intent was declared but never took effect PR #9295 (2026-07-08) first added `notifications-job` to the runtime env contract — the manifest section with `OPENAI_API_KEY` as a Secret Manager binding, plus the render + `secrets:` output wiring in `.github/workflows/gcp_notifications_job.yml`. The same PR also introduced the workflow's `--remove-env-vars=…` flag, but only listed the retired canonical-maintenance and Typesense keys — not the newly-declared secret names. Subsequent tightening in #9296, #9308, and #9358 kept the same `--remove-env-vars=` list without adding the secret names to it. Because `google-github-actions/deploy-cloudrun@v2` merges `secrets:` additively rather than removing overlapping env-vars, and Cloud Run silently keeps the pre-existing literal when a name is bound both ways, the secret ref for `OPENAI_API_KEY` was declared correctly but never actually replaced the (broken) literal. The literal was already broken as of 2026-07-01 01:06 UTC — Loki logs show a clean cutover from working summaries to `401 Unauthorized: invalid_api_key` at that timestamp, ~7 days before the Secret Manager binding was declared — so the July 8 change would have unblocked summaries immediately if it had also stripped the literal. Not a blame-y point: this class of gap is easy to miss because the intent looks correct in code review — the manifest says "secret", the workflow reads `notifications_job_secrets`, and `deploy-cloudrun@v2` accepts it. The failure mode only surfaces on a target that already had a plain literal by the same name, which isn't visible from the PR diff alone. The mitigation is small and general (this PR). ## Change - `render_backend_runtime_env.py` emits a new `<prefix>_secret_names` output per service/job — a comma-separated list of exactly the names in `secrets:`. - `gcp_notifications_job.yml` appends that output to its existing `--remove-env-vars=…` flag. `--remove-env-vars` is a no-op on a clean target, so this is safe on healthy deployments and cleanup on polluted ones. - Manifest stays the single source of truth — adding/removing a secret in `runtime_env.yaml` automatically flows both `--update-secrets` and the matching `--remove-env-vars` on the next deploy. ## Immediate live fix (already applied) To unblock tonight's summaries without waiting for the workflow to run, the live job was updated manually: ```bash gcloud run jobs update notifications-job \ --project=based-hardware --region=us-central1 \ --remove-env-vars=OPENAI_API_KEY \ --update-secrets=OPENAI_API_KEY=OPENAI_API_KEY:latest gcloud run jobs execute notifications-job --project=based-hardware --region=us-central1 ``` Post-execution logs are clean — zero `invalid_api_key`, `Sending daily summary` firing normally across all timezones. This PR makes the fix durable so future deploys can't regress. ## Test plan - [x] `pytest backend/tests/unit/test_render_backend_runtime_env.py` — 9 passed, includes new assertion that `notifications_job_secret_names` emits `{SERVICE_ACCOUNT_JSON, ENCRYPTION_SECRET, OPENAI_API_KEY, PINECONE_API_KEY}`. - [x] Manual `python3 backend/scripts/render_backend_runtime_env.py --env prod` output verified. - [x] Existing workflow-structure assertion (`test_notifications_job_workflow_passes_vpc_vars_and_checkout_sha`) still passes — the change is additive to the flag string. - [ ] Trigger `gcp_notifications_job.yml` prod deploy and verify the live job's spec shows `OPENAI_API_KEY` as `secretKeyRef` (not `value`). ## Notes / follow-ups - The live job carries several other historical literal env vars (`FAL_KEY`, `GROQ_API_KEY`, `SONIOX_API_KEY`, `DEEPGRAM_API_KEY`, `ADMIN_KEY`, `REDIS_DB_PASSWORD`, `GITHUB_TOKEN`, and more) that aren't declared in the manifest at all — the current manifest deliberately narrows `notifications-job` to just the 4 secrets it needs. Whether the extras should be added, removed, or ignored is a separate call. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Summary
vi7SA9ckQCe4ccobWNxlbdcNdC23) in dev only:MEMORY_MODE=read(already on) plusMEMORY_CANONICAL_PROMOTION_CRON_ENABLED=trueandMEMORY_CANONICAL_PROMOTION_FAST_TRACK_ENABLED=true.notifications-jobintobackend/deploy/runtime_env.yaml(env + consolidation secrets) and updatesgcp_notifications_job.ymlto render/apply that contract on deploy — so merge+deploy is enough for real ST→LT (TTL → consolidation → promotion), not a half-enabled backend-only flag flip.CANONICAL_MEMORY_USERS. Non-whitelisted users stay on legacy API with Desktop lifecycle UI fail-closed.Isolation
CANONICAL_MEMORY_USERS.MEMORY_ENABLED_USERS(dev); prod empty +MEMORY_MODE=off.resolve_memory_system().X-Omi-Memory-Canonical-Lifecycle-Exposed: true(exact).Preflight (read-only, 2026-07-08)
Firestore
based-hardwareenrollment already at read-stage for this UID:global_read_gateopen (memory_reads_enabled=true, kill switch off)write_convergence_gatereadyusers/.../memory_control/statemode=read, stage gates passed,grants.omi_chat.default_memory=truememory_state/headandv3_compatibility_projection/statepresentTest plan
python3 backend/scripts/validate-backend-runtime-env.py --env dev --check-workflowspython3 backend/scripts/validate-backend-runtime-env.py --env prod --check-workflowspytest tests/unit/test_render_backend_runtime_env.py tests/unit/test_backend_runtime_env_validator.py(19 passed)Post-merge deploy checklist (only remaining work)
workflow_dispatch.github/workflows/gcp_notifications_job.ymlwithenvironment=development,branch=main.true, allowlist = David only, secrets present (SERVICE_ACCOUNT_JSON,OPENAI_API_KEY, Pinecone, Typesense).Kill switches
MEMORY_CANONICAL_PROMOTION_CRON_ENABLED=falseon notifications-job (dev) and redeploy.MEMORY_ENABLED_USERS.CANONICAL_MEMORY_USERS+ redeploy (hard kill).Made with Cursor