Skip to content

Make automatic development backend deploys converge - #12019

Merged
Git-on-my-level merged 3 commits into
mainfrom
fix/dev-deploy-reliability
Aug 23, 2026
Merged

Git-on-my-level merged 3 commits into
mainfrom
fix/dev-deploy-reliability

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Why

Automatic development backend deploys succeeded 8 times in the last 25 runs. I tallied the 13 failures:

Count Cause
8 release SHA must still equal current main
3 Missing Firestore read-only credentials
2 Firestore index readiness failed

This fixes the two that are defects. The third is configuration and is called out below rather than papered over.

1. Admission deployed the triggering commit, and that was the wrong thing to deploy

verify_auto_backend_release_admission.py rejected the run unless the Release Eligibility proof SHA was still main's tip. Anything merging while eligibility ran therefore rejected a merged, reviewed commit — the common case on a busy main, and why development sat a day behind.

Relaxing that to ancestry, which is what this PR first did, is not enough. gpt-5.6-sol's review found two holes, both real:

  • Ancestry is not safe. Tip-equality was also a currentness fence. Any ancestor of main is accepted, so a late-scheduled run can deploy older code than development already had — Actions concurrency groups are not FIFO — and a run for a commit that has since been reverted redeploys the pre-revert tree. This runtime shares production Firestore, Firebase auth and Stripe, so that is not benign.
  • Ancestry is not sufficient. The scope job green-no-ops any triggering SHA main has moved past, before it inspects changed paths. A backend commit therefore still never deploys if an unrelated commit merges before scope runs: the backend commit no-ops for being behind, the unrelated one no-ops on its own diff.

Both follow from deploying the triggering commit. Admission now resolves the newest commit on main carrying a first-attempt successful Release Eligibility proof and reachable from current main, and deploys that. Concurrent runs converge on one target instead of racing; a revert is never undone by a late run for the commit it reverted; a behind trigger still deploys, because the target moves forward rather than the run being skipped.

--trigger-is-ancestor-of-sha keeps the resolved target at least as new as the proof that triggered the run, so a stale listing cannot move development backwards from its own trigger. The listing is fetched with curl --fail and no error suppression — unreadable means refuse to deploy.

Scope's supersession decision is removed as redundant, deleting its two GitHub API proofs and their fixture. The contract gains tripwires against reintroducing it.

The guard-checkout assertion is removed rather than preserved: sol was right that it had become true by construction, and the re-checkout it needed also made an in-flight run execute a newer guard script than the workflow invoking it.

Readiness now needs actions: read to list proofs. The manual lane's readiness job already had exactly that for exactly this lookup, so the contract expects it for both lanes rather than treating the automatic one as more restricted.

Production is untouched. It deploys only by explicit gcp_backend.yml dispatch.

2. Development had no automatic Firestore migration path

An automatic index reconciliation resolves its environment to prod, and only a manual dispatch ever targeted development. So a merged manifest addition queued the production migration for review while development kept a schema that no longer matched main — and every development deploy then failed its readiness gate until somebody noticed and dispatched the reconcile by hand. That is exactly what happened to the hourly_usage (year, month) index added by #11979.

gcp_firestore_indexes.yml gains a development job on the same push trigger. Composite reconciliation is create-only — an index only moves MISSING → CREATING → READY — and development carries no required reviewer, so it simply converges. It serializes on its own firestore-schema-development concurrency group.

Production's approval gate is unchanged: the new job never runs against it, and the existing reviewed job is untouched.

3. The manual development lane could not authenticate

Manual development deploys failed at custom_token_signing / permission_denied. Their candidate audio gate authenticates against production Firebase (FIREBASE_AUTH_PROJECT_ID: based-hardware) while running as a development deploy identity, and Identity Toolkit only accepts a custom token whose signer is authorized for that Firebase project.

firebase_release_probe_token.py can now be told which account to sign as, via IAM signJwt. Left unset the behaviour is byte-identical, so this is inert until FIREBASE_PROBE_SIGNER_SERVICE_ACCOUNT is set and the deploy identity is granted roles/iam.serviceAccountTokenCreator on it.

Not addressed here

The 3 Missing Firestore read-only credentials failures come from GCP_FIRESTORE_READONLY_CREDENTIALS being intermittently unavailable in the development environment. That credential is a deliberate privilege boundary — readiness executes admitted source and must not hold deploy credentials, which _validate_firestore_readiness_workflow_contract enforces — so it wants a configuration fix, not a code change. I considered collapsing the job and rejected it for that reason.

Product invariants

  • INV-DATA-1 — production data-plane routing is unaffected. No routing authority, project binding, or environment mapping changes. The new Firestore job targets development's own RUNTIME_GCP_PROJECT_ID and never runs against production; the probe signer defaults empty and changes no runtime path.

