Skip to content

feat: add Android production rollout brake - #22999

Merged
Git-on-my-level merged 6 commits into
mainfrom
lane/play-halt
Oct 21, 2026
Merged

Git-on-my-level merged 6 commits into
mainfrom
lane/play-halt

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Oct 21, 2026 •

Copy link
Copy Markdown
Member

Adds the manual Codemagic android-rollout-brake operator workflow for a selected Android production versionCode. Mutations require CONFIRM=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 6ad87431242e17e64a444d3e reported BRAKE_RESULT action=status versionCode=1471 status_before=inProgress status_after=inProgress userFraction=0.1. Halt build 6ad87500b1af6d6d96bcd069 reported BRAKE_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 is 6ad87586c8a443f27e294718.

Independent final status build 6ad87586c8a443f27e294718 reported BRAKE_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 ruling 0f4368. 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.sh with 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 uses ERROR_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_play environment 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).

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 21, 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-21T12:46:29.277142Z 6f2ce90 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.

@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: 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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment thread app/scripts/mobile_rollout_brake.py Outdated
).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()

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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 👍 / 👎.

Comment on lines +80 to +81
finally:
for open_id in open_edits:

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 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 👍 / 👎.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Addressed the required round-1 review and automated review in 8ae85762ec8 (pushing through gates):

  • Concurrent Play edits: this operator tool now refuses before opening an edit unless both scheduled writer workflows are manually disabled and their GitHub runs have completed. The runbook additionally requires draining their previously dispatched Codemagic builds, other manual Play writers, and Play Console. This is a quiescence prerequisite, not a claim of a distributed lock against all API users. External interference still fails closed, with a fresh status read required before another action. P20 itself disabled the advancing workflows before use and its halt was verified independently.
  • Country targeting: explicitly refuse country-targeted mutations before tracks.update. This preserves the status-only scope instead of stripping targeting. The limitation and required Console procedure are documented; a regression test covers it.
  • Existing reviews: commit requests now explicitly use changesInReviewBehavior=ERROR_IF_IN_REVIEW. The query parameter is attached to the authenticated request URI because the pinned runner SDK's static discovery schema may predate the option. The runbook also requires no unrelated Console changes waiting to be submitted, because Play edit commits can submit those too. Tests assert the safe query parameter.
  • Cleanup: unused-edit deletion is best-effort with a static warning, preserving both a verified result and the original operation error. Tests exercise both cases.
  • The minor fraction-response test gap is also closed: a response that changes userFraction is rejected without commit.

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.

@Git-on-my-level

Copy link
Copy Markdown
Member Author

Merge order: this PR first, then #23030 (store-fasttrack: brake stage action, stacked on lane/play-halt). #23030 was used live to stage Android 1.0.569/1477 at 1% over the halted 1471 (stage build 6ad8a05789e6dfa249fca407). It touches only mobile_rollout_brake.{py,md}, its tests, the android-rollout-brake workflow env and the two fixture digests, so if this PR changes those files, ping store-fasttrack on the bus to rebase.

@Git-on-my-level
Git-on-my-level merged commit b012896 into main Oct 21, 2026
57 checks passed
@Git-on-my-level
Git-on-my-level deleted the lane/play-halt branch October 21, 2026 13:20
Git-on-my-level added a commit that referenced this pull request Oct 21, 2026
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. -->
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