Skip to content

build(quality): ratchet oversized product source files - #9851

Merged
Git-on-my-level merged 1 commit into
mainfrom
codex/issue-9838-god-file-ratchet
Jul 15, 2026
Merged

Git-on-my-level merged 1 commit into
mainfrom
codex/issue-9838-god-file-ratchet

Conversation

@Git-on-my-level

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

Copy link
Copy Markdown
Member

Summary

  • Add a diff-scoped 1,500-line ratchet for Python, Swift, and Rust product sources.
  • Seed the committed snapshot with the 47 currently oversized files and provide a downward-only updater for splits.
  • Fold RealtimeHubController.swift's overlapping size guard into the shared ratchet; its extracted-type ownership guard remains.

Root cause and durable guard

Oversized product files repeatedly concentrate collisions and costly navigation (#9838; notably #9836 and #9384/#9638/#9692). The new shared boundary freezes further growth, rejects smaller files that cross the threshold, and makes any exceptional raise exact-count, source-diff-bound, and one-line-justified.

Verification

  • python3 .github/scripts/test_check_product_file_line_count_ratchet.py
  • python3 desktop/macos/scripts/check-hub-controller-ratchet.py --self-test
  • make preflight (rerun after applying the internal-only no-changelog-needed label)

Review in cubic

@Git-on-my-level Git-on-my-level added the no-changelog-needed Skip desktop changelog enforcement for internal-only changes label Jul 15, 2026 — with ChatGPT Codex Connector
@Git-on-my-level
Git-on-my-level merged commit 994c017 into main Jul 15, 2026
19 of 28 checks passed
@Git-on-my-level
Git-on-my-level deleted the codex/issue-9838-god-file-ratchet branch July 15, 2026 22:27

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8be2595bb7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

"""Return growth failures and the safe downward updates they require."""
failures: list[str] = []
downward: dict[str, int | None] = {}
for relative in changed_product_sources(changed):

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Include deleted sources in the ratchet input

When an oversized baseline file is deleted or split, this path never reaches the ratchet: the manifest passes {changed_files}, but both run_checks.py and pr_preflight.py build that list with git diff --diff-filter=ACMR, which drops deletions. Because this loop only considers paths present in that file, removing a baseline entry's source (for example a future split of backend/routers/transcribe.py) can pass without updating product_file_line_count_ratchet_baseline.json, leaving a stale high allowance that would exempt a later file recreated at the same path. Include deleted paths in the input or audit baseline paths against the current tree.

Useful? React with 👍 / 👎.

Git-on-my-level added a commit that referenced this pull request Jul 16, 2026
…seline

The APIClient.swift line-count ratchet in test_desktop_rest_inventory.py
was capped at 6500 but the file grew to 6502 lines after the staged-score-
update batch (#9816). The newer product-file-line-count ratchet (#9851)
already baselines APIClient.swift at 6502. This updates the stale constant
to match, unblocking the Backend unit suite which was failing on every
open PR (including #9844 which does not touch any Swift files).
cursor Bot pushed a commit that referenced this pull request Jul 16, 2026
Kept origin/main's documented 6502 baseline comment (PR #9851 / #9816).
Both sides already agreed on APICLIENT_SWIFT_MAX_LINES=6502.

Verification: backend/.venv/bin/python -m pytest -q
tests/unit/test_backend_test_runner.py
tests/unit/test_desktop_rest_inventory.py::test_apiclient_swift_line_count_ratchet
(5 passed)

Co-authored-by: David Zhang <[email protected]>
undivisible pushed a commit that referenced this pull request Jul 24, 2026
cargo clippy --all-targets reported 275 unwrap_used errors, every one
inside #[cfg(test)] code (proxy 176, chat tests 91, and scattered
singles): the crate-level deny predates any --all-targets run, and CI's
plain cargo clippy never lints test targets, so the debt was invisible
in CI while screaming in every contributor's editor — rust-analyzer runs
clippy with --all-targets by default, burying real diagnostics under 275
false alarms.

Tests may unwrap: a test failing on unwrap is the test doing its job,
and the test authors (including #9851's chat split, merged with these
unwraps) clearly practice that. Each test module now carries an inner
allow with that rationale; production code keeps the crate-level deny
untouched.

Verification: cargo clippy --all-targets → 0 errors (was 275);
cargo test → 376 passed; plain cargo clippy unchanged (was already
clean). #10101's new services::http test module carries its own 4
unwraps and gets the same allow when the branches meet.

Co-Authored-By: Claude Fable 5 <[email protected]>
undivisible added a commit that referenced this pull request Jul 24, 2026
…#10128)

# Summary

`cargo clippy --all-targets` on the desktop Rust backend reported **275
`unwrap_used` errors — every single one inside `#[cfg(test)]` code**
(proxy tests 176, chat tests 91, scattered singles). The crate-level
`unwrap_used = "deny"` predates any `--all-targets` run: CI's plain
`cargo clippy` never lints test targets, so the debt was invisible in CI
while screaming in every contributor's editor — rust-analyzer runs
clippy with `--all-targets` by default, burying real diagnostics under
275 false alarms.

Fix: each test module carries an inner `#![allow(clippy::unwrap_used)]`
with a one-line rationale. Production code keeps the crate-level deny
untouched.

Named as out-of-scope debt in #10101; this closes it.

# Why allow, not 275 `expect()`s

Tests may unwrap — a test failing on unwrap is the test doing its job,
and the codebase's test authors clearly practice that (#9851's chat
split merged with 91 of them). Rewriting 275 call sites into
`expect("...")` messages nobody reads is churn that fights the practiced
convention; scoping the deny to the code it was written for matches
intent with five attribute lines.

# Product invariants affected

none (verified with `scripts/pr-preflight --suggest`)

# Validation

- `cargo clippy --all-targets` → **0 errors** (was 275).
- Plain `cargo clippy` → unchanged (was already clean; production deny
still active — a production `unwrap()` still fails the build).
- `cargo test` → **376 passed**.
- `rustfmt --edition 2021` applied; `make preflight` (local lane, this
PR body) → all selected checks pass.
- `proxy.rs` frozen-size baseline raised 2803 → 2806 (+3, the
test-module allow attribute) with justification, per the ratchet's
documented raise path.

# Out of scope, named

- Adding `--all-targets` to the CI clippy lane (now that it would pass)
— touches workflow config, i.e. the automation guard; trivial follow-up
for a maintainer if wanted.
- #10101's new `services::http` test module carries its own 4 unwraps
and gets the same allow when the branches meet (noted in both PRs).
undivisible added a commit that referenced this pull request Jul 24, 2026
…nded deadline (#10101)

# Summary

- Four desktop-backend call sites built reqwest clients with **no
connect timeout and no total-request deadline** — screen-activity
Pinecone upserts, both Sentry fetches (webhook enrichment + feedback
poll), and the Crisp session lookup. One hung upstream pinned its
handler or background task until the platform killed it, holding the
connection slot the whole time.
- `services::http::bounded_client(total_timeout)` is now the one owner
of outbound client construction: connect capped at 10s, every request
failing after the caller's total budget (Pinecone 30s; Sentry/Crisp
15s). No caller can opt out of having a deadline.
- `realtime.rs`'s private duplicate helper (identical 10s/15s values)
folds onto the primitive; `tts.rs` keeps its deliberate retry-shaped 30s
client unchanged — it already had both bounds.


**Scope:** this establishes bounded connect + total timeouts for the
bare `reqwest::Client::new()` call sites the helper replaces, and steers
new *non-streaming* integrations to `bounded_client(total_timeout)`. It
is **not** a repo-wide 'every client' invariant — streaming transports
(Anthropic/Gemini chat) deliberately omit a client-level total timeout
and bound their budget at the route/request level.
# Why a primitive, not four timeouts

The repo's own FC-per-hop-timeout class (evidence: #9835) names the
pattern: per-call-site retail timeouts drift and new call sites ship
bare. After this PR the bare `reqwest::Client::new()` call sites this
helper covers carry bounded connect + total deadlines, and the next
non-streaming outbound integration reaches for the bounded constructor
because it is the one that exists. Cited, not declared — this is a
`harden:` commit with no triggering incident, per the contribution
guide's fix/harden distinction.

# Product invariants affected

none (verified with `scripts/pr-preflight --suggest`)

Failure-Class: none

# Validation

- New hermetic regression test drives the primitive against a **stalled
local upstream** (TCP listener that accepts, reads the request, and
never responds — the exact shape a bare client hangs on forever) and
asserts the client-side deadline fires, as a timeout error, within
budget. No network, no sleeps on the assert path.
- `cargo test` → **377 passed** (full crate, includes the new test).
- `cargo clippy` clean on the crate; the `--all-targets` `unwrap()`
lints in `src/routes/chat/tests/all.rs` are pre-existing on main (from
the #9851 module split), untouched here.
- `rustfmt --edition 2021` applied to all changed files.
- Behavior at the four migrated sites is unchanged on the success path;
the only new behavior is that a hung upstream now errors at its budget
instead of hanging forever — exercised directly by the test above.

# Out of scope, named

- **Three bare `reqwest::Client::new()` sites remain in the crate** —
`services/firestore.rs:81`, `auth.rs:120`, `routes/auth.rs:847`
(verified against the current head). They sit on auth/Firestore surfaces
rather than the non-streaming outbound-integration surface this helper
covers, and migrating them changes behavior on credential/data paths
that deserve their own review — so they are named follow-up, not bundled
into an already-approved hardening PR.

- The pre-existing `--all-targets` clippy lints in
`routes/chat/tests/all.rs` — separate cleanup, not this PR's surface.
- Per-request deadline propagation (deadline budgets flowing across
hops, FC-per-hop-timeout's full shape) — #10054/#10056 own that for the
chat/proxy paths.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/10101?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
undivisible pushed a commit to undivisible/omi that referenced this pull request Sep 29, 2026
…#9851)

## Summary
- Add a diff-scoped 1,500-line ratchet for Python, Swift, and Rust
product sources.
- Seed the committed snapshot with the 47 currently oversized files and
provide a downward-only updater for splits.
- Fold `RealtimeHubController.swift`'s overlapping size guard into the
shared ratchet; its extracted-type ownership guard remains.

## Root cause and durable guard
Oversized product files repeatedly concentrate collisions and costly
navigation (BasedHardware#9838; notably BasedHardware#9836 and BasedHardware#9384/BasedHardware#9638/BasedHardware#9692). The new shared
boundary freezes further growth, rejects smaller files that cross the
threshold, and makes any exceptional raise exact-count,
source-diff-bound, and one-line-justified.

## Verification
- `python3
.github/scripts/test_check_product_file_line_count_ratchet.py`
- `python3 desktop/macos/scripts/check-hub-controller-ratchet.py
--self-test`
- `make preflight` (rerun after applying the internal-only
`no-changelog-needed` label)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/9851?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
undivisible pushed a commit to undivisible/omi that referenced this pull request Sep 29, 2026
cargo clippy --all-targets reported 275 unwrap_used errors, every one
inside #[cfg(test)] code (proxy 176, chat tests 91, and scattered
singles): the crate-level deny predates any --all-targets run, and CI's
plain cargo clippy never lints test targets, so the debt was invisible
in CI while screaming in every contributor's editor — rust-analyzer runs
clippy with --all-targets by default, burying real diagnostics under 275
false alarms.

Tests may unwrap: a test failing on unwrap is the test doing its job,
and the test authors (including BasedHardware#9851's chat split, merged with these
unwraps) clearly practice that. Each test module now carries an inner
allow with that rationale; production code keeps the crate-level deny
untouched.

Verification: cargo clippy --all-targets → 0 errors (was 275);
cargo test → 376 passed; plain cargo clippy unchanged (was already
clean). BasedHardware#10101's new services::http test module carries its own 4
unwraps and gets the same allow when the branches meet.

Co-Authored-By: Claude Fable 5 <[email protected]>
undivisible added a commit to undivisible/omi that referenced this pull request Sep 29, 2026
…BasedHardware#10128)

# Summary

`cargo clippy --all-targets` on the desktop Rust backend reported **275
`unwrap_used` errors — every single one inside `#[cfg(test)]` code**
(proxy tests 176, chat tests 91, scattered singles). The crate-level
`unwrap_used = "deny"` predates any `--all-targets` run: CI's plain
`cargo clippy` never lints test targets, so the debt was invisible in CI
while screaming in every contributor's editor — rust-analyzer runs
clippy with `--all-targets` by default, burying real diagnostics under
275 false alarms.

Fix: each test module carries an inner `#![allow(clippy::unwrap_used)]`
with a one-line rationale. Production code keeps the crate-level deny
untouched.

Named as out-of-scope debt in BasedHardware#10101; this closes it.

# Why allow, not 275 `expect()`s

Tests may unwrap — a test failing on unwrap is the test doing its job,
and the codebase's test authors clearly practice that (BasedHardware#9851's chat
split merged with 91 of them). Rewriting 275 call sites into
`expect("...")` messages nobody reads is churn that fights the practiced
convention; scoping the deny to the code it was written for matches
intent with five attribute lines.

# Product invariants affected

none (verified with `scripts/pr-preflight --suggest`)

# Validation

- `cargo clippy --all-targets` → **0 errors** (was 275).
- Plain `cargo clippy` → unchanged (was already clean; production deny
still active — a production `unwrap()` still fails the build).
- `cargo test` → **376 passed**.
- `rustfmt --edition 2021` applied; `make preflight` (local lane, this
PR body) → all selected checks pass.
- `proxy.rs` frozen-size baseline raised 2803 → 2806 (+3, the
test-module allow attribute) with justification, per the ratchet's
documented raise path.

# Out of scope, named

- Adding `--all-targets` to the CI clippy lane (now that it would pass)
— touches workflow config, i.e. the automation guard; trivial follow-up
for a maintainer if wanted.
- BasedHardware#10101's new `services::http` test module carries its own 4 unwraps
and gets the same allow when the branches meet (noted in both PRs).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

no-changelog-needed Skip desktop changelog enforcement for internal-only changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant