Repository navigation
Conversation
The pre-deploy runtime-env gate now validates the artifact the renderer produces (BasedHardware#12098), but that artifact only carries services. `_validate_cloud_run` skips its whole job branch when the state has no `jobs` key, so the env, secret and `forbidden_env` contract declared for notifications-job and memory-maintenance-job is no longer checked anywhere: the job workflows run the validator with `--check-workflows` only, and the post-deploy live check is services-only by design. The comment in `_fetch_live_cloud_run_state` still promises that "the job contract is still validated statically against the rendered state". Render jobs into the state from the same helpers that already render their deploy inputs in the same invocation, so the gate sees them again. Failure-Class: FC-mirrored-model-omits-new-member
kodjima33
approved these changes
Aug 24, 2026
kodjima33
left a comment
Collaborator
There was a problem hiding this comment.
Fixes a real gap left by #12098: the rendered runtime-env state omitted Cloud Run jobs, so the env/secret/forbidden_env contract for notifications-job and memory-maintenance-job was validated nowhere. Verified not yet fixed on main. Scoped, tested, CI green. Confidence 5/5.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed and why
#12098 moved the pre-deploy runtime-env gate onto the artifact the renderer produces, which is the right shape — but
_render_cloud_run_stateemitsservicesonly._validate_cloud_runskips its entire job branch when the state has nojobskey (backend/scripts/runtime_env_validation/cloud_run.py:140-141), so the env, secret andforbidden_envcontract the manifest declares fornotifications-jobandmemory-maintenance-jobis now validated nowhere:gcp_notifications_job.yml:115,gcp_memory_maintenance_job.yml:156,gcp_memory_maintenance_job_auto_dev.yml:130) call the validator with--check-workflowsonly, so no Cloud Run state is loaded there either;--check-live-cloud-run, which is services-only on purpose._fetch_live_cloud_run_statestill documents the guarantee that has gone: "The job contract is still validated statically against the rendered state."_render_cloud_run_statenow renders jobs too, through the same helpers that already render those jobs' env, secrets and flags fordeploy-cloudrunin the same invocation — a full render (no--job) always renders every job, so this adds no new failure mode. The shared "env entries plus secret refs" step is factored into_render_state_envso a service and a job cannot drift apart in how they are rendered.Fixing it in the validator instead (treating a missing
jobskey as an error) would break the post-deploy live check, which deliberately reports services only because jobs are deployed by their own workflows. The renderer is the layer that lost the data; the second test below is the ratchet against narrowing it again.Product invariants affected
none
How it was verified
Against the repo's real
backend/deploy/runtime_env.yaml, withHOSTED_PUSHER_API_URLinjected intonotifications-job.env— a name that job's ownforbidden_envlist rejects:48d9625908^(the commit before fix(deploy): validate rendered runtime env before apply #12098),validate_runtime_env(env='dev', check_rendered_cloud_run=True)reportscloud_run/notifications-job: forbidden env HOSTED_PUSHER_API_URL is present;02c48d7da6(current main), rendering with--state-outputand validating with--cloud-run-statereports[]— the deploy gate passes the violation;cloud_run/notifications-job: forbidden env HOSTED_PUSHER_API_URL is presentagain.Not a red-vs-green claim only: on the unmodified manifest the rendered state now carries
{'memory-maintenance-job', 'notifications-job'}for bothdevandprod, andvalidate_runtime_envreturns no errors for either environment, so the restored check does not turn the deploy red.python -m pytest tests/unit/test_render_backend_runtime_env.py tests/unit/test_backend_runtime_env_validator.py tests/unit/test_attach_cloud_run_gmp_sidecar.py tests/unit/test_verify_backend_release_vector.py— 173 passed.state['services'][service]['env']only (attach_cloud_run_gmp_sidecar.py:205-223), so the addedjobskey does not affect--expected-env-state; its suite is in the run above.black --check backend/scripts/render_backend_runtime_env.py backend/tests/unit/test_render_backend_runtime_env.py— clean.Not verified against a live GCP project: the change is to the rendered artifact and to offline validation of it.
Tests
backend/tests/unit/test_render_backend_runtime_env.py:test_state_output_carries_cloud_run_jobs— the regression test; before the change it fails withKeyError: 'jobs'. It pins the whole job entry, including that a secret binding is rendered as asecretKeyRefand that the job's own flags (not the shared network flags) are carried.test_state_output_covers_every_declared_job[dev|prod]— the ratchet against a future "services only" narrowing: every job the real manifest declares must appear in the rendered state. Also red before the change.Failure class (fixes)
The rendered state is a hand-written mirror of the manifest's Cloud Run inventory: it restates which units exist rather than deriving them, so the units it omits are dropped in silence — no decode error, no unhandled case, no failing test, because the mirror stays internally consistent.
_render_state_envand the per-job loop derive the state from the manifest's own inventory, andtest_state_output_covers_every_declared_jobmakes an omission fail instead of disappear.Failure-Class: FC-mirrored-model-omits-new-member