Review

gpt-5.6-sol reviewed this and requested changes. Its two reliability findings are fixed above; its P2 (tautological checkout assertion) is fixed by deletion.

Its P0 — that the development index lane writes to production Firestore — does not hold. RUNTIME_GCP_PROJECT_ID is based-hardware-dev in the development environment and based-hardware in prod, so the two jobs target different projects and cannot race on the same index. sol read the value from runtime_env.yaml's runtime_gcp_project rather than the deployed variable. That inconsistency between the checked-in contract and the deployed value is real and worth its own look, but it is not this lane writing to production.

sol found no defect in the probe signer, and confirmed that declining to swap the read-only Firestore credential for deploy credentials was correct.

Testing

  • .github/scripts/test_verify_auto_backend_release_admission.py — new, 7 cases; covers the forward-resolved target, refusing a target older than its trigger, and that unmerged SHAs are still rejected.
  • test_check_backend_deploy_source_admission.py — 30 pass; mutation cases now tripwire against reintroducing scope supersession, and against a completed-not-successful listing, an unmerged candidate, a hardcoded ancestry flag, and dropping curl --fail.
  • test_auto_dev_backend_scope.py — the stranding test now actually passes the later main SHA to scope. On origin/main that reproduces the strand (applies=false); here it returns applies=true.
  • 182 backend unit tests pass across the affected suites.
  • run_checks.py --lane local — 33 checks pass.

Git-on-my-level and others added 3 commits August 21, 2026 13:25
Automatic development deploys succeeded 8 times in the 25 runs before this
change. The 13 failures had three causes, and this addresses the two that
are defects rather than configuration.

Admission required the Release Eligibility proof SHA to still equal main's
tip. Anything merging while eligibility ran therefore rejected a merged,
reviewed commit -- 8 of the 13 failures, and why development sat a day
behind main. The property that protects the runtime is that the commit is
merged, so require ancestry instead. Production is untouched: it deploys
only by explicit dispatch, which already required ancestor-of-main rather
than tip-equality.

Development also had no automatic Firestore migration path. An automatic
index reconciliation resolves its environment to prod, and only a manual
dispatch ever targeted development, so a merged manifest addition left
development with a schema that no longer matched main and every deploy
failed its readiness gate until somebody noticed -- 2 more failures, most
recently the hourly_usage (year, month) index from #11979. Composite
reconciliation is create-only and development carries no required
reviewer, so it now converges on the same merge that queues the production
migration. Production's approval gate is unchanged.

The manual development lane failed separately, at custom_token_signing:
its candidate audio gate authenticates against production Firebase, which
a development deploy identity cannot sign a custom token for. The probe
can now be told which account to sign as. Left unset the behaviour is
identical, so this is inert until FIREBASE_PROBE_SIGNER_SERVICE_ACCOUNT is
set and the deploy identity is granted token-creator on it.

Not addressed here: 3 failures came from GCP_FIRESTORE_READONLY_CREDENTIALS
being intermittently unavailable in the development environment. That
credential is a deliberate privilege boundary -- readiness executes admitted
source and must not hold deploy credentials -- so it wants a configuration
fix, not a code change.

Co-Authored-By: Claude Opus 5 <[email protected]>
The static migration contract counted --provision-missing across the whole
workflow, which asserted 'only one lane applies indexes'. There are now two,
one per environment, so count per job instead and pin the development lane to
its own environment, concurrency group, and push-only trigger.

Co-Authored-By: Claude Opus 5 <[email protected]>
gpt-5.6-sol's review found the previous approach incomplete in two ways, and
both are real.

Ancestry alone was not safe. Tip-equality was doing more than proving merge
status -- it was also a currentness fence. Accepting any ancestor of main lets
a late-scheduled run deploy older code than development already had, because
Actions concurrency groups are not FIFO, and lets a run for a commit that has
since been reverted redeploy the pre-revert tree. This runtime shares
production Firestore, Firebase auth, and Stripe, so that is not benign.

Ancestry alone was also not sufficient. The scope job green-no-ops any
triggering SHA that main has moved past, before it ever inspects changed
paths. So a backend commit still never deploys if an unrelated commit merges
before scope runs: the backend commit no-ops for being behind, the unrelated
commit no-ops on its own diff. The regression test claimed to cover this but
built a later main SHA and never passed it to scope, so scope saw the backend
commit as main's tip and the assertion proved nothing. Passing it reproduces
the strand.

