Skip to content

test(backend): make sixteen CPU-heavy or timing-dependent unit tests cheap and deterministic - #25381

Merged
Git-on-my-level merged 3 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/q12-deflake
Nov 15, 2026
Merged

Git-on-my-level merged 3 commits into
BasedHardware:mainfrom
Git-on-my-level:lane/q12-deflake

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Summary

Make backend unit tests deterministic under the call-phase CPU guard and shared-runner load. Keep the real Firestore 1 MiB boundary, transaction/write ordering, 20-day alert replay, sample-exact real ffmpeg round trips, and separate deterministic codec-budget fallback coverage. Move immutable fixture scans/compression and cold imports out of call phases; reuse identical pure alert-expression evaluations.

Production code, guard thresholds, allowlists, markers, and CI workflows are unchanged.

Failure-Class: none

This is test-harness determinism and fixture-cost work; no existing product failure class applies. The existing CPU guard and real-clock budget ratchet remain enforced.

Validation

  • Three before/after measurements through backend/test.sh, file isolation and the 1.00 s CPU guard on. Exact commands, all timings, sweep coverage and remaining offenders: data/run-2026-11-15-quality-12h/q12-v-deflake.md in the omi-workspace checkout.
  • Canonical backend typecheck: cd backend && PYRIGHT_PYTHON="$PWD/.venv/bin/python" bash scripts/typecheck.sh — zero errors (existing warnings).
  • cd backend && .venv/bin/python -m pytest tests/unit/test_real_clock_budget_ratchet.py tests/unit/test_llm_gateway_coverage_guardrails.py -m "slow or not slow" -q — 37 passed; one known current-main failure in test_sync_playback_metadata.py, owned separately by Q12-T. This branch deliberately leaves that file untouched.
  • Installed pre-push hook exercised without pushing; final result recorded in the handoff.

All test execution unsets GOOGLE_APPLICATION_CREDENTIALS and every CLOUDSDK_* variable, sets BACKEND_UNIT_FILE_BUDGET_SECONDS=900, and runs through omi-heavy. No production access.

Risk and rollback

Test-only change. Fixture caches hold actual codec output for exact input bytes and do not replace transaction, encryption, lake-envelope, decode, or document-size checks. Alert replay still runs the real episode state machine on every five-minute tick. Roll back by reverting the lane commits.

Author model: GPT-6.1 Sol; integrated by Claude Fable 5.2.

🤖 Generated with Claude Code

View guided diff

Git-on-my-level and others added 3 commits November 15, 2026 15:30
Keep real document limits and codec round trips while moving immutable fixture work and cold imports out of test calls. Reuse pure alert evaluations without shortening the replay timeline.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
Keep all recovery, HTTP, watermark and truncation assertions while removing first-use import cost from guarded test calls.

Failure-Class: none

Co-Authored-By: Claude Fable 5.2 <[email protected]>
@Git-on-my-level
Git-on-my-level merged commit 52523bc into BasedHardware:main Nov 15, 2026
57 checks passed
Git-on-my-level added a commit that referenced this pull request Nov 15, 2026
#25374)

The old integration canary hard-pins the previous carrier and
participates in a four-service deployment. This extension adds an
integration-only transport inside the existing production workflow:
exact eligible source/digest, composition from the retained serving
revision, removal of only the two 200/10 overrides to prove shipped
100/20 defaults, and staged same-run continuation with the saved
inverse. Existing consumer/listen/pusher image-only routes stay
Release-owned and precede integration.

Captain ruling SCA-2283 `01a1de4c-ad87-7cbc-a06e-9c04c19f1580`
explicitly delegates this run's post-wrap guard to Pipeline. Default
`post_wrap_guard: internal` still refuses without a trusted adapter.
Explicit `external` skips only that adapter, preserving 25%/five-minute
hold, 100%/20-minute CPU/request watch,
source/OCI/config/readiness/traffic proofs, CAS and failure/cancellation
rollback. Unknown modes or external mode outside the integration-only
scope refuse.

