Skip to content

Restructuring - #10

Merged
Bentlybro merged 1 commit into
mainfrom
restructuring-docs
Mar 29, 2024
Merged

Bentlybro merged 1 commit into
mainfrom
restructuring-docs

Conversation

@akshaynarisetti

Copy link
Copy Markdown
Contributor

Changes:

1)Update readme about double-tap implemented in #9
2)Restructure README
3)Added Mermaid flow diagram

@Bentlybro Bentlybro left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM lets get this merged!

@Bentlybro
Bentlybro merged commit 0f5acb2 into main Mar 29, 2024
@Bentlybro
Bentlybro deleted the restructuring-docs branch March 29, 2024 12:59
mdmohsin7 added a commit that referenced this pull request Oct 18, 2025
closes #3241

before:


https://github.com/user-attachments/assets/d00d815c-8419-4c1b-96fb-ec20365fba44

logs:

```
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: Bad state: No element
flutter: 
#0      ListBase.firstWhere (dart:collection/list.dart:132:5)
#1      SharedPreferencesUtil.disableApp (package:omi/backend/preferences.dart:255:22)
#2      _AppDetailPageState._toggleApp (package:omi/pages/apps/app_detail/app_detail.dart:1129:13)
#3      _AppDetailPageState.build.<anonymous closure> (package:omi/pages/apps/app_detail/app_detail.dart:576:48)
#4      _AnimatedLoadingButtonState._handleOnPressed (package:omi/widgets/animated_loading_button.dart:38:27)
#5      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1204:21)
#6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:345:24)
#7      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:758:11)
#8      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:383:5)
#9      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:353:7)
#10     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:173:27)
#11
```

after:


https://github.com/user-attachments/assets/26ea5c91-e73a-44f4-ba76-4b804876c5df

<img width="1032" height="257" alt="Screenshot 2025-10-18 at 11 15
52 PM"
src="https://github.com/user-attachments/assets/44e4e46b-b654-4599-84ee-8ee0920b1cd3"
/>
@ellaaicare

Copy link
Copy Markdown

⚡ Phase 1.2 Complete: ElevenLabs True Streaming TTS

Results - Significant Improvement!

Metric OpenAI Blocking (Before) ElevenLabs Streaming (After) Improvement
STT (Deepgram) 1193ms 943ms -250ms
LLM (Groq) 327ms 184ms -143ms
TTS TTFB 1116ms 498ms -618ms (55%)
TTS Total 1116ms 753ms -363ms
TOTAL 3172ms 2134ms -1038ms (33%)

Key Findings

✅ ElevenLabs true streaming works - First audio chunk arrives at 498ms vs 1116ms with OpenAI
✅ 1+ second faster - Total response time dropped from 3.2s to 2.1s
✅ User hears response 618ms sooner - Significant UX improvement

Implementation Details

  • Using eleven_turbo_v2_5 model (fastest)
  • Output format: pcm_16000 (16kHz PCM16 for iOS compatibility)
  • Streaming chunks: 1024 bytes (vs 4096 with OpenAI)
  • Voice: Rachel (21m00Tcm4TlvDq8ikWAM)

Rollback Configuration

# To rollback to OpenAI TTS:
TTS_PROVIDER=openai  # Default

# Current production (ElevenLabs):
TTS_PROVIDER=elevenlabs

Commits

  • 183f28321 - feat(voice): implement ElevenLabs true streaming TTS
  • 73c5c94b3 - fix(voice): use correct ElevenLabs SDK stream() method
  • bacf4e1b3 - fix(voice): remove await from async generator stream()

Next Steps

Phase 1.2 is complete! Consider:

  1. Try Deepgram Aura or Cartesia Sonic for even faster TTFB (~150-300ms)
  2. Optimize STT (still ~1s, could use faster Deepgram model)
  3. Consider Phase 2: Voice-to-voice multimodal LLMs

beastoin added a commit that referenced this pull request Mar 19, 2026
Shared singleton that tracks consecutive 401/Unauthorized errors
across all polling operations. Backoff intervals: 5s, 15s, 30s,
60s cap. Resets on any successful auth call.

Fixes #5784 (friction #10: error log spam)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
Changes:

1)Update readme about double-tap implemented in BasedHardware#9
2)Restructure README 
3)Added Mermaid flow diagram
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
closes BasedHardware#3241

before:


https://github.com/user-attachments/assets/d00d815c-8419-4c1b-96fb-ec20365fba44

