Skip to content

feat(backend): self-heal for capture wedges and processing jams — sweeper, telemetry, Core dashboard spec - #18855

Merged
Git-on-my-level merged 8 commits into
BasedHardware:mainfrom
Git-on-my-level:sca-556-selfheal
Sep 25, 2026
Merged

Git-on-my-level merged 8 commits into
BasedHardware:mainfrom
Git-on-my-level:sca-556-selfheal

Conversation

@Git-on-my-level

@Git-on-my-level Git-on-my-level commented Sep 25, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Add bounded listen funnel telemetry, structured zero-byte session logs, and an opt-in backend self-heal job that scans stale content-bearing conversations, verifies durable finalization, detects capture wedges, and sends flag-gated recovery notifications.
  • Protect existing structured data with transactional admission fences and a pre-persist empty-structure guard; keep the original conversation ID, transcript, and audio.
  • Pace v2 historical sync uploads before consuming bytes and durably record terminal backfill failures without changing the released client's retryable poll statuses.
  • Specify the Omi Core feature-health panels and exact emitted/log-based metric contracts in backend/docs/omi-core-selfheal-dashboard.md. No production job, scheduler, alert, or log metric was provisioned.

Design deviations and rationale

  • One automatic recovery attempt instead of two: an existing durable finalization job ID cannot safely be re-admitted after dead-letter; manual review is safer. Recover only source=omi rows with no existing title, overview, user title, or derived structured data; richer rows are not rewritten.
  • Reject empty derived output before completion persistence or fan-out rather than compensating a bad completion after a later tick. Verification re-reads raw Firestore content, refuses transcript shrinkage or missing audio IDs, and treats scan-window backlog counts as partial observations rather than fleet snapshots.
  • Query only zero-byte sessions during a 10-minute interval, then check candidate UIDs against positive-byte sessions; a broad 30-minute read can truncate under ordinary fleet volume. Any read failure, truncation, or more than 50 candidates suppresses nudges. Distinguish VAD zero-byte counters from no-first-audio teardown across all accepted sessions.
  • Permit one default-on per-UID backfill job with the existing Redis token slot, rather than adding a two-job counter. Preserve SYNC_BACKFILL_ADMISSION_LIMITS=false and the app's existing failed/partial_failure retry semantics; a separate pending→dead_letter Firestore ledger holds diagnosis. Failed backfill tasks do not actively delete staged blobs, but existing storage lifecycle still expires them; the client WAL remains the retry source.
  • Reuse the existing Core-features dashboard instead of introducing a competing dashboard. Its new log-based metric definitions, the Cloud Run Job and Scheduler, and production flags need an operator-managed rollout. A recovery notification uses the repository's typed notification dispatcher, not direct FCM calls.

Verification

  • backend/test.sh selected changed backend tests: passed (10 changed test files).
  • Focused backfill/self-heal and neighboring backend unit suites: passed (at least 439 tests in the recorded focused batches); notification-dispatch tests: 59 passed.
  • black --line-length 120 --skip-string-normalization on touched Python: clean.
  • make preflight: 35/35 checks passed. git diff --check: passed.
  • No live GCP reads/writes, production capture exercise, deployed artifact, or scheduled-job execution. Run detect-mode observability first, validate real structured Cloud Logging payloads and permissions, then require human approval before nudge/heal.

Product invariants affected

  • INV-MEM-4 — Recovery reuses the normal conversation finalizer; it adds no memory promotion path, and reprocess mode suppresses duplicate first-completion fan-out.
  • INV-TASK-2 — Recovery does not create a new task writer or alter capture policy, source eligibility, or the conservative extraction prompt.

Line-Count-Exception: backend/database/conversation_finalization_jobs.py | 2222 -> 2462 | The existing atomic outbox transaction must carry the recovery admission fence and the neighboring rotated cursor; moving the write would split lifecycle ownership.
Line-Count-Exception: backend/database/conversations.py | 3064 -> 3082 | The raw verification read belongs next to the decoded conversation reader so the persisted transcript fingerprint is compared without decoding.
Line-Count-Exception: backend/routers/sync.py | 2128 -> 2167 | Backfill pacing and terminal client-poll compatibility are checks at the existing v2 admission and worker response boundaries.
Line-Count-Exception: backend/utils/conversations/process_conversation.py | 3352 -> 3371 | The recovery-only empty-structure guard must run directly before completion persistence and derived fan-out.

Failure-Class: none

Generated with Devin

Review in cubic

Git-on-my-level and others added 8 commits September 25, 2026 16:18
Failure-Class: none

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Failure-Class: none

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Failure-Class: none

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Failure-Class: none

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
Failure-Class: none

