Repository navigation
feat: add Android production rollout brake - #22999
Conversation
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. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 601c2007d6
ℹ️ 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 action != "status" and confirm != "brake": | ||
| raise BrakeError("mutation requires CONFIRM=brake") | ||
| edit_factory = edit_factory or promote.play_edit | ||
| client, edit_id = edit_factory() |
There was a problem hiding this comment.
Serialize brake edits with scheduled rollout edits
When this lane overlaps .github/workflows/mobile_rollout_watch.yml's scheduled mobile-rollout-advance, both use the google_play service account and open an edit for the same app. Google documents that creating a new edit invalidates an active edit for the same application and API user, so even BRAKE_ACTION=status can abort an in-flight rollout hop, while a scheduled hop opening second can invalidate an emergency halt before it commits. Coordinate these workflows with a shared lock or retry protocol so the safety brake cannot fail due to the every-four-hours advancement lane.
AGENTS.md reference: app/AGENTS.md:L16-L17
Useful? React with 👍 / 👎.
| or not 0 < fraction < 1 | ||
| ): | ||
| raise BrakeError("staged release must have userFraction strictly between 0 and 1") | ||
| selected_release(expected, version_code)["status"] = after |
There was a problem hiding this comment.
Handle country targeting before halting a rollout
When the selected in-progress release has countryTargeting, this full-track update preserves that field while changing its status to halted. The Play track schema permits countryTargeting only on in-progress production releases, and the existing submit_android helper already strips it from non-inProgress writes because otherwise tracks.update rejects the request. Consequently, this emergency halt fails before commit for any country-targeted staged rollout; use a status-only patch or otherwise avoid submitting an invalid halted representation without losing the targeting needed for a later resume.
Useful? React with 👍 / 👎.
| ).execute() | ||
| if updated != expected: | ||
| raise BrakeError("Play update response did not match the status-only change; edit not committed") | ||
| client.edits().commit(packageName=promote.PACKAGE_NAME, editId=edit_id).execute() |
There was a problem hiding this comment.
Prevent the halt commit from resubmitting unrelated changes
When any unrelated Play changes are already under review, this commit omits changesInReviewBehavior; Google documents that edits.commit then defaults to CANCEL_IN_REVIEW_AND_SUBMIT, canceling the current review and submitting all changes for publishing. A production brake can therefore restart or submit unrelated release/listing work even though this lane is intended to change only the selected rollout status. Explicitly select safe review behavior or reject the operation with a clear precondition instead of accepting this destructive default.
Useful? React with 👍 / 👎.
| finally: | ||
| for open_id in open_edits: |
There was a problem hiding this comment.
Do not let edit cleanup hide a verified brake result
After a halt or resume has committed and the fresh readback exactly matches expected, the read-only edit is still deleted in this unguarded finally block. If that cleanup request has a transient failure or the edit was already invalidated, its exception overrides the successful return, so main() reports an ambiguous Play-operation failure even though the production status was already changed and verified. Make deletion best-effort after verified success, or report cleanup separately, so operators receive the authoritative brake outcome.
Useful? React with 👍 / 👎.
|
Addressed the required round-1 review and automated review in
14 targeted fake-client/operator-precondition tests pass. No further store mutation was performed during this hardening. Required round 2 will review only this delta, per the two-round cap. Official contracts checked: edit concurrency, commit review behavior, release field constraints. |
|
Merge order: this PR first, then #23030 (store-fasttrack: brake |
Follow-up to #22999 (Android rollout brake). Adds `BRAKE_ACTION=stage` to the manual Codemagic `android-rollout-brake` workflow, so a fixed build can replace a halted production rollout at an explicit small fraction. Merge after #22999. Why: David approved halting Android 1.0.568 (1471) and fast-tracking the fixed 1.0.569 (1477), which carries the pendant reconnect audio-loss fix from #22995. `mobile-store-promote` cannot be used for this: its Android path defaults to `status=completed`, which is 100% at once. What `stage` does: - Inputs: `BRAKE_VERSION_CODE` (new code), `BRAKE_SUPERSEDES_VERSION_CODE` (halted code), `BRAKE_USER_FRACTION`, a one-line `BRAKE_NOTES_LINE`, and `CONFIRM=brake`. Inputs are validated before any authentication or edit. - Refuses unless production holds the superseded code as `halted` beside completed releases only (no drafts or other staged releases), the new code is not already on production, the new code sits alone on internal or alpha under exactly one marketing version newer than the halted one, the fraction does not exceed the halted fraction, and the halted release has no country targeting. - Writes one `inProgress` release at the requested `userFraction` in place of the halted one. Completed releases stay byte-identical. The release name carries the daily train's gate receipt (`1.0.569 (gate YYYY-MM-DD-HHMM)`), so the ladder can advance it later. - Notes copy the halted release's What's New and append `BRAKE_NOTES_LINE` to en-US and to every locale holding the identical English text. Real translations stay unchanged, and Play's 500-character limit is enforced before writing. - Uses the existing commit path: exact update-response match, then `ERROR_IF_IN_REVIEW` commit, then a full-track readback in a fresh edit. Prints `BRAKE_RESULT action=stage ...`. - Halt/resume/status behaviour is unchanged. The commit/readback block moved into a shared helper. The only `.github/` change refreshes the two whole-document Codemagic digests in `.github/scripts/fixtures/codemagic_workflow_contract/v1.json`, under lead ruling `0f4368`. A scratch check confirmed every other workflow is semantically identical and only three env vars were added to `android-rollout-brake`. Validation: `backend/tests/unit/test_mobile_rollout_brake.py` now has 24 fake Play tests (11 new), all passing, plus `.github/scripts/test_check_release_process_guards.py` (121 total passed). Stage tests cover the exact written track, notes, gate-receipt name, call sequence, refusal for every non-halted status, unexpected production or source state, fraction above the halted one, bad inputs before authentication, update/readback mismatches, and a status read of the staged release. Fixes found during live use (each refused before opening any Play edit): - Codemagic rejects an empty env var value, so `BRAKE_NOTES_LINE` has no yaml default and is passed per build. - Play's Android notes are one line of entries joined by "; " (from `mobile-changelog` android_notes; 1471 held 486 characters). The stage keeps whichever shape Play holds and replaces the last entry when appending would pass 500 characters. The refusal names both lengths. - The anonymous GitHub API read from Codemagic's shared runners failed 3 times. The workflow now also loads the existing read-only `mobile_release_admission` group, and the check sends its `GITHUB_TOKEN` when present. Live use (store-fasttrack lane, David-approved fast-track; lead answer `0142bb` for the notes): - status `6ad88707d7f84e6126bb0274`: `BRAKE_RESULT action=status versionCode=1471 status_before=halted status_after=halted userFraction=0.1` - stage `6ad8a05789e6dfa249fca407`: `BRAKE_RESULT action=stage versionCode=1477 status_before=absent status_after=inProgress userFraction=0.01 supersedes=1471 superseded_status=halted superseded_userFraction=0.1 name='1.0.569 (gate 2026-10-21-1123)'` - status `6ad8a0d948119fac6ce8b698`: `BRAKE_RESULT action=status versionCode=1477 status_before=inProgress status_after=inProgress userFraction=0.01` Both GitHub Play writer workflows remain disabled; re-enabling is the release lead's call. Product invariants affected: INV-AUTH-1, INV-DATA-1, INV-BETA-1 (the shared Codemagic file matches these guards; the change only adds env vars to the Android production brake workflow and preserves all existing desktop auth, routing, signing, and Beta workflows). 🤖 Generated with [Claude Code](https://claude.com/claude-code) <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/23030?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="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a> <a href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/23030?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F23030&source=description" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img alt="Turn on auto-fix" src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a> <!-- End of auto-generated description by cubic. -->
Adds the manual Codemagic
android-rollout-brakeoperator workflow for a selected Android production versionCode. Mutations requireCONFIRM=brake, enforce the expected starting status, preserve the entire track except that release's status, and verify a fresh post-commit read before reporting success. No automatic trigger or iOS action.Android 1.0.568 (1471) was halted before this PR, under David's approval. Mandatory status build
6ad87431242e17e64a444d3ereportedBRAKE_RESULT action=status versionCode=1471 status_before=inProgress status_after=inProgress userFraction=0.1. Halt build6ad87500b1af6d6d96bcd069reportedBRAKE_RESULT action=halt versionCode=1471 status_before=inProgress status_after=halted userFraction=0.1, after committing and verifying a fresh edit. A separate final status build is6ad87586c8a443f27e294718.Independent final status build
6ad87586c8a443f27e294718reportedBRAKE_RESULT action=status versionCode=1471 status_before=halted status_after=halted userFraction=0.1.The only
.github/change refreshes the two whole-document Codemagic digests, explicitly authorized by lead ruling0f4368. Existing Codemagic workflow semantics are unchanged. Both GitHub rollout advancement workflows remain disabled. Resume has not been invoked.Validation: 14 fake Play client/operator-precondition tests passed through
backend/test.shwith an explicit file list. Covers status-only reads, halt/resume state transitions, fraction preservation, wrong status, missing/duplicate codes, malformed inputs/fractions, update/readback mismatches, country-targeted refusal, edit-cleanup failures, safe review behavior, and disabled/drained writer checks.Review hardening: before opening even a read edit, verify both scheduled writer workflows are manually disabled and their GitHub runs have finished. Operators must additionally drain already-dispatched Codemagic builds and keep Play Console idle, with no unrelated pending review changes (documented in
app/scripts/mobile_rollout_brake.md). This is an explicit quiescence prerequisite rather than a distributed lock against all Play users; external interference still fails closed and requires a new status read. The commit usesERROR_IF_IN_REVIEW, country-targeted mutations refuse rather than dropping targeting, and cleanup warnings cannot hide verified results. Resume is a permanent tool capability and was not used during P20.Full pre-push gates passed, including the Codemagic contract, existing mobile promotion/train fixtures, typecheck, and the targeted brake tests. Live validation uses Codemagic's existing
google_playenvironment group; no host GCP tier or production account data was accessed.Product invariants affected: INV-AUTH-1, INV-DATA-1, INV-BETA-1 (the shared Codemagic file matches these guards; the added workflow only operates on the Android production track and preserves all existing desktop auth, routing, signing, and Beta workflows).