logs:

```
flutter: ----------------FIREBASE CRASHLYTICS----------------
flutter: Bad state: No element
flutter: 
#0      ListBase.firstWhere (dart:collection/list.dart:132:5)
#1      SharedPreferencesUtil.disableApp (package:omi/backend/preferences.dart:255:22)
BasedHardware#2      _AppDetailPageState._toggleApp (package:omi/pages/apps/app_detail/app_detail.dart:1129:13)
BasedHardware#3      _AppDetailPageState.build.<anonymous closure> (package:omi/pages/apps/app_detail/app_detail.dart:576:48)
BasedHardware#4      _AnimatedLoadingButtonState._handleOnPressed (package:omi/widgets/animated_loading_button.dart:38:27)
BasedHardware#5      _InkResponseState.handleTap (package:flutter/src/material/ink_well.dart:1204:21)
BasedHardware#6      GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:345:24)
BasedHardware#7      TapGestureRecognizer.handleTapUp (package:flutter/src/gestures/tap.dart:758:11)
BasedHardware#8      BaseTapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:383:5)
BasedHardware#9      BaseTapGestureRecognizer.acceptGesture (package:flutter/src/gestures/tap.dart:353:7)
BasedHardware#10     GestureArenaManager.sweep (package:flutter/src/gestures/arena.dart:173:27)
BasedHardware#11
```

after:


https://github.com/user-attachments/assets/26ea5c91-e73a-44f4-ba76-4b804876c5df

<img width="1032" height="257" alt="Screenshot 2025-10-18 at 11 15
52 PM"
src="https://github.com/user-attachments/assets/44e4e46b-b654-4599-84ee-8ee0920b1cd3"
/>
Glucksberg pushed a commit to Glucksberg/omi-local that referenced this pull request Apr 28, 2026
Shared singleton that tracks consecutive 401/Unauthorized errors
across all polling operations. Backoff intervals: 5s, 15s, 30s,
60s cap. Resets on any successful auth call.

Fixes BasedHardware#5784 (friction BasedHardware#10: error log spam)

Co-Authored-By: Claude Opus 4.6 <[email protected]>
choguun added a commit to choguun/omi that referenced this pull request Jun 25, 2026
CI lint fix (the only thing blocking merge):
- Ran black --line-length 120 --skip-string-normalization on 7 files that
  the Lint & Format Check job flagged. All 13 .py files now pass --check.

P1 #1: AutoRouter.swift:105 guard treated "model: null" as failure and
left stale cached pick active. If the endpoint reports 'no candidate for
this task today', the client would keep routing to yesterday's model.
Fix: explicitly handle null by clearing the cached pick (removeObject
for both keys). Also fixed invalidate(task:) to clear BOTH the pick and
the date (was: only the date). 2 new Swift tests cover both.

P1 BasedHardware#2: benchmark.py bench_endpoint_cached ignored get_or_refresh's return
value and relied on  side effects. On a cache hit, the loader
doesn't run, so tasks/models stay None and the next call crashes.
Fix: use the return value of get_or_refresh in an async helper.

P2 BasedHardware#3: invalidate(task:) now also clears the cached pick (was: only date).
Done as part of P1 #1.

P2 BasedHardware#4: Demo's 'Original weights' were hardcoded in main(); now read from
the task registry (weights_for(task_name)) so demo output tracks
benchmarks.example.json changes instead of going stale.

P2 BasedHardware#6: from_json didn't validate top-level shape (not a dict), or that
'tasks' is a list / 'models' is a dict. Would crash with AttributeError on
bad input. Now raises clean TaskValidationError/ModelValidationError.
Added 6 new tests (3 in task_registry, 3 in model_registry).

P2 BasedHardware#7: updated_at in the endpoint was datetime.now() — reported RESPONSE
time, not cache refresh time. Misleading for 'is this data fresh?' Added
last_loaded_at + last_loaded_wall_time() properties to DailyRefreshCache
(used by the endpoint).

P2 BasedHardware#8: _load_registries() does blocking JSON file I/O inside an async def,
which the project conventions forbid (per CLAUDE.md: 'no in-function
imports, never call sync file I/O inside async def'). Fix: wrap with
run_blocking(sync_executor, _load_registries) via a lazy _get_loader()
helper. The cache loader is now an async function that schedules the
sync I/O on the threadpool.

P2 BasedHardware#9: New test modules were not in backend/test.sh, so CI was skipping
them. Added explicit pytest invocations for all 6 auto-router test
files, right before the fair-use integration tests section.

P2 BasedHardware#10: README + docs/auto-router-demo.md used PYENV_VERSION=3.12.8 but
backend's .python-version declares 3.11. Updated to 3.11.11 (verified all
142 tests pass under 3.11.11 with pytest-asyncio installed).

