Repository navigation
ci: regression guardrails — PR scope governor, test-discovery ratchet, sync annotation ratchet - #9634
Conversation
|
I like the idea behind these mechanical regression guards, but PRs are expensive to test right now, so splitting up a large feature unnecessarily increases human time burden which IMO is worse than increasing agent review burden Thoughts? I think 2 + 3 are good, but 1 + 4 need to be reconsidered |
|
Fair point — reworked in eafd3e0. The scope check (1) is now advisory-only: it still warns at 1,500 / 3,000 production-source lines (the 3,000 tier cites the audit so review depth scales with size) but never fails, so it can't force a split. That also let me delete the whole I kept the two other rules in 4 (legacy-principal test for new fail-closed gates; external citation when a test is rewritten alongside the code it asserts) since they don't force splits and their cost lands on agent/review effort — but happy to drop them too if you disagree. 2 + 3 unchanged. |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the careful iteration here. I reviewed this as a workflow/guardrail change rather than a normal app-code patch.
Positive signal from my side:
- The PR scope check is now advisory-only and exits 0, which matches the maintainer constraint that size should inform review depth without forcing splits.
- I locally ran the touched manifest path with
python3 .github/scripts/run_checks.py --lane local --base origin/main --head HEAD; all 16 selected local checks passed, includingpr-scope,pr-scope-helper-tests,backend-test-discovery, backend import purity/module isolation, and workflow-contract checks. - I also ran the focused tests directly:
.github/scripts/test_check_pr_scope.py,backend/tests/unit/test_check_unit_test_discovery.py, andbackend/scripts/check_unit_test_discovery.py.
Agent/maintainer consequence to call out: this PR changes AGENTS.md, so it will influence AI coding/review agents in this repo. The new instructions look safe and useful: they tell agents that PR size is reported but not bounded, add the pyright strictness ratchet rule, and make backend test discovery/fail-closed gate expectations explicit. That should steer agents toward better validation without creating a hard split mandate. Because it changes agent instructions plus CI/workflow guardrails, I still think a human maintainer should make the final policy call before merge.
I am not formally approving because this touches workflow/CI and repo-wide agent guidance, but I did not find a blocker in the implementation I reviewed.
undivisible
left a comment
There was a problem hiding this comment.
Approve
Guardrails that report without becoming a second product owner: advisory scope (never blocks), discovery ratchet so tests can’t silently leave the runner, sync param-type ratchet for the source=unknown class. Exactly the kind of scar-tissue CI that earns its keep. Rebase the two conflicted files (checks-manifest, AGENTS.md) and merge.
|
Approved — advisory scope (never blocks), unit-test discovery ratchet, sync param-type ratchet. Exactly scar-tissue CI. Conflicts are only |
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for rebasing this. I re-reviewed the new head (819f32bbaf26e5d6602b349674b28c0002da4e6b) as a workflow/guardrail change.
I’m requesting changes for one concrete blocker on the current head:
python3 .github/scripts/run_checks.py --lane local --base origin/main --head HEADnow failsfailure-class-protocol. The newfix(merge): restore upstream content for files clobbered by the main mergecommit is treated as afix:commit but has noFailure-Class: FC-<slug> | new | nonedeclaration, so the manifest exits non-zero. Please either add the required failure-class declaration to that fix commit/PR body path or rename/rework the commit subject if it is not an actual bug-fix commit.
Focused checks that still passed locally:
python3 .github/scripts/test_check_pr_scope.py-> 9 passedcd backend && python3 -m pytest -q tests/unit/test_check_unit_test_discovery.py scripts/check_unit_test_discovery.py --tb=short-> 14 passedcd backend && python3 scripts/check_unit_test_discovery.py-> unit test discovery OK, 0 orphans
Agent/maintainer consequence: this PR still changes AGENTS.md, so it will alter how AI coding/review agents behave in this repo. The updated guidance appears safe and aligned with the maintainer direction: PR size is advisory/reporting-only rather than a hard split gate, backend test discovery becomes mechanically enforced, and agents are pushed to preserve fail-closed/legacy-principal coverage. That policy change still warrants human maintainer review before merge.
I’m not formally approving because the PR touches CI/workflow guardrails and repo-wide agent instructions, and the approval gate is also blocked by the current failing/cancelled GitHub checks.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
… sync annotation ratchet Three mechanical regression guardrails derived from an internal audit of merged PRs: 1. PR scope advisor (advisory-only, never blocks): warns at 1,500 and 3,000 changed production-source lines so reviewers calibrate skepticism to diff size. 2. Unit-test discovery ratchet: fails when any test file is not discovered by a verified runner. Allowlists only shrink. 3. Sync parameter annotation ratchet: pyright executionEnvironments enforces reportMissingParameterType=error for utils/sync/. Co-authored-by: skanderkaroui <[email protected]>
819f32b to
953bc9f
Compare
undivisible
left a comment
There was a problem hiding this comment.
Clean rebase on latest main. Failure-class-protocol issue resolved — the fix(merge) commit is gone. Advisory scope, test-discovery ratchet, sync annotation ratchet. LGTM, merging.
Failure-class-protocol issue resolved in clean rebase. Advisory scope, test-discovery ratchet, sync annotation ratchet all verified. Dismissing to merge.
The PR branch had stale versions of these scripts missing --exclusive-platform, --output json, resolve_check_selections, and other features added to main after the branch point. Also: restore reportUnusedImport=false in pipeline.py pyright comment (imports are used but pyright can't trace them in this file), add Callable annotation to on_fenced parameter.
The PR branch had a stale manifest missing 60+ entries from main. Restored main's manifest and inserted only the 3 new PR entries: pr-scope, pr-scope-helper-tests, backend-test-discovery.
testing/desktop_beta_admission/ is covered by desktop_beta_admission_control.yml but wasn't in the checker's WORKFLOW_COVERED_PREFIXES, causing it to be flagged as orphaned.
Revert wrong workflow mapping (desktop_beta_admission_control.yml is a manual dispatch, not a test runner). Add the test to MANUAL_ONLY_TESTS allowlist instead.
Desktop Backend-Rust was deleted in main; the formatting command reference is a stale pointer that agent-doc-references catches.
pr-scope has triggers: ["all"] so it's selected for any change, including doc-only diffs. Update the test to expect it.
The test asserted MANUAL_ONLY_TESTS was empty. Updated to expect the desktop_beta_admission allowlist entry.
Git-on-my-level
left a comment
There was a problem hiding this comment.
Thanks for the cleanup on the latest head (e7cab1b8d3738beb8323130432f565ad6ff0a625). I re-reviewed the workflow/guardrail changes and this looks like a positive signal from automation, not a formal approval.
What I verified locally:
python3 .github/scripts/test_check_pr_scope.py-> 9 passedcd backend && .venv/bin/python -m pytest -q tests/unit/test_check_unit_test_discovery.py scripts/check_unit_test_discovery.py --tb=short-> 14 passedcd backend && python3 scripts/check_unit_test_discovery.py-> unit test discovery OK, 0 orphanspython3 .github/scripts/run_checks.py --lane local --base origin/main --head HEAD --pr-body-file /tmp/omi-pr9634-review-20260729/pr-body.mdprogressed through the PR-scope, backend-test-discovery, failure-class, agent-doc, diff-hygiene, and related selected checks; the earlier failure-class blocker is resolved when the current PR body is supplied. My local environment stopped later at a Ruby-dependent Ray-Ban iOS guard (rubynot installed here), while GitHub’s current check rollup is green.
Agent/maintainer consequence: this PR changes AGENTS.md, so it will alter how AI coding/review agents behave in the repo. The notable behavior changes are: PR size is advisory/reporting-only rather than a hard split gate; backend test discovery becomes mechanically enforced; new fail-closed gates need legacy-principal fallback coverage; tests rewritten in the same PR as asserted code need an external source; and the repo-wide behavior section tells agents to act autonomously while the safety section still requires explicit user sign-off for landing to main and risky/wide-blast-radius actions. That guidance appears directionally safe and aligned with the maintainer discussion, but it is still repo-wide agent/workflow policy and should keep human maintainer review before merge.
I’m not formally approving because the approval gate is blocked for workflow/CI guardrails, AGENTS.md agent-instruction changes, and the existing needs-maintainer-review / workflow-review labels.
by AI on behalf of David — if you need David’s attention urgently, please @Git-on-my-level and escalate with need human response.
What this is
Three mechanical regression guardrails plus the written rules behind them, derived from an internal audit of our own recent merge history. No behavior changes; the bug fixes the research surfaced will land as separate PRs.
The research
We audited the last ~30 merged PRs and found 9 confirmed regression pairs — a merged PR that introduced a production bug, and a later PR that fixed it. Three PRs each shipped 2+ regressions. We then ran a controlled replay experiment: 18 independent blind pre-merge reviews across 7 of the bug-introducing PRs (reviewers were never told a bug existed), scored against pre-registered ground truth.
Key findings:
backend/test.shwhile the test files stayed in the tree; nothing failed. (A later runner rewrite to directory discovery happened to heal it — by luck, not by guard.)source=unknownmisattribution bug (fixed in Fix backend audio-merge durable loss, memory control-state race, v2 source misattribution, OAuth log leak #9588) flowed through an unannotatedsourceparameter inutils/sync/pipeline.pythat a metering string shadowed. The enforced pyright lane had nothing to check.What this PR adds
1. PR scope advisor (
.github/scripts/check_pr_scope.py, manifest checkpr-scope— runs in the local pre-push lane and CI, advisory-only, never blocks)Counts changed production-source lines (tests across all platform conventions, docs, l10n, lockfiles, generated files excluded; rename/quotePath-safe via
--no-renames+ C-quote handling). ≥1,500 emits a warning annotation; ≥3,000 warns that in the audited merge history every PR this size shipped a regression review missed — so the reviewer calibrates skepticism to the diff, and splits only when the pieces are independently verifiable without extra human verification passes. Exit code is always 0 on a countable diff; push events (post-mergemain) are notice-only. Because nothing blocks, there is no waiver machinery — no override label, no env escape hatch, no label plumbing.2. Unit-test discovery ratchet (
backend/scripts/check_unit_test_discovery.py, wired into Backend Unit Tests before dependency install)Fails when any test file under
backend/tests/orbackend/testing/is not selected by the unit runner, not verified against its dedicated runner workflow (the workflow file must exist and actually reference the tree — or, for explicit-list workflows like the GPU suite, name the individual file), not policy-excluded (live integration/eval), and not allowlisted. Allowlists only shrink. This audit itself surfaced thattests/container/test_parakeet_vram_stress.pyis currently run by no workflow — it is now explicitly tracked as a manual-only harness instead of being silently vouched for.3. Parameter-annotation ratchet for the sync pipeline (
backend/pyrightconfig.json+ annotations)executionEnvironmentselevatesreportMissingParameterTypeto error forutils/sync/only, and this PR adds the five missing annotations — one of which is the exactsourceparameter from finding #3. Verified against the introducing PR's merge state: the rule flags that unannotated parameter atpipeline.py:746. Typed parameters make str-vs-enum confusion visible to pyright at annotated sinks and same-scope assignments (verified in isolation on pyright 1.1.403).4. AGENTS.md rules — PR size is reported, not bounded (matching the advisory check), mechanical discovery enforcement, the legacy-principal test rule for new fail-closed gates, and the rewritten-test review lens. Each rule names its enforcement or the shipped failure it prevents. The latter two rules cost agent/review effort rather than human verification time.
What this deliberately does not do
Verification
python3 .github/scripts/test_check_pr_scope.py→ 9 tests OK (classification, counting, advisory tiers, push notice-only).backend/scripts/check_unit_test_discovery.pyon the real tree →564 selected, 49 covered by other runners/allowlist, 0 orphans; a seededtests/<newdir>/test_orphan.pyfails the check with an actionable message.pytest tests/unit/test_check_unit_test_discovery.py→ 8 passed.bash backend/scripts/typecheck.sh(enforced pyright lane, pinned 1.1.403, full deps) with the new ratchet → 0 errors; the rule replayed against the introducing PR's merge state flags the unannotatedsourceparam.python3 -m py_compile backend/utils/sync/pipeline.py→ passes; annotations are runtime-inert.actionlinton both changed workflows → clean..github/scripts/test_run_checks.py(manifest drift guard) → OK..github/scripts/test_pr_preflight.py→ OK.tests/container/file IS flagged, pyright lane 0 errors, sync unit files 273 passed, Agent Runtime tool-surfaces 104 passed.backend/test.shrun (564 files): 562 files green in the parallel run; the two failures were environmental and pass on rerun —test_rendered_deployment_contract.pyneededhelmon PATH (8 passed once installed), andtest_sync_v2.pytripped only the per-test CPU-timing guard under saturated parallel load (all 161 tests pass; clean and fast in isolation).Product invariants affected
None — no product behavior changes; CI/tooling, type annotations, and docs only.
Failure class
Failure-Class: none
(This PR ships CI guardrail tooling; its fix commits repair the guardrail scripts themselves, not a registered product failure class.)