Repository navigation
SCA-2279: make CPU-guard-borderline backend unit tests cheap - #25312
Merged
Git-on-my-level merged 2 commits intoNov 14, 2026
Merged
Conversation
…sts stay cheap The backend unit CPU guard fails a test above 1.00 s of call-phase CPU. Four test files sat at 0.7-1.0 s on CI purely because they re-parsed large deploy documents with the pure-Python YAML loader (or re-serialized them with the pure-Python dumper) once per test: - test_conversation_erasure_queue_deploy.py parsed the 280 KB deploy/runtime_env.yaml and the 82 KB deploy-backend-stack action.yml in every test; two tests reached 1.10 s and 0.95 s on PR #25304. - test_backend_runtime_env_validator.py already loads with the C loader but rewrote the whole 280 KB manifest through yaml.safe_dump before validating. - test_pipeline_ledger_routes.py parsed the 160 KB route_policy_manifest.yaml with the pure-Python loader. - test_listen_helm_env_overrides.py re-parsed the 40 KB listen helm workflow for every _step() lookup. Each file now parses its documents once per process with the C loader (already used elsewhere in this suite) and hands out deep copies to tests that mutate. No assertion, marker, skip, allowlist entry or guard limit changed.
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. |
Git-on-my-level
deleted the
agent/m1-studio-opencode-deepseek-v4/750e04a27b82
branch
November 14, 2026 23:25
This was referenced Nov 14, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Nov 15, 2026
SCA-2012's live samples exceeded the 120-second age budget after PR #25224 deployed. Sampling ran only at the start of general maintenance, and the serving supervisor waited for that entire pass before ticking again. A deterministic test holds cleanup in flight for 180 simulated seconds and reproduces the stale gauge. Current integration head: `fdfb46738ae61a513eb1f081bcf58131e1b5a918`, a normal merge of main `d1fb900e5b` into the previously reviewed commit `8def546556dd20f13f6a835d75a1be13550d10a2`. This incorporates the CPU-test repair #25312 (merge `8614ee4cad335ca13da7df9e17875012f3985077`) that blocked the previous candidate. The merge completed without conflicts or additional source edits. Main's allowance-hold maintenance and all other current-main changes are retained; the fresh guard still has its independent timer and stored-class count cohort. Luna independently reviewed this current integration commit and posted REVIEW: SHIP on SCA-2012 at 2026-11-15 00:20:47 UTC. The subsequent merge-stage receipt confirms all eight backend shards, emulator proofs, and the hermetic merge gate passed on this commit. The guard now has an independent 20-second supervised timer on the shared DB executor, using the same maintenance leader lease. All callers retain the existing nonblocking overlap lock and 60-second count-start cadence. The timer is owned by the serving runtime and stopped with it; projection-pump-only instances do not run it. Query failures and stale samples still remove counts/ratio, and scrapes do no IO. This establishes and corrects a scheduling defect; raw production ages alone do not prove it was the sole cause of every breach. The new count-only `backend/scripts/fresh_guard_cohort.py` replaces the prescribed external `projection_cohort.py` for this acceptance check: it selects stored `fresh_capture == True` and the inclusive commit window, not fresh_first/capture age. It requires the matching read-only tier. A sample-timestamp gauge exposes the exact pre-RPC window anchor for equivalent comparisons; it expires with the counts. No documents, audio or content are read, and failed/empty windows have no healthy ratio. Failure-Class: new New class: FC-observer-cadence-coupled-to-maintenance. Prevention is independent bounded supervision while preserving leader election, overlap coalescing and sample expiry. The reusable regression artifact stalls real maintenance while exercising the real guard on a deterministic clock. Stored-state contract: no field/writer change. `OrderedMerge.commit_next` remains the sole result-class writer. Runtime reader remains the maintenance-leader guard; the only added semantic reader is the count-only acceptance CLI. Existing merge/projection/discovery/drain/enrichment/recovery/shadow/simulator/worker readers retain their semantics. No provider, hold/release, predecessor, privacy, erasure, hard-3, alert or index-shape change. Cost: unchanged count pair, roughly one read per 1,000 index entries per count (minimum two reads per pair). The timer adds up to three existing maintenance-lease checks per minute per serving replica. Each independent acceptance comparison costs a separate count pair. Its new query site has a declared planning envelope of 200 reads/comparison at 100,000 rows and 4,000/day at 20 comparisons; these are estimates, not runtime caps or booked savings. No new collection or lease role. Validation on `fdfb46738ae61a513eb1f081bcf58131e1b5a918`: - Nine isolated files through `backend/test.sh` under `bin/omi-heavy`, offline/simulator-only: 359 passed. Covers the stalled-maintenance regression, count comparison CLI, serving/config, fresh merge and provider membership, delivered-share contract, and repaired erasure deployment tests. - All 42 local preflight checks passed, including the Firestore index guard's 591 query-shape tests. - Normal bounded pre-push gate passed; no hooks bypassed. - Luna's exact-commit REVIEW: SHIP: 2026-11-15 00:20:47 UTC. Merge-stage CI receipt: 2026-11-15 00:40:07 UTC, all eight backend shards, emulator proofs, and the hermetic merge gate green. - No endpoint changed; exercised the real collector/count builders against synthetic metadata and the real maintenance path with cleanup blocked. No production action/read or live acceptance claim. Release owner must admit the correction through the existing train and verify collector retention of the new anchor gauge. Acceptance still requires two equivalent count comparisons at least 30 minutes apart within one percentage point, plus a complete healthy sample-age hour, after the admitted release. Revert through the release train or use the existing controlled guard kill switch; no data rollback. Live acceptance remains open on SCA-2012; SCA-2063 owns release coordination.
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
The original four backend unit files spent call-phase CPU re-parsing or re-serializing large deploy documents once per test. Three more guard failures were then reported on PR #25304 and #25268:
test_batch_upload_coalescing.py::test_supervisor_drains_existing_holds_while_producer_off[true],test_home_transcribing_hold.py::test_stamped_capture_remains_completed_for_batch_replacement, andtest_monthly_switch.py::test_switch_charges_monthly_first_then_voids_the_unpaid_yearly_invoice. Those three were not covered by the original #25312 diff or summary table. Their measured calls paid for cold imports of helpers/modules used by only one test. The imports now happen at module collection time, outside per-test call-phase accounting.Each YAML-heavy file parses once per process with the C loader and deep-copies only where a test mutates. Assertions remain intact. The three follow-up changes only move imports; no production code changed.
tests/unit/test_conversation_erasure_queue_deploy.pydeploy/runtime_env.yaml+ 82 KBdeploy-backend-stack/action.ymlparsed in every testtests/unit/test_backend_runtime_env_validator.pyyaml.safe_dumpbefore each validationtests/unit/test_pipeline_ledger_routes.pyroute_policy_manifest.yamlparsed with the pure-Python loadertests/unit/test_listen_helm_env_overrides.py_step()lookuptests/unit/test_batch_upload_coalescing.pytests/unit/test_home_transcribing_hold.pytests/unit/test_monthly_switch.pybilling_recovery, whichswitch()lazily imports, before the measured test callProduct invariants affected
None. No production code, guard limits, allow-list entries, markers, skips, retries, or assertions changed.
How it was verified
The guard reports call-phase CPU (
time.process_time), warns above 0.10 s, and fails above 1.00 s. It prints numeric per-test values only above the warning floor;<0.10 sis the reportable upper bound for nodes with no warning row. Before values below are from five recent main guard runs: 43613611072, 43609042294, 43608838125, 43600956507, and 43607443879, except where a stronger PR failure is cited. The original four-file fix was measured on PR run 43623704701. The follow-up import changes are at head6ccb6d91and were measured on PR run 43627834886: all eight backend unit shards and backend guardrails passed. The guard emitted no warning row for the three added test nodes, so each was below 0.10 s in that report.Runtime-validator rows explicitly report both original run
43623704701and final run43627834886, in that order. Values without a warning row use the guard’s<0.10 sreporting bound.tests/unit/test_conversation_erasure_queue_deploy.py::test_every_prod_dispatcher_names_the_queue_and_wipes_keep_theirstests/unit/test_conversation_erasure_queue_deploy.py::test_prod_contract_rejects_erasure_units_on_the_wipe_queuetests/unit/test_backend_runtime_env_validator.py::test_runtime_manifest_lake_writes_allow_dev_but_require_c4_for_prod[false-1-dev]tests/unit/test_backend_runtime_env_validator.py::test_runtime_manifest_lake_writes_allow_dev_but_require_c4_for_prod[false-1-prod]tests/unit/test_backend_runtime_env_validator.py::test_runtime_manifest_lake_writes_allow_dev_but_require_c4_for_prod[true-0-dev]tests/unit/test_backend_runtime_env_validator.py::test_runtime_manifest_lake_writes_allow_dev_but_require_c4_for_prod[true-0-prod]tests/unit/test_backend_runtime_env_validator.py::test_runtime_manifest_lake_writes_allow_dev_but_require_c4_for_prod[true-100-dev]tests/unit/test_backend_runtime_env_validator.py::test_runtime_manifest_lake_writes_allow_dev_but_require_c4_for_prod[true-100-prod]tests/unit/test_backend_runtime_env_validator.py::test_dev_lake_writes_require_real_bindings[BUCKET_OBJECT_LAKE]tests/unit/test_backend_runtime_env_validator.py::test_dev_lake_writes_require_real_bindings[OBJECT_LAKE_KMS_KEY]tests/unit/test_backend_runtime_env_validator.py::test_memory_job_retirement_rejects_captured_after_windowtests/unit/test_backend_runtime_env_validator.py::test_memory_job_retirement_rejects_reintroduced_jobtests/unit/test_backend_runtime_env_validator.py::test_memory_job_retirement_rejects_retired_cron_env_on_request_pathtests/unit/test_backend_runtime_env_validator.py::test_memory_job_retirement_rejects_retired_maintenance_controls_on_request_path[MEMORY_CANONICAL_CONSOLIDATION_ENABLED]tests/unit/test_backend_runtime_env_validator.py::test_memory_job_retirement_rejects_retired_maintenance_controls_on_request_path[MEMORY_CANONICAL_MAINTENANCE_FLEX]tests/unit/test_pipeline_ledger_routes.py::test_route_policy_manifest_declares_both_routestests/unit/test_listen_helm_env_overrides.py::test_materialize_step_installs_dependencies_before_the_secret_touches_disktests/unit/test_batch_upload_coalescing.py::test_supervisor_drains_existing_holds_while_producer_off[true]6ccb6d91tests/unit/test_home_transcribing_hold.py::test_stamped_capture_remains_completed_for_batch_replacement6ccb6d91tests/unit/test_monthly_switch.py::test_switch_charges_monthly_first_then_voids_the_unpaid_yearly_invoice6ccb6d91The three new follow-up nodes ran in Backend unit shards 4/8, 6/8, and 8/8 respectively; each shard passed. Local backend unit check passed (
1792 passed in 21.08s). The pre-push bounded gate passed;scripts/pr-preflightand static guardrail checks also passed.Tests
No assertions were added, removed, skipped, or weakened. Existing tests continue to run with the imports paid once during module collection.
UI evidence
UI-Evidence: none -- backend test-only change.
Failure class
Failure-Class: none
Full census of main CPU-guard warnings at or above 0.7 s
The changed nodes above are the addressed subset. The following exact node IDs are the remaining non-allowlisted tests observed at or above 0.7 s in the five main runs
43613611072,43609042294,43608838125,43600956507, and43607443879:tests/unit/test_backlog_release_gate.py::test_held_audio_takes_normal_priority_only_when_granted_and_never_the_vendor_tabletests/unit/test_batch_held_dead_letter.py::test_private_requeue_rpc_is_stage_bound_authenticated_and_idempotenttests/unit/test_batch_pipeline_custody_property.py::test_phone_hears_completed_only_when_every_unit_is_terminal[false]tests/unit/test_batch_pipeline_custody_property.py::test_phone_hears_completed_only_when_every_unit_is_terminal[true]tests/unit/test_batch_pipeline_left_context.py::test_kill_switch_and_onset_start_take_no_contexttests/unit/test_batch_pipeline_pull_multi_lease.py::test_batch_transaction_cuts_transactions_and_round_trips_per_lease[False]tests/unit/test_batch_pipeline_pull_multi_lease.py::test_batch_transaction_cuts_transactions_and_round_trips_per_lease[True]tests/unit/test_batch_pipeline_pull_multi_lease.py::test_one_shard_leases_in_the_same_order_as_one_lease_per_transaction[True]tests/unit/test_batch_pipeline_pull_multi_lease.py::test_write_stop_before_any_lease_commits_progress_without_parking_the_shard[False]tests/unit/test_batch_pipeline_pull_multi_lease.py::test_write_stop_before_any_lease_commits_progress_without_parking_the_shard[True]tests/unit/test_check_cloud_run_env_drift.py::test_gke_envfrom_configmap_keys_are_comparedtests/unit/test_check_cloud_run_env_drift.py::test_gke_helm_render_accepts_deployed_override_argstests/unit/test_conversation_delete_accept.py::test_53_same_second_deletes_all_return_204_fast_and_all_end_erasedtests/unit/test_conversation_transcript_offload.py::test_live_in_progress_transcript_crosses_document_limit[enhanced-True]tests/unit/test_conversation_transcript_offload.py::test_live_in_progress_transcript_crosses_document_limit[standard-True]tests/unit/test_daily_summary_job_resilience.py::test_cursor_age_metric_retains_abandonment_signature_then_resets_on_fresh_ticktests/unit/test_daily_summary_job_resilience.py::test_due_local_hours_include_half_and_quarter_hour_zonestests/unit/test_enrichment_route.py::test_legacy_sync_handler_delegates_to_the_consumer_when_routedtests/unit/test_episode_f_join_gate_metrics.py::test_refusal_counts_only_first_reason_and_keeps_join_without_extra_reads[owner-change0-snapshot]tests/unit/test_lifecycle_invariants.py::test_latch_clause[batch:leased/entry_deadline]tests/unit/test_live_stt_restart_burst_sim.py::test_sim_soniox_promotes_within_twenty_minutes_of_the_escapetests/unit/test_memories_delete_batch_chunk.py::test_unlock_helpers_fence_deletion_visible_after_memory_page[None-conversations]tests/unit/test_memory_replace_policy.py::test_canonical_dense_capture_is_bounded_before_atomic_replacementtests/unit/test_monitoring_adapter_hpa_contract.py::test_hpa_and_adapter_changes_select_this_contracttests/unit/test_pinecone_partition_migration.py::test_qualify_counts_every_split_upsert_in_generation_and_can_committests/unit/test_pinecone_partition_migration.py::test_wide_page_splits_by_complete_serialized_payload_without_losing_recordstests/unit/test_pipeline_sim_vendor_drills.py::test_holds_never_outlive_the_outage_by_more_than_one_redrive[3600.0]tests/unit/test_prerecorded_vendor_fail_fast.py::test_detect_failure_outcomes[post0-quota]tests/unit/test_prerecorded_vendor_fail_fast.py::test_detect_outcome_acceptedtests/unit/test_record_gap_fill.py::test_empty_retained_set_needs_a_valid_start[nan]tests/unit/test_record_gap_fill.py::test_empty_retained_set_needs_a_valid_start[None]tests/unit/test_record_gap_fill.py::test_empty_retained_set_needs_a_valid_start[not-a-time]tests/unit/test_record_seal_cluster_repair.py::test_jobs_kill_switch_restores_exact_old_hash_scan[off]tests/unit/test_replay_harness_capture.py::test_bucket_names_come_from_backend_config_and_runtime_overridestests/unit/test_soniox_batch_async.py::test_poll_wait_releases_http_permit_and_never_repeats_submissiontests/unit/test_text_window_abstention.py::test_mixed_invalid_text_applies_owner_without_labeling_bad_segment[window0-first]tests/unit/test_verify_backend_release_vector.py::test_deploy_script_argparse_percent_escapes[backend/scripts-*.py]tests/unit/test_voice_message_syncing_cleanup.py::test_cleanup_leaves_other_users_and_other_folders_alonetests/unit/test_voice_message_syncing_cleanup.py::test_voice_question_wav_in_syncing_dir_is_deleted_after_the_streamtests/routers/test_import_transcripts_route.py::test_route_policy_records_the_byok_check_its_auth_runsAlready allowlisted with written reasons (not changed; the
[1]parameterized row appeared in the main census and is covered by this base-node allow-list entry):tests/unit/test_speaker_learning_round2.py::test_legacy_admission_bounds_candidatestests/unit/test_sync_input_limits.py::test_opus_disk_full_mid_file_raises_capacity_pressure_and_keeps_no_prefixtests/unit/test_batch_live_preview.py::test_all_three_cohorts_share_batch_bucket_and_summary_survives_admission_rollbacktests/unit/test_batch_pipeline_pull_multi_lease.py::test_long_heads_never_push_one_transaction_past_the_write_budget[None]tests/unit/test_batch_pipeline_pull_multi_lease.py::test_long_heads_never_push_one_transaction_past_the_write_budget[1000000]The remaining nodes are workload/structural costs or runner-sensitive isolated imports, not repeated parsing of the large deploy documents fixed here. The HPA selector test walks 27 chart sources; the batch transaction, custody, partition, lifecycle and outage drill nodes exercise the volume or state space named in their assertions. No guard exception was added for any of them.
Still open
Merge and the post-merge “next three main runs” check belong to the merge/verify stages. After merge, report those run links and per-test results on the issue; then post the merge SHA so the lifecycle owner can sync.