Repository navigation
SCA-1606 Reconcile temporary app review visibility - #25123
Conversation
Codex Review Summary: ✅ CompletedThis 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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c3ac4d8d71
ℹ️ 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".
| for release in releases: | ||
| raw_codes = release.get('versionCodes', []) if isinstance(release, dict) else [] | ||
| if isinstance(raw_codes, list): | ||
| codes.update(str(code) for code in raw_codes) |
There was a problem hiding this comment.
Distinguish published Play releases from pending changes
When a production-track release is still awaiting review or publication, its version code must not be treated as proof that it is live. This reader collects codes from every release without checking its status or publication state, and reconcile_android_config immediately removes the corresponding hide. In particular, app/scripts/mobile_store_promote.py::submit_android commits production changes with changesNotSentForReview=True, explicitly holding them for manual submission. The next sweep can therefore undo the receipt's hide before review even starts. Only clear entries after establishing that the release is actually published.
Useful? React with 👍 / 👎.
| if repairs or clears: | ||
| result['hidden_versions'] = hidden | ||
| result['review_submission_entries'] = entries |
There was a problem hiding this comment.
Persist metadata removal even when no hide changes
If an iOS entry expires before Apple reports a terminal state, TTL cleanup removes its hide and leaves an expired tombstone. On a subsequent REJECTED sweep, the reconciliation loop removes that tombstone locally, but neither repairs nor clears increments because the version is no longer hidden, so this guard discards the metadata change. If the same version later reenters review and its submission hook is missed, the retained tombstone prevents reconciliation from hiding it again. Persist changes to the entries independently of the hide counters; the Android reconciliation has the same metadata-only cleanup problem.
Useful? React with 👍 / 👎.
| from google.auth.transport.requests import AuthorizedSession | ||
| from google.cloud import firestore | ||
|
|
||
| from database._client import db, run_transactional |
There was a problem hiding this comment.
Use the required call-time Firestore client accessor
This new service imports and uses the legacy db proxy for all lifecycle reads and transactions. backend/AGENTS.md explicitly prohibits using that proxy in new code and requires get_firestore_client() at call time, with injectable client parameters on converted helpers. Resolve the client at the service boundary and pass it through the persistence helpers rather than adding another dependency on the retired compatibility interface.
AGENTS.md reference: backend/AGENTS.md:L180-L180
Useful? React with 👍 / 👎.
| except StoreCredentialsUnavailable: | ||
| summary['store_errors'] += 1 | ||
| report_lifecycle_alert(platform, 'credentials_unavailable', 'using TTL-only cleanup for this platform') | ||
| logger.warning('app_review_config store credentials unavailable platform=%s; TTL continues', platform) |
There was a problem hiding this comment.
Instrument TTL-only degradation with the shared fallback helper
When store credentials are unavailable, this branch continues in TTL-only mode but emits only lifecycle-specific metrics and logs. The equivalent store-API exception branch does the same. These are new degraded fallback paths, for which backend/AGENTS.md requires utils.observability.fallback.record_fallback; without it, the shared fallback telemetry misses both transitions. Record the degraded outcome in both branches while retaining the domain alerts.
AGENTS.md reference: backend/AGENTS.md:L322-L322
Useful? React with 👍 / 👎.
| session: Any = None | ||
| try: | ||
| raw = json.loads(load_secret(SECRET_NAMES['play'])) | ||
| from google.oauth2.service_account import Credentials |
There was a problem hiding this comment.
Move the Play credentials import to module scope
backend/AGENTS.md requires all imports at module scope and explicitly forbids imports inside functions. The new Play reader introduces a function-local Credentials import despite the rest of its Google authentication dependencies already being imported at module scope. Move this import alongside those dependencies to comply with the backend's documented import convention.
AGENTS.md reference: backend/AGENTS.md:L166-L168
Useful? React with 👍 / 👎.
| "type": "prometheus", | ||
| "uid": "prometheus" | ||
| }, | ||
| "expr": "sum(increase(omi_app_review_config_alert_total[15m])) > bool 0", |
There was a problem hiding this comment.
Allow lifecycle metrics through the sync monitoring pipeline
For the scheduled backend-sync worker, these alerts cannot observe the events they are meant to report: backend/deploy/cloud_run_gmp_sync.yaml:55 drops the new omi_app_review_config_* families through its keep regex, and backend/charts/monitoring/prometheus-stackdriver-exporter/prod_sync_omi_cloud_run_metrics_exporter.yaml also omits them from its explicit import prefixes. The general Cloud Run exporter excludes sync namespaces, so it does not provide an alternate path. Consequently, store failures never reach this lifecycle alert, and enabling the dead-sweeper rule will not make successful sync ticks visible either. Add the new families to both stages of the sync monitoring pipeline.
Useful? React with 👍 / 👎.
| if active is not None: | ||
| if _append_hidden(hidden, version): | ||
| repairs += 1 |
There was a problem hiding this comment.
Take ownership of hides newly added during repair
If a submission initially matches a manual hide, its lifecycle entry correctly has owns_hidden_version=False. But if an operator subsequently removes that hide while the entry is active, this repair branch adds the version back without updating ownership. When the 14-day lease expires or Apple reaches a clear state, _remove_owned_hidden refuses to remove the newly created hide, leaving it permanent. The Android repair branch has the same behavior. When reconciliation actually inserts a missing hide, mark that entry as owned so the lifecycle can later remove the hide it created.
Useful? React with 👍 / 👎.
| Grant `roles/secretmanager.secretAccessor` on only these three secrets to | ||
| `[email protected]`. Do not put the ASC or Play |
There was a problem hiding this comment.
Grant submission-token access to the public API identity
Following these activation instructions grants secret access only to the Cloud Run identity, but the Codemagic hook posts to https://api.omi.me, which is served by backend-listen according to backend/charts/backend-listen/prod_omi_backend_listen_values.yaml:327. That workload uses [email protected] (the same values file, line 40), not backend-runtime@.... Since the submission handler loads its expected token using ADC on every request, the documented setup leaves receipt requests returning 503 even after all activation steps are followed. Grant the submission-token secret to the backend-listen identity as well, or direct the hook to the service whose identity receives the grant.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 39541be3a6
ℹ️ 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".
| if before_hidden: | ||
| clears += 1 |
There was a problem hiding this comment.
Count only hides actually removed during reconciliation
When a legacy/manual iOS hide matches a terminal store version, before_hidden is true even though there is no owned lifecycle entry to remove. Consequently, reconciliation preserves the hide but reports clears=1 on every sweep. I reproduced this across consecutive ticks with hidden_versions=['1.0.500'], no lifecycle entries, and READY_FOR_SALE. Since the sweep passes every nonzero clear count to report_lifecycle_alert, these intentionally preserved entries generate recurring false live_hide_cleared alerts. Increment the counter only when _remove_owned_hidden actually removes a hide.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6edba5729f
ℹ️ 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".
| if any(_same_visible_version(item, version) for item in hidden): | ||
| return False |
There was a problem hiding this comment.
Widen build-qualified hides for semantic-version submissions
If hidden_versions already contains 2.1.0+22 and build 2.1.0+23 is submitted, this comparison treats the existing build-specific hide as covering the whole semantic version and skips adding 2.1.0. However, mobile requests include the build number (app/lib/utils/platform/platform_manager.dart), and the serving reader compares both build numbers when present, so 2.1.0+23 remains visible. Reconciliation calls the same helper and cannot repair this state. Ensure that recording a semantic-version submission adds a hide covering all its builds rather than accepting a narrower build-qualified entry as sufficient.
Useful? React with 👍 / 👎.
# Conflicts: # backend/charts/monitoring/gmp-query-migration-inventory.json # backend/deploy/cloud_run_gmp_sync.yaml
# Conflicts: # backend/tests/unit/test_batch_upload_coalescing.py # backend/tests/unit/test_conversation_erasure_queue_deploy.py # backend/tests/unit/test_home_transcribing_hold.py
# Conflicts: # backend/deploy/cloud_run_gmp_sync.yaml
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: ad4619ff33
ℹ️ 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".
| monkeypatch.setattr(lifecycle.firestore, "transactional", lambda callback: callback) | ||
| transaction = Mock() |
There was a problem hiding this comment.
Use the required strict Firestore transaction fixture
This test exercises document-reference reads and a transactional set, but replaces the transaction with an unconstrained Mock. It would continue passing if _update_config performed reads after writes, which Firestore rejects in production. backend/AGENTS.md explicitly requires StrictFirestore for this service-boundary test pattern; use that fixture so the persistence test enforces transaction ordering and stored-value constraints.
AGENTS.md reference: backend/AGENTS.md:L232-L232
Useful? React with 👍 / 👎.
| if not supplied or not hmac.compare_digest(supplied, expected.encode("utf-8")): | ||
| raise HTTPException(status_code=401, detail='invalid submission token') |
There was a problem hiding this comment.
Emit the rejected-token event before returning 401
If Codemagic has an incorrect or out-of-sync submission token, this branch rejects every receipt without emitting a lifecycle alert. The hook deliberately logs failures and returns success, so submissions can stop creating hides without triggering the new paging rule, even though that rule explicitly selects submission_token_rejected. Record a bounded rejected-token reason here and add it to AppReviewConfigReason; otherwise the documented rejected-token activation check cannot pass.
Useful? React with 👍 / 👎.
| if [[ -n "$JOBS" ]]; then | ||
| read -r -a JOB_ARGS <<< "$JOBS" | ||
| fi |
There was a problem hiding this comment.
Prefix selected scheduler job names with --jobs
When the workflow's new jobs input is populated, JOB_ARGS contains only bare job names, which both invocations append after --apply or --check. The reconciler's CLI help specifies --jobs JOBS [JOBS ...] (“Limit reconciliation to these declared job names”), and its parser in backend/scripts/scheduler_reconcile.py:303–316 accepts no positional arguments. Executing that parser with the workflow-style arguments rejects app-review-config-sweep-hourly as unrecognized and exits with status 2. Consequently, the documented planned-job deployment and subsequent scoped checks cannot run. Include --jobs in the argument array whenever a selection is supplied.
Useful? React with 👍 / 👎.
| for entry in reversed(entries) | ||
| if entry.get('platform') == platform and entry.get('version') == version and entry.get('state') == 'active' |
There was a problem hiding this comment.
Check the lease deadline before reusing an active entry
If a fresh submission arrives after the previous lease's deadline but before the hourly sweep marks it expired, this lookup still selects the old entry because its persisted state remains active. The receipt is then accepted with the already-expired deadline instead of receiving a new 14-day lease. The next sweep removes its hide and leaves a tombstone, preventing iOS reconciliation from restoring the hide during the new review. This also occurs after a sweeper outage. Only preserve the previous deadline for an active lease whose expires_at is still in the future; treat an elapsed lease as expired when processing the fresh receipt.
Useful? React with 👍 / 👎.
# Conflicts: # backend/config/flag_budget.json
# Conflicts: # backend/config/flag_budget.json
|
Shard 1/8 at 26bf873 hit the fast-unit CPU guard in |
UI-Evidence: none -- backend lifecycle, monitoring, release operator docs; no UI changed. ## Summary - Held Android manual promotions write production releases as `draft`; the sweep only clears a hide after a genuinely completed rollout. Fresh receipts renew an expired lease, and first-sight reconciliation repairs missing receipts without reviving expired tombstones. - Page on missing and rejected submission tokens after three lifecycle failures within three hours; the reasons reach the real alert rule and generated export. - Close the remaining lifecycle, Play edit contention, metrics inventory, route-policy, rollout-brake, and operator-runbook gaps from the independent audit. The brake authenticates the scheduler pause read with the existing read-only identity and fails closed on missing or denied access. ## R1 decision Use the write-side fix. When `changesNotSentForReview` is enabled, an omitted Android release status defaults to `draft`; otherwise it remains `completed`. A held draft cannot be mistaken for a live rollout by the sweep, while a genuinely completed rollout remains the approval signal. This avoids exposing a staged fraction before review. ## Audit coverage - Android reconciliation creates a 14-day hide on first sight of a non-completed production code, repairs active hides without extending a same-build lease, and preserves expired tombstones. A fresh authenticated receipt for a replacement build receives a new full lease, and completing an older build cannot clear a same-version replacement build's hide while it remains pending. - The parent lifecycle uses a call-time Firestore resolver, a valid module-scope `Credentials` import, TTL-only cleanup on store failure, and semantic/build-aware hide matching. Credential, store, and submission-token failures page through the wired alert path. - Sweep and promotion paths retry Play edit conflicts with bounded exponential backoff. Failed validation, track reads, updates, or commits abandon the uncommitted Play edit so retries are not blocked; committed edits are never deleted. The rollout brake verifies both manually disabled/drained GitHub writers and the paused scheduler; its fresh-runner path uses the existing `google_play` service-account credentials and the API-supported `cloud-scheduler` OAuth scope, with read-only access enforced by IAM. Missing or denied `cloudscheduler.jobs.get` access fails before a Play edit. - Declared the wired submission limiter as `fail_open` in the route manifest. Added the sweep counter and `outcome` label to the metric contract. - Regenerated the combined alert export and GMP inventory after resolving parent/child generated-file conflicts. The inventory reports `combined_equals_split: true` and retains all 326 query consumers. - Expanded parent and child runbooks with the freeze, credential/deploy order, pre-activation probes, first-tick snapshot and checks, deadman verification, receipt authentication, rotation, and rollback. Activation requires parent #25123 first and the final repaired child code merged and deployed; the scheduler remains planned and paused until separately authorized. ## Branch and merge order Parent PR #25123 merged to `main` at `bc7e79190a84` (2026-11-15 06:40Z). This PR targets `main`, currently based on `18a774e84662`; child head `05e5df7b4c79` includes a normal merge of that current base. The child retains its lifecycle and operational changes, including the `d1c77ea6` hermetic Play SDK test fix. The prior `origin/lane/sca-1606` event failed before tests because the parent branch had been deleted; that stale-base event is resolved by the current `main` integration. The alternative branch `lane/sca-1619-studio` remains untouched. ## Product invariants affected - `INV-AUTH-1`, `INV-DATA-1`, and `INV-BETA-1` are inherited from stacked PR #25123. This follow-up does not change session ownership, production-family data-plane authority, or beta identity. ## Verification - Parent #25123 passed its normal bounded pre-push gate at `8e767d02812d169e90e1ab75a5e2c07a5ba2f2c5`; the targeted lifecycle/alert/GMP suite passed 116 tests. The previously timing-sensitive shard-6 scope passed a 50-test local rerun. - On the merged review head, the targeted lifecycle, brake, boundary, route-policy, scheduler, monitoring telemetry, and strict-transaction suites passed 251 tests. `backend/.venv/bin/python app/scripts/mobile_store_promote_test.py` passed 37 tests, `backend/.venv/bin/python app/scripts/mobile_daily_train_test.py` passed 105 tests, and `backend/.venv/bin/python .github/scripts/check-release-process-guards.py` passed. `git diff --check` passed. - The brake tests use fake GitHub/Scheduler responses and fail closed on denied scheduler reads. No live scheduler/IAM/store read or additional grant was made. API routes run on `backend-sync` under `backend-runtime`; this stack does not request `backend-listen` access. - New-head GitHub required checks and current-head author approval must be refreshed after publication. Keep SCA-1619 blocked until the required checks and approval gate pass; do not retarget or bypass the gate. - No production writes, credential creation, scheduler operations, PR merge, deployment, or activation were performed. Failure-Class: new Line-Count-Exception: backend/utils/metrics.py | 1765 -> 1817 | the integrated stack carries the app-review lifecycle metrics and their reason labels without splitting the existing metric module
What changed and why
Adds a bounded review-visibility lifecycle: successful store submissions are reported by Codemagic, then an internal sweep reconciles App Store Connect and Google Play state and expires temporary hides after 14 days. The app-review read path and its parity behavior remain unchanged.
Current-main repair (2026-11-14)
mainat3980a409cb9bwith a normal merge. The GMP inventory now contains 326 consumers, preserving main’s batch-census and newer metric consumers alongside both app-review consumers.get_firestore_client()at each lifecycle access. Store read failures still run TTL cleanup and emit boundedomi_fallback_totaltelemetry for thettl_onlypath.Product invariants affected
Line-Count-Exception: backend/utils/metrics.py | 1765 -> 1816 | add pre-zeroed app-review lifecycle alert and sweep metrics.
How it was verified
python3 app/scripts/mobile_store_promote_test.py: 32 passed.python3 .github/scripts/check-release-process-guards.py: passed.PYTHON=./.venv/bin/python bash test-preflight.shfrombackend/: 17 passed, 9 optional environment warnings, 0 failed.0f7b038d4c5b, hosted shards exposed the stale inventory and split/combined alert mismatch; both artifacts are regenerated on this follow-up. Two separate timing-guard files were rerun with the prescribedbackend/test.shrunner throughomi-heavy: 50 passed, with CPU-time warnings below the 1.0-second failure limit. The refreshed head still needs GitHub checks.backend/test.shrun reported timing/load failures intest_live_recovery_matrix.py,test_qualify_parakeet_route.py, andtest_backend_test_runner.py. Each file passed its prescribed isolated rerun (103 passed/3 deselected, 34 passed, and 16 passed respectively); no reproducible failure remained.Tests
Coverage includes held/draft Play releases remaining hidden until a completed rollout, clearing legacy iOS hides when ASC is live or terminal, adoption and expiry of pre-existing hides, build-qualified iOS version matching, tombstone persistence, bounded and rate-limited submission receipts, Codemagic hook failure handling and staging override, Play edit-conflict retry, workflow environment-group scope, and alert paging policy.
UI evidence
UI-Evidence: none -- backend and release automation only.
Failure class
Failure-Class: FC-metric-dropped-by-scrape-allowlist
Operational notes and deviations
plannedandPAUSED; it runs at minute 17 to avoid the rollout-watch and daily-train Play edit windows, and retries one edit-creation conflict.status == "completed"counts as live. Draft, in-progress, and held releases remain hidden. The 14-day lease is the staged-rollout backstop. When a lease expires, the hide stays off for that version until a new submission is recorded; its tombstone prevents reconciliation from re-hiding it.1.0.547+20when ASC reports1.0.547. The current poller does not query the separatemacosdocument; its existing1.0.80+501entry remains a manual cleanup decision after checking store state. Unmatched legacy iOS entries also require a separate manual decision.app_review_configenvironment group empty. It is referenced only bymobile-store-promoteandmobile-daily-train; Codemagic rejects missing groups. The hook is best-effort after a successful store submission. Do not add the token until the scheduler is enabled and one successful sweep tick is confirmed.INV-AUTH-1andINV-BETA-1becausecodemagic.yamlchanged. Those desktop auth and beta contracts are untouched; only the two mobile workflow group bindings changed here, so the affected-invariant list above intentionally citesINV-DATA-1alone.backend-runtime. The submission and sweep routes run onbackend-sync; do not grantbackend-listenaccess for them. Probe the narrowest ASC read role and verify on a staging app that the Play role can create/read/delete an uncommitted edit before production activation; a view-only Play role has not been verified to allow this.production, and deletes it without committing. Internal and alpha tracks are not queried.