The existing public input selects external mode with
`service_images=integration-canary=<immutable backend
digest>,post_wrap_guard=external`. The workflow binds that exact
selection to the composite input and prepare flag; omitting it never
selects external. No public trigger/input/job/runner/budget or
credential/IAM change is introduced.

External completion exports metadata-only
`phase=external_guard_pending`, Pipeline ownership and actual receiving
revision/UID/source/digest/config/generation/run binding with verified
100/20 settings and 200/10 inverse. It never marks wrap/recount/progress
healthy. Pipeline's read-only guard owns subsequent proof and posts
ROLLBACK; Release alone executes the inverse. Captain ruling
`01a1de53-b889-73a6-9cad-177c8e123c1a` permits FreshGuard alone when the
stock signal needs a new scan; Pipeline's 08:40 disposition selects that
lane with the absent stock baseline stated, not fabricated. Arming
requires a complete cursor circle after receiving/config verification
and unchanged committer identities. Missing, unbound, expired or
zero-denominator FreshGuard evidence is UNKNOWN. The four existing
workflow artifacts remain the handoff; private environment/journal
content is never uploaded.

**Post-job recovery disposition:** captain ruling
`01a1de67-42e8-78e9-8b54-ee9bb02c1561` resolves the handoff without new
controller code. After the job exits, Release uses prod-operator to
route 100% traffic to the saved pre-restoration named revision with
verified 200/10 settings. Before dispatch, Release records that
identity/settings and dry-runs the traffic return; it refreshes the
packet if a newer 200/10 revision serves first. Within-run
failure/cancellation still uses the private same-run controller journal,
which must never be exported. A durable controller inverse remains a
nonblocking follow-up, so the runbook's statement that no such interface
exists still holds.

Historical Luna successor-delta SHIP is recorded in SCA-2225 comment
`01a1de64-2b19-73fa-958d-26b66e096742` for `468b26227f`. The subsequent
test-only CI repair updates three existing workflow-contract files to
preserve integration-only queue/development-smoke exclusions while
retaining ordinary production checks. All 63 native tests in those files
pass; production code is unchanged.

Normal main integration now merges
`6ed88eaceb5e4b8aff62e8d7a9e19410865c58c7` as
`91529e9cede9fcf6eec71df5aab8d98c7480daa2`, with #25381 and #25383
ancestral. It is a clean merge with zero changes to the PR's 14 owned
files compared with `952d8bbd41`; inherited main changes are not new
controller decisions. The shared playback 0.001-second timeout is
repaired by main's deterministic Future timeout simulation. Preserve the
old failed CI receipts: `952d8bbd41` also hit CPU guards in unchanged
input-retention and pusher-reference tests, so actual native regression
and exact-successor CI are still required. No red-CI waiver, rerun or
budget increase is claimed. Control-source integration does not repin
the application: captain ruling `01a1de89-5ee9-70db-8e47-627a6dc2856a`
keeps `afa75349` for the first 100/20 restoration after its 200/10 image
acceptance; later carriers remain Release-owned.

Final successor `91b687523abf8c2044b2a556f24c2caca3949384` adds only one
test-setup repair after that merge: the retention test's shared fixture
import is resolved at collection, matching the landed
fixture/provider-model setup pattern. Its assertion/behavior AST is
unchanged. The native test initially reproduced a 1.09-second
cold-import CPU failure; after the change the retention file's 113 cases
and shared fixture's 232 cases pass under the unchanged fast guard. The
existing slow-clock guardrail command also passes all 11 cases; its
original slow marker and CI tier are unchanged. Pusher-reference's 35
cases pass. Normal final push, with the supplied PR body, passes 58
manifest checks and 516 selected native tests. Fresh exact-head terminal
CI and normal review-carry/admission remain required; these local
receipts do not waive or manufacture green CI.

