Repository navigation
feat: support Hardware AAD feature and improve power consumption - #9048
Conversation
…oftware VAD Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…akes Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ording tests Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ge into unpowered card Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…er leak (~1mA) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ile connected Co-Authored-By: Claude Opus 4.8 <[email protected]>
…dsl_power_off Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…power BLE conn Co-Authored-By: Claude Opus 4.8 <[email protected]>
…oid wake audio drop Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…cordings Co-Authored-By: Claude Opus 4.8 <[email protected]>
Co-Authored-By: Claude Opus 4.8 <[email protected]>
…n commits Co-Authored-By: Claude Opus 4.8 <[email protected]>
…unt SD at connect start Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ure (-ENOMEM/-EAGAIN) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…hen-connected Co-Authored-By: Claude Opus 4.8 <[email protected]>
…ad can drain (fixes no-log sync stall) Co-Authored-By: Claude Opus 4.8 <[email protected]>
…n >=3.0.20) Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
@cubic-dev-ai review |
@TuEmb I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 16 files
Confidence score: 5/5
- Safe to merge after the addressed issues were fixed.
Reply with feedback, questions, or to request a fix.
Re-trigger cubic
… churn was stalling sync)
|
Thanks @TuEmb — this is a substantial, well-scoped power-consumption improvement for the firmware (hardware AAD sleep on the T5838, SD power cycling, low-power BLE params). The power-state diagrams you attached are genuinely helpful for review. The overall architecture (AAD owned in Because this changes power, mic bring-up, SD persistence, and BLE connection behavior across 16 files (~1670 lines), it needs human maintainer + on-device validation before merge — I've labeled it accordingly and will not approve it automatically. A few concrete things that came up in review: SD data durability during power cycling (most important)
New
Minor
Really nice work on the power-state design overall. Once the SD-durability path and the driver error handling are tightened up, this should be in good shape for a maintainer to validate on hardware. |
|
Following up on the earlier review with a few more targeted notes after a full pass over the final diff. SD data durability during power cycling (highest impact)
New
Idle-thread wakeups
Minor
Still needs human maintainer review + on-device validation before merge (power, mic bring-up, SD persistence, and BLE params all change at once). The power-state design itself reads well. |
…rval + slave latency caused disconnects)
…e errors instead of false-ready
…l); log t5838 init failure
…power-request queue put, mount directly on wake-race
|
Third-pass automated review. The power-state architecture (hardware AAD owned in Still open
Resolved since last pass (good)
No security concerns — no auth/secrets/data-handling/CI/dependency changes. The FAKE2C protocol and register writes are properly attributed to the Irnas/Brilliant-Labs driver. Still needs human maintainer review + on-device validation before merge (power, mic bring-up, SD persistence, and sync path all change at once). Once the SD-durability path and driver error handling are tightened, this should be in good shape. |
…transfer_active gate)
…ata through shared throttle (fixes battery -ENOMEM during sync)
|
Fourth-pass automated review — the earlier items are all addressed in the current diff. Thank you for working through them. Previously flagged — now resolved
The wake-race fallback in Architecture assessment The power-state design is cohesive and sound: hardware AAD owned in Why this still needs human maintainer review before merge
These are judgment calls, not blockers I can resolve from a diff. Leaving |
|
Fifth-pass automated review. The power-state design remains cohesive and all four earlier items (SD durability, One new docs-accuracy item:
Remaining judgment calls (unchanged from pass 4, not code defects):
No security concerns. Needs human maintainer review + on-device validation before merge. |
## Summary Review-swarm findings from a 10-agent code review of the last 2 days of merged PRs (62 PRs / 1072 files). Seven isolated bugs were found and fixed; no behavior change beyond the fixes. Each commit is independent and reviewable on its own. ### High-severity correctness - **`fix(chat)`: tz-aware `created_at` sort sentinel** — `get_chat_files_desc` (>30 file_ids merge path) used naive `datetime.min`, which TypeError-compares against tz-aware Firestore dates and 500s. Last instance of the #9571 failure class; all four `datetime.min` sort sentinels in `backend/` are now tz-aware. - **`fix(agent-control)`: derive consent for `request_permission` in PTT/voice mode** — both voice paths never built a `PermissionRequestAuthorization`, so the consent gate always silently denied `request_permission` while the system prompt told the model to call it. The feature was non-functional in voice mode. Fixed by deriving authorization from the spoken turn transcript (mirrors the text path; fail-closed). ### Medium - **`fix(translation)`: NLLB native-language-code case resolution** — `_resolve_nllb_code` lowercased input before checking the mixed-case `NLLB_TO_BCP47` keys, making the native-code passthrough dead. README documents `eng_Latn` as valid input. - **`fix(nllb)`: autoscale on active requests instead of CPU-only** — the NLLB GPU HPA scaled only on CPU, which stays low during GPU inference, so it never scaled past minReplicas. Added a concurrency-based External metric on the existing `nllb_active_requests` gauge (`requestsPerPod: 4` in prod), mirroring the parakeet pattern, and wired the adapter rule into the cluster-wide prometheus-adapter (dev+prod). CPU retained as a secondary floor. - **`fix(firmware)`: propagate `t5838_aad_init` failure from `mic_start`** — the init powers the 1.8V mic rail; on failure it only logged and returned 0 (false-ready at the caller: mic "starts" but captures silence). `main()` already handles a nonzero `mic_start` return via `error_microphone()`, so propagate the failure. Closes the #9048 false-ready goal at the caller level. ### Low / defense-in-depth - **`fix(tasks)`: re-add defensive newest-first sort for suggested candidates** — #9591 removed the client-side sort, leaving the top-5 slice dependent on backend return order with no test. Re-added the sort as defense-in-depth. - **`fix(ci)`: drop duplicate isinstance-ratchet exempt entry** — two commits registered the same script in the manifest `exempt:` list. ### Desktop changelog Fragments added for the two user-visible desktop fixes (PTT permission consent, suggested-tasks ordering). ## Product invariants affected - INV-CHAT-1 ## Verification - Each fix reviewed hunk-by-hunk by a dedicated reviewer; the chat.py fix was cross-confirmed by two reviewers (sync/memory found it, API owner fixed it). - Pre-push manifest checks pass (check-manifest-contract, diff-hygiene, architecture-guardrails, product-invariants with this citation, desktop-changelog-entry, brand-ui INV-UI-1, backend-import-purity, backend-async-blockers). - No new tests added in this PR; the underlying behavior is covered by the existing suite for each touched area. The tz-sentinel and consent fixes are the kind of regression a follow-up test should pin (noted below). ## Notes / follow-ups - The NLLB HPA active-requests metric requires the documented prometheus-adapter helm upgrade (same manual step parakeet needs) before it takes effect in-cluster. - Reported-but-not-fixed concerns from the review (out of scope here): NLLB model re-downloaded every pod restart (emptyDir), gateway 13-label metrics cardinality monitoring, a static guard to prevent recurrence of the naive-`datetime.min` sort class. 🤖 Generated with Claude Code <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/9600?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. -->
…ew swarm t5838_aad_init() powers the 1.8V mic rail; if it fails the PDM mic is unpowered and captures silence, but mic_start() only logged and returned 0 (false-ready at the caller level). main() already handles a nonzero mic_start return via error_microphone(), so propagate the failure — the device reports a mic fault instead of booting into a silent-capture state. Closes the false-ready class BasedHardware#9048 targeted at the caller level; aad_hw_start() remains non-fatal (mic already running by then).







This PR is to:
1. Hardware AAD (new t5838_aad.c/.h, mic.c; removes aad.c/aad.h)
On silence, the T5838 is clocked into its built-in AAD sleep (mic off, ~µA) and wakes on the WAKE pin (P1.02). Owned inside mic.c since it shares the PDM peripheral.
CLK + THSEL parked high during sleep so they don't fight the TXS0104 level-shifter's pull-ups (~1 mA leak).
2. Offline / idle power (sd_card.c, mic.c, main.c)
SD-NAND powered off during offline AAD sleep, remounted on wake (writes buffered across the remount); CS parked low; full bus disconnect at shutdown.
Status LED off during offline sleep.
Deep-sleep (system-off): mic_off() now cuts PDM_EN so mic + shifter fully power down → ~25 µA (IMU + OTA flash stay functional).