Generated with [Devin](https://devin.ai)

Co-Authored-By: Devin <158243242+devin-ai-integration[bot]@users.noreply.github.com>
- test_conversation_relevance: SERVER_RECOVERY joins the KEEP set; the
  repair trigger must never let relevance discard the recovered copy,
  so the user-action-only invariant gains one documented server path.
- test_sync_silent_failure: stub database.sync_dead_letters in the
  hermetic process_segment harness; sync_jobs now imports it at module
  scope and the real module needs get_firestore_client.
@Git-on-my-level

Copy link
Copy Markdown
Member Author

Monitor run — CI repair + rebase onto current main (head 0812b03).

  • Rebased sca-556-selfheal onto latest main (was 48 behind) and fixed the three failing backend unit checks:
    • Shard 3 — test_conversation_relevance.py::test_only_user_actions_skip_assessment: the KEEP invariant now includes SERVER_RECOVERY. The repair trigger reprocesses a stale row the pipeline never finished; letting relevance discard the only recovered copy would defeat recovery itself. Docstring on ProcessingMode.relevance updated to match.
    • Shard 1 — test_sync_silent_failure.py::TestProcessSegmentReal (10 ImportErrors): database.sync_jobs now imports database.sync_dead_letters at module scope, and the real module needs get_firestore_client from database._client. The hermetic process_segment harness now stubs database.sync_dead_letters (same convention as sync_ledger).
  • Verification: both files pass through the repo test.sh runner (46 + 25 passed, incl. all 10 previously-erroring tests); full pre-push preflight passed (35 checks; line-count exceptions in the PR body cover the four growing files — growth compared, endpoints stale after rebase are fine).

Backend unit shards 1/4, 3/4 and the suite are green on the new head; no other failures.

@Git-on-my-level
Git-on-my-level merged commit 2438d01 into BasedHardware:main Sep 25, 2026
43 checks passed
Git-on-my-level added a commit that referenced this pull request Sep 25, 2026
## Summary
- Restore the release-eligibility `feature-flag-registry` gate: [main
push run](https://github.com/BasedHardware/omi/actions/runs/36130925731)
reports `backend/services/conversation_selfheal.py:75: unregistered
feature flag: SELFHEAL_MODE`.
- Root cause: merged #18855 introduced a `SELFHEAL_MODE` read after the
registry gate was tightened on 2026-09-24, without registering the flag.
- Register it as a backend environment-owned, fail-closed rollout
(`off|detect|nudge|heal`; default `off`) and regenerate the registry.
The Cloud Run Job is operator-provisioned, not part of `runtime_env`; no
deployment manifest, overlay, behavior, or flag value changes. The job
remains dormant pending a separate operator decision.

## Verification
- `python3 scripts/check_feature_flag_registry.py` — passed.
- `python3 scripts/test_check_feature_flag_registry.py` — 13 tests
passed.
- `python3 scripts/test_posthog_flag_sync.py` — 11 tests passed.
- `make preflight` — 17 manifest checks passed.
- No backend behavior changed; no live job was run.

Failure-Class: none

Generated with [Devin](https://devin.ai)


<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/18900?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 that referenced this pull request Sep 25, 2026
…obs (#18954)

Backfill jobs that reached failed/partial_failure before the dead-letter
ledger shipped (#18855) have no sync_dead_letters doc and no publisher left
to write one, so GET /v2/sync-local-files/<job_id> returned 503 forever.
Record the missing doc as pending on read (no confirmed-cohort event, no
replay consumer), then release the backfill slot and serve the terminal
status. 503 remains only for a failed ledger read/write or an identity
mismatch.

Failure-Class: FC-schema-adopted-only-at-resource-creation

Co-authored-by: Claude Opus 5.5 <[email protected]>
Git-on-my-level added a commit that referenced this pull request Nov 9, 2026
…bt, ops_kill defaults on (#24954)

<!-- claude-projects-attribution: {"github_login":"Git-on-my-level"} -->
_Requested by **David**_

David approved 2026-11-08 17:09Z: enforce review_by and done_by in CI,
sweep the registry metadata, and make ops_kill mean default on. This
applies those rules and the lead's subsequent sweep rulings. The
pre-sweep registry had 82 rollout/experiment rows whose review dates
would fail the old seven-day-grace checker on 2026-11-12, turning every
PR red without a sweep (measured against the saved pre-sweep registry on
2026-11-08 19:24Z).

- Use UTC for the default check date so UTC+7 pre-push hooks agree with
CI.
- Enforce review dates and pending rollout ramp completion dates with
the same seven-day grace. A row's single extension affects both
deadlines. Decided flags still read by code must retire their code
paths.
- Validate a single self-service extension of at most 14 days, with a
meaningful reason, lane, and grant date that has already occurred.
Compare against the merge-base to refuse second extensions and later
original deadlines, for pending and already-decided rows. Existing ramp
plans cannot lose their deadline while ramp enforcement still applies.
Missing merge-base data explicitly warns and skips diff rules.
- Count only pending rollout debt without a live dated ramp toward the
owner cap of five, including all new debt added in the same PR. Reject
any account token on new rows (existing rows are grandfathered), split
shared owners on /, comma, &, +, | and whitespace-delimited "and", and
count each debt row once per distinct normalized lane token. Remove the
dazheng backlog exception.
- Reject default-off ops_kill rows except the 18 remaining migration
exceptions, which expire 2026-11-29. Retain stale-entry and expiry
enforcement. Warn about rollout rows decided keep/with_legacy.
- Emit FLAG_DUE_SOON, FLAG_OVERDUE_COUNT, FLAG_DARK_OVER_14D and the
revised FLAG_OWNER_BACKLOG counts; regenerate the registry documentation
with its existing 2026-11-05 header.

The CSV contains 307 rows: 304 active rows were applied;
SYNC_BACKFILL_INFLIGHT_LIMIT was already retired in #19352, and two
DREAM_NO_PROGRESS_STOP_MODE rows retired in #24955 were preserved when
merging current main. None was recreated. All other 286 rows still owned
by dazheng were reassigned. Owner assignments to omi-pipeline now
require an existing origin/main assignment or
PROJECTION_DRAIN_LIVE_TARGET_BACKOFF. Assignments to backlog-refactor
require an existing origin/main assignment or the accepted BATCH_/SYNC_
scope; other previously inferred assignments go to auditfix pending
retirement or an explicit owner claim. No account owner token remains in
flags, ignored entries, or retired entries (verified with the same
tokenizer used by the checker). The ignored entries
localEmbeddingsEnabled and meeting_note_screenshots_enabled also move
from dazheng to auditfix; active flag owner counts below are unchanged.
All 97 exceptions introduced by #24950 are now extended rows, permanent
lifecycles, or retired upstream; REVIEW_OVERDUE and _AD1268_SWEEP are
removed.

| CSV action | Rows | Applied treatment |
| --- | ---: | --- |
| A | 15 | Extension through Nov22; two subsequently retired in #24955 |
| B | 65 | Extension through Nov22, preserving client-surface reason |
| C | 12 | Extension through Nov22 |
| D | 88 | Extension through Nov22 |
| E | 15 | Extension through Nov22 |
| E-MISMATCH | 40 | Extension through Nov22 |
| F → config_switch | 32 | Relabel permanent opt-in controls |
| F → rollout | 17 | Relabel and add missing review_by Nov22 only |
| G → config_switch | 15 | Relabel 14 active rows; one already retired |
| G → ops_kill | 8 | Per lead ruling, use config_switch because all
eight default off |

There are 234 bounded extensions, all granted Nov8 by auditfix and
ending Nov22. One additional extension covers
AUDIO_ARCHIVE_STOP_PCM_PERCENT, outside the CSV, whose unchanged Nov14
ramp deadline would otherwise fail Nov23. Permanent G relabels drop
inapplicable review/ramp metadata and preserve the old review date in
notes. No decision, terminal, parser fail/default, runtime value, or
production value changed. Existing dates were not postponed: the only
original review/ramp metadata changes are the explicitly approved G
removals; 17 missing F review dates were added. The checker change also
aligns the policy validation script (`backend/config/policy/guard.py`):
default-on live controls must remain ops_kill; opt-in live controls may
be config_switch or rollout. Hermetic fixtures cover both accepted and
rejected lifecycles. The backend flag-budget fixture also follows the
approved rollout labels and lane ownership, rather than freezing the
former account owner. No workflow or runtime application code changed.
No production access was used.

CSV proposed-owner counts (unowned mapped to auditfix): omi-pipeline
122; auditfix 82; backlog-refactor 78; uicleanup 19; firestore-lead 2;
cl2-coordkit 2; pgfoundation 1; cl2-deploy 1. The already-retired limit
row is included in the backlog-refactor source count; the two
subsequently retired Dream rows are included in the auditfix source
count.

Registry-wide owner counts after reassignment (712 rows). The ownership
correction moves 179 rows from omi-pipeline and 62 from backlog-refactor
to auditfix. The ownership correction changes no decision, deadline,
lifecycle, extension, fail/default, or runtime value. Shared-owner
validation now refuses account tokens on added rows and applies the cap
separately to each named lane, with duplicate lane tokens counted once;
existing rows remain exempt from the new-row account rule. Regression
fixtures cover every separator, lane-only acceptance, legacy rows,
shared existing debt and batched additions.

| Owner | Before correction | After correction |
| --- | ---: | ---: |
| auditfix | 190 | 431 |
| backlog-refactor | 181 | 119 |
| unowned | 40 | 40 |
| two-lane lead | 27 | 27 |
| uicleanup | 23 | 23 |
| backend | 14 | 14 |
| planscost | 8 | 8 |
| merge-desk | 6 | 6 |
| omi-pipeline | 184 | 5 |
| firestore-lead | 4 | 4 |
| home-overlap | 4 | 4 |
| review-desk | 4 | 4 |
| lead2 | 3 | 3 |
| two-lane rollout lead | 3 | 3 |
| cl2-coordkit | 2 | 2 |
| cl2-deploy | 2 | 2 |
| pgfoundation | 2 | 2 |
| speaker rollout lead | 2 | 2 |
| vroute-c / batch rollout lead | 2 | 2 |
| backend listen | 1 | 1 |
| backend runtime_env (PR #18855) | 1 | 1 |
| cl2-cost / lead2 | 1 | 1 |
| flightcut / batch rollout lead | 1 | 1 |
| fswrites | 1 | 1 |
| nik | 1 | 1 |
| omi-lifecycle | 1 | 1 |
| rollout-meetings | 1 | 1 |
| speakerrename | 1 | 1 |
| uicleanup (omi-lifecycle) | 1 | 1 |
| uicleanup / omi-lifecycle | 1 | 1 |

Validation (measured locally; CI is separate). The owner correction
reruns the fixtures, six as-of CLI checks, and unchanged normal push
hooks; historical broader audit results below are identified by scope.
No owner backlog exception has been added.


- `nice -n 15 timeout 1500 backend/.venv/bin/python -m unittest discover
-s scripts -p 'test_*flag*.py'`: **102 passed**, 146.373 seconds (91
checker fixtures and 11 PostHog fixtures). The focused owner subset
passed **14 tests**, including all requested spellings and shared-lane
cap cases.

- `nice -n 15 timeout 1500 backend/.venv/bin/python -m pytest -q
backend/tests/unit/test_flag_budget.py`: **24 passed** in the normal
push hook.
- Earlier registry-coupled backend audit using canonical
`backend/test.sh`, an explicit nine-file list and two isolated workers:
**430 tests passed across all 9 files** (includes the 24 budget tests
above). Default/off runtime assertions remain intact.
- Full local manifest preflight and supplied PR-body validation, through
the unchanged normal pre-push hook (same manifest as `make preflight`):
**40 checks passed**, 285 seconds. No skip flags. The remaining normal
pre-push gates also passed, and the branch was pushed successfully.
- Full checker CLI `scripts/check_feature_flag_registry.py --as-of DATE`
on head `99c25a16e58695b1e49729ea88070cb882e32c12`:

| As of | Errors | Result |
| --- | ---: | --- |
| 2026-11-08 | 0 | Pass |
| 2026-11-12 | 0 | Pass |
| 2026-11-16 | 0 | Pass |
| 2026-11-19 | 0 | Pass |
| 2026-11-23 | 28 | Only pre-existing duplicate-declaration exceptions
expired Nov20 (workstream B) |
| 2026-11-30 | 18 | Expected default-off ops_kill migration exceptions
expired Nov29 |

All twelve daily schema/deadline boundary checks for Nov8 through Nov19
also pass. Nov30 returns at schema validation on the 18 migration
expiries, so that output does not enumerate the subsequent row-deadline
failures. Raw outputs and UTC measurement receipts are saved in the
owning run directory as `out-checker-asof-<date>.txt` and
`checker-asof-receipt.json`.


Product invariants affected: none (`scripts/pr-preflight --suggest`).

Failure-Class: none

This hardens repository registry governance; no existing semantic
runtime failure class matches these validation bypasses. Reusable guards
and regression fixtures live in
`scripts/check_feature_flag_registry.py`,
`scripts/feature_flag_registry.py` and
`scripts/test_check_feature_flag_registry.py`.




<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/BasedHardware/omi/pull/24954?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="View guided diff"
src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<a
href="https://www.cubic.dev/action/auto-fix/pr/BasedHardware/omi/24954?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24954&source=description"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"><img
alt="Turn on auto-fix"
src="https://www.cubic.dev/buttons/turn-on-auto-fix-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

🤖 Generated with [Claude Code](https://claude.com/claude-code).
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