Tests added: +8 (137 → 142 backend; 13 → 15 desktop)
Total: 142 backend + 15 desktop = 157 tests, all passing.

Cubic findings NOT addressed (subjective or already correct):
- P2 'Plan redefines the diff budget': per-task commits are correct.
- P2 'Acceptance criteria tie-breaking wrong': tie-breaking is in the
  endpoint, not scoring — cubic is wrong.
- P2 'UAT-FN-07 inaccurate': that finding is now resolved by
  test_auto_router_demo.py (added in this cycle).
- P2 'UAT-FN-01 outdated': the fix is real; the current code does NOT
  leak task names (verified via TestClient in test_auto_router_endpoint).
- P2 'Benchmark uses template data': intentional for v1; documented.
- P3 nits: docstring, diff-hygiene wording, test-count arithmetic.
Git-on-my-level added a commit that referenced this pull request Jul 9, 2026
P1 fixes:
- ChatProvider: resume suspended waiter continuation inside the task
  group body on timeout, preventing withTaskGroup hang (#1).
- AgentRuntimeProcess: route stale-alive latch through handleTermination
  so in-flight continuations are resumed and the old terminationHandler
  is properly superseded (#2).
- WALService: startRecording no longer discards retained frames when the
  best-effort retry fails — preserves audio for next flush (#14).

P2 fixes:
- WALService: remove duplicate wal_write_failed health event recording
  in createWalFromCurrentFrames; writeFramesToDiskAndWait already
  records it (#3).
- BleAudioService: reset isDecodeDegraded on successful decode so the
  flag reflects current processor state instead of staying sticky (#5).
- TranscriptionRetryService: record db-backoff pause via
  DesktopDiagnosticsManager.recordFallback for observability (#7).
- APIClient: derive auth retry outcome from response status code instead
  of assuming success before callers validate 2xx (#9).
- APIClientAuthRetryTests: clean up UserDefaults authUserId in tearDown
  to prevent state leak (#8).
- ChatBridgeModeSwitchTimeoutTests: remove meaningless defer { assertion
  that passes regardless of mode-switch cleanup (#10).
- TranscriptionRetryResilienceTests: check busy-error guard by semantic
  elements instead of exact formatting (#11); remove fragile negative
  assertion (#12).
- capture-lifecycle.yaml: remove 5 files from covers: that the hermetic
  seam does not exercise at runtime (#13).

Verification:
- xcrun swiftc -parse on all 8 changed Swift files: clean
- git diff --check: no whitespace errors
- check-desktop-changelog.py: fragment found
- check-e2e-flow-coverage.py --strict: passes (exit 0)

Co-authored-by: Cursor <[email protected]>
ZachL111 added a commit to ZachL111/omi that referenced this pull request Jul 10, 2026
The backend derives desktop release notes from GitHub releases but only exposes them as Sparkle
appcast XML for the auto-updater. This adds a JSON feed an in-app What's New screen can consume
(issue BasedHardware#3474, milestone BasedHardware#10), reusing the same live-release gating and changelog parsing.

- routers/updates.py: GET /v2/desktop/whats-new returns recent live release changelogs newest-first,
  filtered by platform/channel and an optional since_build (only newer releases). Two pure helpers
  (_release_entry_to_whats_new, _filter_whats_new) reuse _get_live_desktop_releases and
  _parse_changelog_to_changes. Returns 200 with an empty items list when nothing is newer.
ZachL111 added a commit to ZachL111/omi that referenced this pull request Jul 10, 2026
The backend derives desktop release notes from GitHub releases but only exposes them as Sparkle
appcast XML for the auto-updater. This adds a JSON feed an in-app What's New screen can consume
(issue BasedHardware#3474, milestone BasedHardware#10), reusing the same live-release gating and changelog parsing.

- routers/updates.py: GET /v2/desktop/whats-new returns recent live release changelogs newest-first,
  filtered by platform/channel and an optional since_build (only newer releases). Two pure helpers
  (_release_entry_to_whats_new, _filter_whats_new) reuse _get_live_desktop_releases and
  _parse_changelog_to_changes. Returns 200 with an empty items list when nothing is newer.
aryanorastar pushed a commit to aryanorastar/omi that referenced this pull request Jul 22, 2026
feat(windows): Phase 4 — top-edge bar + the Omi orb (identity layer)
abunet added a commit to abunet/omi that referenced this pull request Aug 14, 2026
…cubic 10887 BasedHardware#4/BasedHardware#10/#11d)

list_review_conflicts paginates ordered by impact DESC, created_at DESC, __name__ DESC (three fields),
but the store keyset was single-field: _resolve_start_after raised NotImplementedError, so page 2 of the
review queue broke on Mongo (BasedHardware#4). The Mongo adapter also silently ignored order fields after the first
(BasedHardware#10) and the Firestore adapter built a 2-value cursor for >2 order fields (#11d). Rather than reject
multi-field cursors, implement them.

- Store cursor generalized to {"values": [<one per REAL order field>], "id": <doc id>} (a trailing
  __name__ / no order is the _id tiebreak; the old {"value": v} shape still works).
- Mongo query: a strictly-after lexicographic keyset — OR of (all prior fields equal AND next field
  strictly after), ending in the _id tiebreak — generalizing the single-field and __name__-only cases.
- Firestore query: order by each field (append __name__ if absent), cursor = one value per real field +
  the doc id.
- Facade: _resolve_start_after reads each real order field off the snapshot/cursor into `values`; _run
  passes the full multi-field order_by through.
- FakeDocumentStore.query: one unified lexicographic path — also fixes the crash when start_after is
  passed with order_by=None (the fake compared None > str; cubic store_fakes BasedHardware#223).

Verify (rule 12, live dual-backend fresh): contract 104 passed (+2: a 3-field impact/created_at/__name__
DESC cursor pages correctly, incl. an (impact,created_at)-tie resolved by the id tiebreak, on both
Firestore emulator and Mongo). Facade hermetic 19 (review-queue-shaped cursor via the facade). Guard 0;
store/facade sweep 0 regressions.
Git-on-my-level added a commit that referenced this pull request Nov 27, 2026
…s 503 (SCA-2225) (#26458)

## What

Every handler-level designed 503 refusal on `POST /v2/sync-local-files`
now writes exactly one INFO record:

`sync_upload_refused uid=%s status=503 reason=%s trace=<32-hex
X-Cloud-Trace-Context id>`

The mechanism lives in `utils/sync/designed_refusal.py`:
- The handler calls `mark_designed_refusal(...)` right before the
designed 503.
- `designed_refusal_outcome`, the innermost decorator, captures the
handler's own response or exception.
- `records_designed_refusals`, outside `custody_upload`, writes the
record only if the final outcome is that same object and is a 503. A 503
that the custody finalizer substitutes is left unrecorded.
- The fence cutover is marked only when `SYNC_LEDGER_FENCE_MODE` is
explicitly `standby`, so an invalid setting that fails closed is not
marked.

The existing `backfill_day_cap` line moves onto this mechanism. Failure
503s write no record. Those include `sync_dispatch_unavailable` (staging
or sequencer), `sync_batch_unavailable` from batch-admission errors,
custody, config and platform 503s.

## Why

SCA-2225. The Cloud Run rollout guard used to exclude every
sync-local-files 503 (`refusal_statuses: [503]`), which hid real
failures. Removing that exclusion outright flips the labelled trip
backtest, because designed backpressure then counts as errors. Luna
approved a design on SCA-2225 (2026-11-27T00:09Z): exclude a 503 only
when the same revision logged a designed-refusal record for the same
request, and hold on anything that cannot be reconciled. The `trace=`
field lets the guard match each record to its own request log
one-to-one, so window edges do not skew the counts. The guard side of
the change is a separate PR stacked on #26438 (linked below).

Production shape check (ro-prod `read-only-bot-account`, 2026-11-27,
projections only, no payloads or uids read): backend-sync 503 request
logs for this route carry `trace=projects/based-hardware/traces/<id>`.
The existing `sync_upload_refused … status=503` records land in
`run.googleapis.com%2Fstdout` with `resource.labels.revision_name`.

### 503 inventory: `POST /v2/sync-local-files` (BasedHardware/omi
`origin/main` f628eab)

Line numbers are at f628eab. "Record" means one `sync_upload_refused
uid=… status=503 reason=… trace=…` line. The handler marks the refusal
right before its 503, and the outermost wrapper writes the line only if
that same 503 is the final response. Before this change, only #8 wrote a
record, and that record had no trace. `sync_upload_refused` is written
only inside `sync_local_files_v2`; no other route or file writes that
string.

| # | file:line | code | trigger | designed? | record before | record
after |
|---|---|---|---|---|---|---|
| 1 | utils/sync/stage.py:50 (router dependency) | stage unavailable |
`OMI_ENV_STAGE` missing or invalid | failure (config) | no | no (counts
as error) |
| 2 | utils/other/endpoints.py:65 | `directory_routing_unavailable` |
directory resolution fails | failure | no | no |
| 3 | utils/other/endpoints.py:112 |
`account_deletion_state_unavailable` | deletion-fence read raises |
failure | no | no |
| 4 | utils/account_cutover/access.py:260/262 |
`account_cutover_state_unavailable` | cutover state unreadable | failure
| no | no |
| 5 | live_upload.py:118 via `memoized_record_wait` (sync.py:852) |
`record_capture_pending` | cached conversation-level wait | designed |
no | **no (gap, see below)** |
| 6 | sync.py:873 | `sync_ledger_fence_cutover` | fence mode STANDBY |
designed pause only when explicitly configured* | no | **yes, explicit
standby only** `sync_ledger_fence_cutover` |
| 7 | sync.py:973 | `backfill_capacity` | backfill lane,
`SYNC_BACKFILL_ENABLED` off | designed (kill switch) | no | **yes**
`backfill_disabled` |
| 8 | sync.py:1040 (log at 1038) | `backfill_capacity` | unlimited_v2
backfill day cap | designed | yes, no trace | **yes**
`backfill_day_cap`, now with trace |
| 9 | utils/sync/record_token_lease.py:120 | custody admission |
`record_custody_append.begin` raises | failure (custody) | no | no |
| 10 | utils/sync/receipt_clock.py:197 / :204 |
`capture_clock_anchor_unavailable` | :197 too many scopes (bounded
refusal); :204 read fails | :197 designed, :204 failure | no | no (gap
for :197) |
| 11 | sync.py:1118 | "Historical recovery is paused" | retained
recovery while backfill is off | designed | no | **yes**
`retained_recovery_disabled` |
| 12 | sync.py:1169 | `capture_clock_identity_required` | future-clock
files with no device id | designed | no | **yes**
`capture_clock_identity_required` |
| 13 | live_upload.py:118 via record router (sync.py:1265,
intake.py:750) | `record_capture_pending` | 9 wait reasons are designed;
4 `*_failed` reasons are failures | mixed | no | no (gap for the waits)
|
| 14 | intake.py:749 | `record_capture_pending` | `record_router` is
None | wiring fault, unreachable | no | no |
| 15 | utils/batch_pipeline/upload_coalescing.py:242 |
`sync_batch_unavailable`, Retry-After 1 | coalescing wait | designed |
no | no (gap) |
| 16 | intake.py:987 | `sync_batch_unavailable` | decode-failure memo
hit | designed repeat | no | no (gap) |
| 17 | intake.py:1271 (`FutureCaptureRetry`) |
`capture_clock_anchor_pending` / `identity_required` /
`anchor_unavailable` | clock anchoring in batch decode | pending and
identity designed; unavailable failure | no | no (gap) |
| 18 | intake.py:1298 | `sync_batch_unavailable` | any batch-admission
exception | failure | no | no |
| 19 | sync.py:1421 | `sync_batch_unavailable` | batch declined an
estimated or retained-clock upload | designed decline | no | **yes**
`repaired_clock_batch_declined` |
| 20 | sync.py:1608 | `backfill_capacity` | backfill lane but not Cloud
Tasks eligible | failure (config, fail closed) | no | no |
| 21 | sync.py:1664 | `dispatch_hold` | staging hit
`DestructiveOperationInProgress` | designed pause | no | **yes**
`dispatch_hold` |
| 22 | sync.py:1675 | `sync_dispatch_unavailable` | GCS staging failed |
failure | no | no (counts) |
| 23 | sync.py:1758 | `sync_dispatch_unavailable` | sequencer
registration failed | failure | no | no (counts) |
| 24 | record_token_lease.py:93 (`@custody_upload` finally) | custody |
`record_custody_append.finish` raises; can replace any response |
failure | no | no |
| — | Cloud Run platform | — | no instance, queue full, crash | infra |
no app log | no (counts) |

\* #6: an invalid fence setting also fails closed to STANDBY
(`database/sync_jobs.py:154`) and returns the same 503. Since 61972e1,
only `SYNC_LEDGER_FENCE_MODE=standby` is marked; an invalid setting
stays unrecorded and counts as an error (regression test included).

**Records gap (designed, but still counted as errors):** #5, #10:197,
the wait reasons in #13, #15, #16, and #17 pending/identity. These 503s
come from below the handler: `live_upload`, batch intake,
`receipt_clock`. There the request's trace is not in scope, and the same
response code is shared with failure paths. Batch intake's outer `try`
also rewrites exceptions into the generic `sync_batch_unavailable`.
Recording them needs the trace passed down (for example a contextvar)
and its own review. Until then they count as errors on both revisions,
which is the conservative direction: a candidate that changes their rate
is scored as a 5xx change.

**Custody finalizer (#24), fixed in 61972e1:** the record used to be
written before `@custody_upload` finished, so a finalizer 503 could
replace a designed response after its record existed. Now
`designed_refusal_outcome`, the innermost layer, captures the handler's
own response or exception, and `records_designed_refusals`, outside
`custody_upload`, writes the record only if the final outcome is that
same object and is a 503. A finalizer-replaced 503 stays unrecorded and
counts (regression test included).

**Logging path:** the `utils/sync/designed_refusal.py` logger propagates
to the root handler that `main.py:27` installs through
`configure_logging(K_SERVICE, default_format='text', …)`. That handler
writes INFO to stdout as `INFO utils.sync.designed_refusal:
sync_upload_refused uid=… status=503 reason=… trace=<32 hex>`. Cloud Run
ingests stdout as `textPayload` in `run.googleapis.com%2Fstdout` and
labels it with `resource.labels.revision_name`. The trace comes from the
`X-Cloud-Trace-Context` header the handler already declares. It is the
trace id Cloud Run writes into the request log's `trace` field. No PII
is added beyond the existing `uid=` pattern.

## Composition and order

- This PR touches no guard files, so it has no conflict with #26438
(`lane/holdback-wiring`). The guard change is a separate PR stacked on
#26438: #26459. The workspace copy is Git-on-my-level/omi-workspace
#586.
- **Order:** this PR should be serving on backend-sync before either
guard change scores Sync. Before that, a revision's old
`backfill_day_cap` record carries no `trace=`, and the guard holds
(`INSUFFICIENT_DATA refusal_records_unparseable_record`) on any window
where that revision logged one. The first comparison against a pre-trace
inverse can therefore hold once.
- Rollback: revert this PR. The records are log-only; responses and
behavior are unchanged.

## Verification

Run with `omi-heavy run -- timeout 1800 bash test.sh …` (local,
hermetic):
- `test_sync_designed_refusal_record.py`: 19 passed.
- `test_sync_backfill_day_cap_upload.py` 11,
`test_logging_entrypoint_guard.py` 51,
`test_sync_ledger_fence_cutover.py` 14, `test_sync_capture_time_skew.py`
160: all passed.
- The other suites that touch `sync_local_files_v2` (future-early
parity, schema inventory, legacy dark, fair use, mobile standard batch,
batch language router, cloud tasks, assignment recovery, `test_sync_v2`,
batch intake outcome, custody admission privacy): 14, 15, 48, 30, 27,
31, 40, 210, 13, 51 and 193 passed.

The new tests cover:
- the record format and trace parsing, and the guard parser reading the
shared text format;
- a raised designed 503, which is recorded once and still raised;
- a mark made without the outer recorder, which writes nothing;
- **custody finish failing after a designed refusal**, which gives the
finalizer's 503 and no record; a clean finish records once;
- a wrapper replacing the response, which writes no record;
- the decorator order: recorder, then custody, then observe, then
capture, then handler;
- **an explicit `standby` fence, which is recorded; an invalid setting
(`stanby`, `on`) gives the same 503 with no record and logs
`invalid_config`**;
- a real over-cap upload, which writes exactly one traced record;
- an AST check that the seven marks each sit directly before a designed
503.

Not proven here: that production records carry the trace id. That needs
this PR serving, then a READBACK that `sync_upload_refused … trace=`
lines match request-log traces on the same revision.

Line-Count-Exception: backend/routers/sync.py | 4393 -> 4405 | seven
designed-refusal marks, the explicit-standby guard and two decorator
lines; the mechanism lives in utils/sync/designed_refusal.py

## Product invariants affected

none

🤖 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.

3 participants