Both follow from deploying the triggering commit. Admission now resolves the
newest commit on main carrying a first-attempt successful Release Eligibility
proof and reachable from current main, and deploys that. Concurrent runs
converge on one target rather than racing, a revert is never undone by a late
run for the commit it reverted, and a behind trigger still deploys because the
target moves forward instead of the run being skipped. Scope's supersession
decision is removed as now-redundant, which also deletes its two GitHub API
proofs and their fixture -- the contract gains tripwires against
reintroducing it.

--trigger-is-ancestor-of-sha keeps the resolved target at least as new as the
proof that triggered the run, so a stale listing cannot move development
backwards from its own trigger. The proof listing is fetched with curl --fail
and no error suppression: an unreadable listing refuses to deploy.

The guard checkout assertion is gone rather than re-checked-out. sol was right
that it had become true by construction and added no independent evidence,
and the re-checkout it needed also made an in-flight run execute a newer
guard script than the workflow that invoked it.

Readiness now needs actions:read to list proofs. The manual lane's readiness
job already had exactly that for exactly this lookup, so the contract now
expects it for both rather than treating the automatic lane as more
restricted.

sol's P0 -- that the new development index lane writes to production -- does
not hold: RUNTIME_GCP_PROJECT_ID is based-hardware-dev in the development
environment and based-hardware in prod, so the two jobs target different
projects and cannot race on the same index. It read the value from
runtime_env.yaml's runtime_gcp_project rather than the deployed variable.
That inconsistency between the checked-in contract and the deployed value is
real and worth its own look, but it is not this lane writing to production.

