Repository navigation
fix(memory): use a tz-aware sentinel in the review-queue sort key to avoid a 500 - #9571
Merged
kodjima33 merged 1 commit intoJul 12, 2026
Merged
Conversation
…avoid a 500
_review_conflict_sort_key returned (impact, item.get('created_at') or datetime.min). datetime.min
is naive; stored created_at is tz-aware. On an impact tie, list_review_conflicts' items.sort(...)
compares the two datetimes and raises "can't compare offset-naive and offset-aware datetimes"
-> HTTP 500 on GET /v3/memories/review-queue. Changed the sentinel to
datetime.min.replace(tzinfo=timezone.utc), the aware sentinel database/memory_ledger.py already uses.
Verification (backend/): pytest tests/unit/test_review_queue_sort_tz.py -> 2 passed; black clean;
check_module_stub_pollution -> 0.
kodjima33
approved these changes
Jul 12, 2026
kodjima33
left a comment
Collaborator
There was a problem hiding this comment.
Backend bug fix — root cause stated, scoped, CI green. Merging.
Git-on-my-level
added a commit
that referenced
this pull request
Jul 13, 2026
## 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. -->
Git-on-my-level
added a commit
to Git-on-my-level/omi
that referenced
this pull request
Jul 13, 2026
… — review swarm get_chat_files_desc (the >30 file_ids chunking path) sorted merged results with datetime.min as the missing-key fallback. A file doc lacking created_at then paired a NAIVE datetime against the TZ-AWARE Firestore datetimes of its siblings during sort, raising TypeError: can't compare offset-naive and offset-aware datetimes -> HTTP 500. Same failure class BasedHardware#9571 closed for the review queue. datetime.min.replace(tzinfo=timezone.utc) is comparable and sorts oldest, so a doc missing created_at sinks to the bottom of the descending sort instead of crashing it. timezone is already imported.
This was referenced Jul 15, 2026
Git-on-my-level
added a commit
that referenced
this pull request
Jul 16, 2026
## Summary\n\n- add a semantic, JSON failure-class registry plus an offline scripts/failure-class CLI for agent-oriented preparation, explanation, validation, and advisory reporting\n- surface the same failure-class guidance with product-invariant suggestions through scripts/pr-preflight --suggest, before a PR exists\n- keep PR-body checks in local/PR preflight while excluding them from metadata-less post-merge main pushes\n- enforce PR-body declarations for reactive fix: commits through the existing preflight manifest, while distinguishing proactive harden: work\n- add manifest-backed recurrence ratchets for naive Python datetime sort sentinels and unsafe macOS Swift dictionary construction\n- replace repetitive existing-class narratives with a validated declaration, require real-incident citations for new guards, and defer locked invariants until seven stable days\n- extract the X connector transport and DTOs from APIClient.swift into its connector feature, reducing the client from 6,502 to 6,430 lines without changing endpoint behavior\n\nCloses #9822\n\n## Failure class (fixes)\n\nFailure-Class: none\n\n## New guards\n\nThe datetime ratchet cites #9571 and #9600; the desktop dictionary ratchet cites #6506 and #9288. These are static checks because the canonical safe primitives already exist, while the prohibited patterns can be reintroduced independently at multiple call sites.\n\n## Product invariants affected\n\n- INV-AUTH-1 — the authenticated transport implementation is unchanged; this moves its X connector extension only.\n- INV-INT-1 — the X connector endpoints and DTOs are now co-located with their connector-import feature; behavior is unchanged.\n\n## Verification\n\n- python3 scripts/test_failure_class.py — 13 passed\n- python3 .github/scripts/test_pr_preflight.py — 10 passed\n- python3 .github/scripts/test_run_checks.py — 13 passed\n- focused backend ratchet tests — 6 passed\n- BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-backend-unit-failures.txt bash backend/test.sh — 9 passed\n- bash backend/test.sh — 631-file CI-equivalent suite passed\n- xcrun swift test --package-path Desktop --filter ConnectorImportOperationsTests — 13 passed\n- xcrun swift build -c debug --package-path Desktop — passed\n- python3 desktop/macos/scripts/check_desktop_test_quality.py — passed\n- desktop-core-harness self-check — passed with the repository virtualenv and Node 22 runtime\n- scripts/pr-preflight — passed (26 checks)\n- make preflight — passed\n\n
undivisible
pushed a commit
to undivisible/omi
that referenced
this pull request
Sep 29, 2026
…ware#9841) ## Summary\n\n- add a semantic, JSON failure-class registry plus an offline scripts/failure-class CLI for agent-oriented preparation, explanation, validation, and advisory reporting\n- surface the same failure-class guidance with product-invariant suggestions through scripts/pr-preflight --suggest, before a PR exists\n- keep PR-body checks in local/PR preflight while excluding them from metadata-less post-merge main pushes\n- enforce PR-body declarations for reactive fix: commits through the existing preflight manifest, while distinguishing proactive harden: work\n- add manifest-backed recurrence ratchets for naive Python datetime sort sentinels and unsafe macOS Swift dictionary construction\n- replace repetitive existing-class narratives with a validated declaration, require real-incident citations for new guards, and defer locked invariants until seven stable days\n- extract the X connector transport and DTOs from APIClient.swift into its connector feature, reducing the client from 6,502 to 6,430 lines without changing endpoint behavior\n\nCloses BasedHardware#9822\n\n## Failure class (fixes)\n\nFailure-Class: none\n\n## New guards\n\nThe datetime ratchet cites BasedHardware#9571 and BasedHardware#9600; the desktop dictionary ratchet cites BasedHardware#6506 and BasedHardware#9288. These are static checks because the canonical safe primitives already exist, while the prohibited patterns can be reintroduced independently at multiple call sites.\n\n## Product invariants affected\n\n- INV-AUTH-1 — the authenticated transport implementation is unchanged; this moves its X connector extension only.\n- INV-INT-1 — the X connector endpoints and DTOs are now co-located with their connector-import feature; behavior is unchanged.\n\n## Verification\n\n- python3 scripts/test_failure_class.py — 13 passed\n- python3 .github/scripts/test_pr_preflight.py — 10 passed\n- python3 .github/scripts/test_run_checks.py — 13 passed\n- focused backend ratchet tests — 6 passed\n- BACKEND_UNIT_TEST_FILE_LIST=/tmp/omi-backend-unit-failures.txt bash backend/test.sh — 9 passed\n- bash backend/test.sh — 631-file CI-equivalent suite passed\n- xcrun swift test --package-path Desktop --filter ConnectorImportOperationsTests — 13 passed\n- xcrun swift build -c debug --package-path Desktop — passed\n- python3 desktop/macos/scripts/check_desktop_test_quality.py — passed\n- desktop-core-harness self-check — passed with the repository virtualenv and Node 22 runtime\n- scripts/pr-preflight — passed (26 checks)\n- make preflight — passed\n\n
Wizard815
pushed a commit
to Wizard815/omi-local
that referenced
this pull request
Nov 25, 2026
…aterial render_material sorted undated conversations with a naive datetime.min. The (started_at is None, ...) tuple key already kept it from being compared with aware timestamps, so nothing broke, but the backend-datetime-sort-sentinel-ratchet (BasedHardware#9571/BasedHardware#9600) rejects new naive sentinels; use datetime.min.replace(tzinfo=timezone.utc). Adds a test pinning the ordering this key exists for: undated conversations come after dated ones, in their original order. It passes on both the old and new key; it guards the behavior, not a past bug. Verification: BACKEND_UNIT_TEST_FILE_LIST=<test_day_review_rules.py, test_day_review_service.py> backend/test.sh -> 7 passed, 7 passed. Co-Authored-By: Claude Opus 5.5 <[email protected]> Claude-Session: https://claude.ai/code/session_0148HLrpWR8Mimn43rkNvGKg
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.
Problem
_review_conflict_sort_keyreturned(impact, cast(datetime, item.get('created_at') or datetime.min)).datetime.minis naive, but storedcreated_atis tz-aware (datetime.now(timezone.utc)). On an impact tie,list_review_conflicts'items.sort(key=_review_conflict_sort_key, reverse=True)compares the two datetimes and raisesTypeError: can't compare offset-naive and offset-aware datetimes-> HTTP 500 onGET /v3/memories/review-queue. Impact ties are common (defaults/fallbacks), so an item missingcreated_attriggers it.Fix
Use the tz-aware sentinel
datetime.min.replace(tzinfo=timezone.utc), exactly asdatabase/memory_ledger.pyalready does for the same kind of sort.Test
tests/unit/test_review_queue_sort_tz.pysorts items with one tz-awarecreated_atand one missing (an impact tie) without raising, and confirms the ordering (impact desc, then created_at desc on a tie).Verification
pytest tests/unit/test_review_queue_sort_tz.py-> 2 passedblack --checkclean;check_module_stub_pollution-> 0