The `91b68752` CI is preserved as terminal 39 SUCCESS / 25 SKIPPED / 2
FAILURE: pusher binding's dev case still spent 1.05 seconds in repeated
pure-Python manifest parsing, and the aggregate correctly refused.
Test-only successor `2dd6e8c28a903d90d71a87562fd4852883e286fa` reuses a
module-scoped immutable manifest parsed with PyYAML's safe C loader
(safe-loader fallback retained). Both dev/prod cases and their assertion
AST remain unchanged. Local parsed documents are equal; measured parse
CPU fell from 0.284s to 0.040s, and all 35 file tests pass under the
unchanged one-second guard. No production, marker, allowlist or budget
change; no blind rerun. Exact-successor CI remains the authority.

True upload-to-durable-transcript latency stays **UNMEASURED** and is
not a restoration blocker under captain ruling
`01a1ddc7-ad39-75e0-a8de-ad7088463568`. No HTTP, CPU, commit or audio
proxy replaces it.

INV-DATA-1: customer identity/data-plane routing remains
`based-hardware`; only Cloud Run controller scope and metadata proof
change. Consumer/GKE/queue writers are excluded from the new profile.
Native source eligibility, Firestore, protected production
approval/concurrency and unchanged rollback windows remain. No author
production read, deployment, source repin, scaling, privacy or
provider-release activation.

Verification: 273 focused native tests passed (122 controller, 49 canary
workflow, 102 workflow contracts) via explicit
BACKEND_UNIT_TEST_FILE_LIST and backend/test.sh, retaining the
one-second fast-test CPU guard. Normal pre-push, actionlint, concurrency
and CI-budget results accompany the published head. Same Luna reviewer
checks the extension/successor delta only; this is not a third full
review of merged #25345. Exact-head green CI and canonical admission are
required before merge or execution.


Current integration recovery:
`2a54056b3bda6990c9c179059d0c4099fd357eac`, normal merge of
maina0352a778445281a5d7ecbd45fc66fa0e5fa9105
over2dd6e8c28a903d90d71a87562fd4852883e286fa. Incorporates actual
canonical shared Quality playback repair25386, not rerun-to-green. Sole
conflict test_verify_pusher_config_references.py overlaps shared
safe-YAML/intake fixtures; retain main canonical fixtures, resolvedfile
matchesmain. All reviewed ownednon-testfiles
unchanged.1729focusedtests/28isolatedfiles pass via canonical omi-heavy
SHA2560f176f780fd976ad7ea7c75f845ea7e8f8213f4b45bf55e218283aae28195ea4
on approvedStudio, userdavid/Darwin, defaults/placement unchanged. No
budget/timeout/marker/skip/assertion relaxation or CI rerun; earlier
actual teardown failure remains recorded. Normal hooks/gates run;
current-head terminalCI and normalReleaseadmission remain required. No
third review or old-headSHIPcarry invented. Separate next-day
selector/hook work is untouched. Existing Release/captain owns runtime
pin/slot and100/20; no source-containingcarrier, activation or
serving/savings inferred. Original intervention CLOSED10:18:30.

Current source qualification packet:
`2a54056b3bda6990c9c179059d0c4099fd357eac` has terminal CI **41 SUCCESS
/ 24 SKIPPED**, no failed or pending checks. An author byte comparison
verifies all 11 files in the Luna-reviewed extension (including all
seven non-test workflow/controller/documentation files) are identical to
reviewed `468b26227fcb9e8290da9dcdcc51c591dae0d470`. The later main
integration's sole conflict resolves to main's exact pusher-reference
test fixture bytes. Historical failures remain recorded; this is actual
successor CI, not a rerun waiver.

Review-cap disposition: no third full controller review is requested.
Historical Luna SHIP `01a1de64-2b19-73fa-958d-26b66e096742` is evidence
for its named source, not a new independent verdict on this head.
Bounded confirmation from the same reviewer of this exact
source-identity/carry packet remains pending; ordinary Release
admission/holds remain separate. No merge or activation is claimed.
Runtime carrier/predecessor must be explicitly rebound by
Release/captain to the actual live vector before 100/20; the inactive
afa-bound guard and its UNKNOWN previous-zero proof cannot be silently
reused. The intervention deadline passed without a qualified clean hour.
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