Co-Authored-By: Claude Opus 5 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 30d47e6 into main Aug 23, 2026
42 checks passed
@Git-on-my-level
Git-on-my-level deleted the fix/dev-deploy-reliability branch August 23, 2026 04:01
abunet added a commit to abunet/omi that referenced this pull request Aug 23, 2026
Six commits, no conflicts. Nineteen of the forty files are Swift desktop (legacy Home
visibility, BasedHardware#11933, plus the v0.12.209 changelog). The rest is upstream's Cloud Run / GCP
deploy lane: converging automatic dev deploys (BasedHardware#12019), a preflight that can see past the
metrics sidecar (BasedHardware#12080), and the GMP secret annotation written with a project number
(BasedHardware#12081).

Post-merge audit (ADR-0029/0030): nothing to resolve.

  ports        untouched — no file under database/store/, utils/{auth,vector,object_store}/,
               _client.py, or the notification transport is in the diff at all
  fidelity     the four new backend modules (attach_cloud_run_gmp_sidecar,
               firebase_release_probe_token, preflight-cloud-run-deploy,
               runtime_env_validation/workflows) introduce no raw persistence and no
               firebase_admin.auth — they are deploy tooling, not request-path code
  guards       9/9 exit 0, including the env-parity guard: upstream declared no new runtime
               variable this time

Worth noting for our own backlog: BasedHardware#12080 and the GMP sidecar attach script are the
Cloud Run mechanism behind PROMETHEUS_SIDECAR_PORT, which the previous merge wrote off as a
shape we do not deploy. Upstream building on it confirms the write-off was the right call
rather than a gap on our side.

Verification
  contract lane 55 files, 1083 passed, 78 skipped (live-tier only), 0 failed
  full sweep 1027 files in 3m19s, FAIL set identical to the pre-merge baseline
  upstream's five new backend test files run and pass under our runner
  (8 + 9 + 13 + 18 + 49), and their two new .github guard suites pass (37 + 67 subtests)
formed2forge pushed a commit to formed2forge/omi that referenced this pull request Aug 24, 2026
)

* Make automatic development backend deploys converge

Automatic development deploys succeeded 8 times in the 25 runs before this
change. The 13 failures had three causes, and this addresses the two that
are defects rather than configuration.

Admission required the Release Eligibility proof SHA to still equal main's
tip. Anything merging while eligibility ran therefore rejected a merged,
reviewed commit -- 8 of the 13 failures, and why development sat a day
behind main. The property that protects the runtime is that the commit is
merged, so require ancestry instead. Production is untouched: it deploys
only by explicit dispatch, which already required ancestor-of-main rather
than tip-equality.

Development also had no automatic Firestore migration path. An automatic
index reconciliation resolves its environment to prod, and only a manual
dispatch ever targeted development, so a merged manifest addition left
development with a schema that no longer matched main and every deploy
failed its readiness gate until somebody noticed -- 2 more failures, most
recently the hourly_usage (year, month) index from BasedHardware#11979. Composite
reconciliation is create-only and development carries no required
reviewer, so it now converges on the same merge that queues the production
migration. Production's approval gate is unchanged.

The manual development lane failed separately, at custom_token_signing:
its candidate audio gate authenticates against production Firebase, which
a development deploy identity cannot sign a custom token for. The probe
can now be told which account to sign as. Left unset the behaviour is
identical, so this is inert until FIREBASE_PROBE_SIGNER_SERVICE_ACCOUNT is
set and the deploy identity is granted token-creator on it.

Not addressed here: 3 failures came from GCP_FIRESTORE_READONLY_CREDENTIALS
being intermittently unavailable in the development environment. That
credential is a deliberate privilege boundary -- readiness executes admitted
source and must not hold deploy credentials -- so it wants a configuration
fix, not a code change.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Update release-vector contract for the development index lane

The static migration contract counted --provision-missing across the whole
workflow, which asserted 'only one lane applies indexes'. There are now two,
one per environment, so count per job instead and pin the development lane to
its own environment, concurrency group, and push-only trigger.

Co-Authored-By: Claude Opus 5 <[email protected]>

* Resolve the newest proven main source instead of the triggering one

gpt-5.6-sol's review found the previous approach incomplete in two ways, and
both are real.

Ancestry alone was not safe. Tip-equality was doing more than proving merge
status -- it was also a currentness fence. Accepting any ancestor of main lets
a late-scheduled run deploy older code than development already had, because
Actions concurrency groups are not FIFO, and lets a run for a commit that has
since been reverted redeploy the pre-revert tree. This runtime shares
production Firestore, Firebase auth, and Stripe, so that is not benign.

Ancestry alone was also not sufficient. The scope job green-no-ops any
triggering SHA that main has moved past, before it ever inspects changed
paths. So a backend commit still never deploys if an unrelated commit merges
before scope runs: the backend commit no-ops for being behind, the unrelated
commit no-ops on its own diff. The regression test claimed to cover this but
built a later main SHA and never passed it to scope, so scope saw the backend
commit as main's tip and the assertion proved nothing. Passing it reproduces
the strand.

Both follow from deploying the triggering commit. Admission now resolves the
newest commit on main carrying a first-attempt successful Release Eligibility
proof and reachable from current main, and deploys that. Concurrent runs
converge on one target rather than racing, a revert is never undone by a late
run for the commit it reverted, and a behind trigger still deploys because the
target moves forward instead of the run being skipped. Scope's supersession
decision is removed as now-redundant, which also deletes its two GitHub API
proofs and their fixture -- the contract gains tripwires against
reintroducing it.

--trigger-is-ancestor-of-sha keeps the resolved target at least as new as the
proof that triggered the run, so a stale listing cannot move development
backwards from its own trigger. The proof listing is fetched with curl --fail
and no error suppression: an unreadable listing refuses to deploy.

The guard checkout assertion is gone rather than re-checked-out. sol was right
that it had become true by construction and added no independent evidence,
and the re-checkout it needed also made an in-flight run execute a newer
guard script than the workflow that invoked it.

Readiness now needs actions:read to list proofs. The manual lane's readiness
job already had exactly that for exactly this lookup, so the contract now
expects it for both rather than treating the automatic lane as more
restricted.

sol's P0 -- that the new development index lane writes to production -- does
not hold: RUNTIME_GCP_PROJECT_ID is based-hardware-dev in the development
environment and based-hardware in prod, so the two jobs target different
projects and cannot race on the same index. It read the value from
runtime_env.yaml's runtime_gcp_project rather than the deployed variable.
That inconsistency between the checked-in contract and the deployed value is
real and worth its own look, but it is not this lane writing to production.

Co-Authored-By: Claude Opus 5 <[email protected]>

---------

Co-authored-by: Claude Opus 5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Aug 26, 2026
…12264)

The known-audio gate authenticates against the production Firebase project
(based-hardware) because the development backend verifies user tokens there.
Since 224b2c5 split project_id from firebase_auth_project_id, the gate
corrected the token *audience* but kept signing with the development deploy
identity, which Identity Toolkit will not accept for another project. Every
manual development backend deploy has failed at
custom_token_signing/permission_denied since then, so development has been
silently refusing new deploys: candidates were built --no-traffic and never
promoted.

#12019 plumbed an escape hatch, firebase_probe_signer_service_account, but the
variable it reads has never been set and needs an IAM grant to be usable.

Sign locally with the Firebase project's own key instead. That is what
desktop_backend_auto_dev.yml already does for the identical project split, and
what .github/AGENTS.md prescribes: stage the environment-owned
GCP_SERVICE_ACCOUNT in a mode-0600 runner file, let the token minter reject
signer-project drift before the key is used, and delete the key after the probe.
No IAM change is required. The named-signer input stays available and is only
consulted when no credential is supplied.

sync_ledger_fence_cutover.yml carries the same split in its development lane and
is wired the same way; its production lane deploys into based-hardware and keeps
signing with its active identity.

Co-authored-by: Claude Fable 5 <[email protected]>
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