Repository navigation
Fair use: let the throttle stage decay back down - #24531
Conversation
There was a problem hiding this comment.
7 issues found across 13 files
Confidence score: 2/5
backend/utils/fair_use.pystill writes restrict expiry unconditionally, so a stale read can overwrite a concurrent reset or upgrade clear and reapplythrottle. Route the decay through the existing compare-and-set transaction.- The new failure-class definition in
.github/failure-classes/FC-state-deadline-without-reader-exit.jsonis undeclared, so validation fails withmissing_declaration. AddFailure-Class: newto the PR body. backend/models/fair_use.pyleaves the warning deadline and stage-entry timestamp behind during upgrade cleanup, so cleared users retain stale state and dwell telemetry attributes prior enforcement time tonone. Clear both fields during cleanup.backend/docs/feature-flag-registry.mdomits the flag’s default-on behavior and supported disable values, which can mislead operators. Document the exacttrue/false/off/0semantics and regenerate the registry entries.
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="backend/tests/unit/test_fair_use_engine.py">
<violation number="1" location="backend/tests/unit/test_fair_use_engine.py:539">
P3: This assertion no longer verifies the write count or UID. A duplicate or mis-targeted state update would pass; retain a single-call assertion and check that the first argument is `user1`.</violation>
</file>
<file name="backend/utils/observability/fair_use.py">
<violation number="1" location="backend/utils/observability/fair_use.py:23">
P3: Concurrent fair-use reads can make this gauge report an older dwell value than the latest authoritative read. Track the observation timestamp and update the gauge only when the sample is newer than the current one.</violation>
</file>
<file name="backend/docs/feature-flag-registry.md">
<violation number="1" location="backend/docs/feature-flag-registry.md:523">
P3: This generated registry now contains a flag created on 2026-11-04 but is still stamped as-of 2026-11-02. Update the as-of date and regenerate the document so the catalog’s freshness and date-based review information remain truthful.</violation>
<violation number="2" location="backend/docs/feature-flag-registry.md:523">
P3: The registry summary omits the flag’s default-on behavior and the supported `false`/`0` disable values. Mirror the exact `true`/`false`/`off`/`0` semantics in the source summary and regenerate both added registry entries so operators can use this page for rollback.</violation>
</file>
<file name="backend/utils/fair_use.py">
<violation number="1" location="backend/utils/fair_use.py:738">
P1: Restrict expiry still uses an unconditional write, so a stale read can overwrite a concurrent reset or upgrade clear with `stage: throttle`. Route this decay through the same compare-and-set transaction used for throttle and warning exits.</violation>
</file>
<file name=".github/failure-classes/FC-state-deadline-without-reader-exit.json">
<violation number="1" location=".github/failure-classes/FC-state-deadline-without-reader-exit.json:3">
P2: This new failure-class definition is not declared in the PR body. Add `Failure-Class: new`; validation currently fails with `missing_declaration` because this PR contains fix commits.</violation>
</file>
<file name="backend/models/fair_use.py">
<violation number="1" location="backend/models/fair_use.py:70">
P3: Upgrade cleanup leaves the new warning deadline and stage-entry timestamp behind, so cleared users retain inconsistent state and dwell telemetry attributes prior enforcement time to `none`. Clear both fields when `clear_fair_use_on_upgrade` resets the stage.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| 'warning_until': None, | ||
| } | ||
| ) | ||
| fair_use_db.update_fair_use_state(uid, updates) |
There was a problem hiding this comment.
P1: Restrict expiry still uses an unconditional write, so a stale read can overwrite a concurrent reset or upgrade clear with stage: throttle. Route this decay through the same compare-and-set transaction used for throttle and warning exits.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/fair_use.py, line 738:
<comment>Restrict expiry still uses an unconditional write, so a stale read can overwrite a concurrent reset or upgrade clear with `stage: throttle`. Route this decay through the same compare-and-set transaction used for throttle and warning exits.</comment>
<file context>
@@ -656,9 +726,20 @@ def normalize_expired_restriction_state(
+ 'warning_until': None,
+ }
+ )
+ fair_use_db.update_fair_use_state(uid, updates)
invalidate_enforcement_cache(uid)
- normalized_state.update({'stage': 'throttle', 'restrict_until': None})
</file context>
| @@ -0,0 +1,15 @@ | |||
| { | |||
| "schema_version": 1, | |||
| "id": "FC-state-deadline-without-reader-exit", | |||
There was a problem hiding this comment.
P2: This new failure-class definition is not declared in the PR body. Add Failure-Class: new; validation currently fails with missing_declaration because this PR contains fix commits.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/failure-classes/FC-state-deadline-without-reader-exit.json, line 3:
<comment>This new failure-class definition is not declared in the PR body. Add `Failure-Class: new`; validation currently fails with `missing_declaration` because this PR contains fix commits.</comment>
<file context>
@@ -0,0 +1,15 @@
+{
+ "schema_version": 1,
+ "id": "FC-state-deadline-without-reader-exit",
+ "violated_contract": "An automatically entered nonterminal state must have a deadline written at entry and an automatic exit consumed by its readers. A downward ladder must reach its base state. Fair-use throttle_until was written but never read, leaving throttle absorbing after restrict expiry.",
+ "canonical_prevention": "Persist stage entry and expiry together, normalize expired states at authoritative read boundaries, fail safe on missing or malformed deadlines, and verify the complete downward ladder with a fake clock, alongside bounded dwell and transition telemetry. Conditional writes must preserve concurrent escalations and deadline renewals.",
</file context>
| _fair_use_db.update_fair_use_state.assert_called_once_with( | ||
| 'user1', {'stage': 'throttle', 'restrict_until': None} | ||
| ) | ||
| updates = _fair_use_db.update_fair_use_state.call_args.args[1] |
There was a problem hiding this comment.
P3: This assertion no longer verifies the write count or UID. A duplicate or mis-targeted state update would pass; retain a single-call assertion and check that the first argument is user1.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/tests/unit/test_fair_use_engine.py, line 539:
<comment>This assertion no longer verifies the write count or UID. A duplicate or mis-targeted state update would pass; retain a single-call assertion and check that the first argument is `user1`.</comment>
<file context>
@@ -530,9 +536,10 @@ def test_expired_restriction_reads_as_throttle_on_cache_miss(self):
- _fair_use_db.update_fair_use_state.assert_called_once_with(
- 'user1', {'stage': 'throttle', 'restrict_until': None}
- )
+ updates = _fair_use_db.update_fair_use_state.call_args.args[1]
+ assert updates['stage'] == 'throttle'
+ assert updates['restrict_until'] is None
</file context>
| updates = _fair_use_db.update_fair_use_state.call_args.args[1] | |
| _fair_use_db.update_fair_use_state.assert_called_once() | |
| assert _fair_use_db.update_fair_use_state.call_args.args[0] == 'user1' | |
| updates = _fair_use_db.update_fair_use_state.call_args.args[1] |
|
|
||
| def observe_stage_dwell(stage: str, seconds: float) -> None: | ||
| if stage in STAGES: | ||
| STAGE_DWELL_SECONDS.labels(stage=stage).set(seconds) |
There was a problem hiding this comment.
P3: Concurrent fair-use reads can make this gauge report an older dwell value than the latest authoritative read. Track the observation timestamp and update the gauge only when the sample is newer than the current one.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/utils/observability/fair_use.py, line 23:
<comment>Concurrent fair-use reads can make this gauge report an older dwell value than the latest authoritative read. Track the observation timestamp and update the gauge only when the sample is newer than the current one.</comment>
<file context>
@@ -0,0 +1,28 @@
+
+def observe_stage_dwell(stage: str, seconds: float) -> None:
+ if stage in STAGES:
+ STAGE_DWELL_SECONDS.labels(stage=stage).set(seconds)
+
+
</file context>
| | `EPISODE_RECORDED_TIME_ENABLED` | Default on; resolve episode ownership by recorded timestamps for every device and late capture | backend | env | open | — | — | — | — | keep | keep | — | dazheng | | ||
| | `FAIR_USE_ENABLED` | Enforce fair-use metering; set false to stop enforcement | backend | env | closed | — | true (backend-listen (chart)) | true (backend-listen (chart)) | — | keep | keep | — | unowned | | ||
| | `FAIR_USE_KILL_SWITCH` | Emergency stop for fair-use enforcement | backend | env | inverted | — | false (backend-listen (chart)) | false (backend-listen (chart)) | — | keep | keep | — | unowned | | ||
| | `FAIR_USE_THROTTLE_DECAY_ENABLED` | Decay expired throttle and quiet warnings on read; set off to restore restrict-only decay | backend | env | open | — | — | — | — | keep | keep | — | backend | |
There was a problem hiding this comment.
P3: This generated registry now contains a flag created on 2026-11-04 but is still stamped as-of 2026-11-02. Update the as-of date and regenerate the document so the catalog’s freshness and date-based review information remain truthful.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/feature-flag-registry.md, line 523:
<comment>This generated registry now contains a flag created on 2026-11-04 but is still stamped as-of 2026-11-02. Update the as-of date and regenerate the document so the catalog’s freshness and date-based review information remain truthful.</comment>
<file context>
@@ -520,6 +520,7 @@ and an explicit empty literal renders as `''`.
| `EPISODE_RECORDED_TIME_ENABLED` | Default on; resolve episode ownership by recorded timestamps for every device and late capture | backend | env | open | — | — | — | — | keep | keep | — | dazheng |
| `FAIR_USE_ENABLED` | Enforce fair-use metering; set false to stop enforcement | backend | env | closed | — | true (backend-listen (chart)) | true (backend-listen (chart)) | — | keep | keep | — | unowned |
| `FAIR_USE_KILL_SWITCH` | Emergency stop for fair-use enforcement | backend | env | inverted | — | false (backend-listen (chart)) | false (backend-listen (chart)) | — | keep | keep | — | unowned |
+| `FAIR_USE_THROTTLE_DECAY_ENABLED` | Decay expired throttle and quiet warnings on read; set off to restore restrict-only decay | backend | env | open | — | — | — | — | keep | keep | — | backend |
| `FSR_KG_CITATION_INDEX` | Default on; query native reverse citations for KG node pruning; off restores the node scan | backend | env | open | — | — | — | — | keep | keep | — | dazheng |
| `FSR_MAINTENANCE_COORDINATION_ENABLED` | Default on in prod independently of read-lever rollback; explicit false restores per-replica maintenance | backend | env | open | — | — | — | — | keep | keep | — | dazheng |
</file context>
| | `EPISODE_RECORDED_TIME_ENABLED` | Default on; resolve episode ownership by recorded timestamps for every device and late capture | backend | env | open | — | — | — | — | keep | keep | — | dazheng | | ||
| | `FAIR_USE_ENABLED` | Enforce fair-use metering; set false to stop enforcement | backend | env | closed | — | true (backend-listen (chart)) | true (backend-listen (chart)) | — | keep | keep | — | unowned | | ||
| | `FAIR_USE_KILL_SWITCH` | Emergency stop for fair-use enforcement | backend | env | inverted | — | false (backend-listen (chart)) | false (backend-listen (chart)) | — | keep | keep | — | unowned | | ||
| | `FAIR_USE_THROTTLE_DECAY_ENABLED` | Decay expired throttle and quiet warnings on read; set off to restore restrict-only decay | backend | env | open | — | — | — | — | keep | keep | — | backend | |
There was a problem hiding this comment.
P3: The registry summary omits the flag’s default-on behavior and the supported false/0 disable values. Mirror the exact true/false/off/0 semantics in the source summary and regenerate both added registry entries so operators can use this page for rollback.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/docs/feature-flag-registry.md, line 523:
<comment>The registry summary omits the flag’s default-on behavior and the supported `false`/`0` disable values. Mirror the exact `true`/`false`/`off`/`0` semantics in the source summary and regenerate both added registry entries so operators can use this page for rollback.</comment>
<file context>
@@ -520,6 +520,7 @@ and an explicit empty literal renders as `''`.
| `EPISODE_RECORDED_TIME_ENABLED` | Default on; resolve episode ownership by recorded timestamps for every device and late capture | backend | env | open | — | — | — | — | keep | keep | — | dazheng |
| `FAIR_USE_ENABLED` | Enforce fair-use metering; set false to stop enforcement | backend | env | closed | — | true (backend-listen (chart)) | true (backend-listen (chart)) | — | keep | keep | — | unowned |
| `FAIR_USE_KILL_SWITCH` | Emergency stop for fair-use enforcement | backend | env | inverted | — | false (backend-listen (chart)) | false (backend-listen (chart)) | — | keep | keep | — | unowned |
+| `FAIR_USE_THROTTLE_DECAY_ENABLED` | Decay expired throttle and quiet warnings on read; set off to restore restrict-only decay | backend | env | open | — | — | — | — | keep | keep | — | backend |
| `FSR_KG_CITATION_INDEX` | Default on; query native reverse citations for KG node pruning; off restores the node scan | backend | env | open | — | — | — | — | keep | keep | — | dazheng |
| `FSR_MAINTENANCE_COORDINATION_ENABLED` | Default on in prod independently of read-lever rollback; explicit false restores per-replica maintenance | backend | env | open | — | — | — | — | keep | keep | — | dazheng |
</file context>
| violation_count_30d: int = 0 | ||
| last_violation_at: Optional[datetime] = None | ||
| throttle_until: Optional[datetime] = None | ||
| warning_until: Optional[datetime] = None |
There was a problem hiding this comment.
P3: Upgrade cleanup leaves the new warning deadline and stage-entry timestamp behind, so cleared users retain inconsistent state and dwell telemetry attributes prior enforcement time to none. Clear both fields when clear_fair_use_on_upgrade resets the stage.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At backend/models/fair_use.py, line 70:
<comment>Upgrade cleanup leaves the new warning deadline and stage-entry timestamp behind, so cleared users retain inconsistent state and dwell telemetry attributes prior enforcement time to `none`. Clear both fields when `clear_fair_use_on_upgrade` resets the stage.</comment>
<file context>
@@ -67,6 +67,8 @@ class FairUseState(BaseModel):
violation_count_30d: int = 0
last_violation_at: Optional[datetime] = None
throttle_until: Optional[datetime] = None
+ warning_until: Optional[datetime] = None
+ stage_entered_at: Optional[datetime] = None
restrict_until: Optional[datetime] = None
</file context>
Preserve qualifying violations in both warning renewal and decay commit orders. Failure-Class: FC-state-deadline-without-reader-exit
Keep the listen DG-budget regression guard and assert the complete throttle entry write, including its exact seven-day deadline. Failure-Class: FC-state-deadline-without-reader-exit
…24571) The development pusher image smoke fails with `missing installed dependency modules: soundfile`, blocking a qualified pusher digest for fleet-off. Add the backend's existing `soundfile==0.12.1` pin to the pusher manifest and regenerate only its Linux lock, preserving every existing package version. The reachable path is `pusher.main → routers.pusher → utils.pusher_finalization → utils.conversations.finalizer → utils.conversations.transcription_shadow → utils.stt.pre_recorded → utils.stt.modulate_batch → soundfile`. #24540 added the lazy FLAC import (also used in `recovery_recognizers`). `runtime_image_contracts.py` walks lazy imports and asserts dependency presence before image publication. Good run [41736493035](https://github.com/BasedHardware/omi/actions/runs/41736493035) installs 155 packages and checks 312 module paths; bad run [41752337247](https://github.com/BasedHardware/omi/actions/runs/41752337247) installs the same 155 packages and checks 313 paths. This is deterministic, rather than a transient package-index failure. The earlier #24531 / `dbf17bf82` run [41741443997](https://github.com/BasedHardware/omi/actions/runs/41741443997) passed build, dependency smoke and publication. It failed later in the development semantic probe (`listen_closed_early`, code 1006); that separate qualification remains with the rollout lead. Validation: - Reproduced the exact generated dependency assertion for `soundfile` in an empty isolated Python 3.11 environment, installed the declared pin, and observed PASS. - Real FLAC encode, duration read and lossless decode passed, exercising native libsndfile. - `backend/test.sh` with `BACKEND_UNIT_TEST_FILE_LIST` selecting `test_runtime_image_contracts.py` and `PYTEST_ADDOPTS='-k "pusher or dependency_probe"'`: 11 passed. Run serially through `omi-heavy` and `nice -n 19` in the canonical worktree venv. - Canonical `make setup` and worktree environment doctor passed. - Full `make preflight` with the draft PR body: all 15 selected checks passed. - Local Docker daemon unavailable; the requested exact-assertion reproduction/pass is the local proof. This lock change triggers Role Images CI: its Linux `backend/Dockerfile.roles --target pusher` build uses the same pusher lock and source surface and runs the offline probe on a public Python base. The shipped standalone Dockerfile/private-base development qualification remains with the lead. No deployment or workflow edits were run by this lane. Coverage follow-up: source-only backend import changes such as #24540 do not match the Role Images PR path filter. The older `runtime_image_contracts.yml` authenticated image-smoke job was retired November 1, so its source-only PR check does not fill that gap. The rollout lead owns disposition of source-change dependency coverage. Failure-Class: FC-runtime-image-boundary
## What changed and why Exercise lifecycle transitions through the shared Firestore simulator: expired admission schedules must reach a durable transcript and summary, and stored facts must derive the intended capturing/sealed/settled shadows. A late worker result after early finalization must increment a pending durable enrichment outbox with a token and finite due time. The negative control rejects an unchanged outbox. Generated fair-use escalation/read schedules reach the base after #24531. Producer-custody controls follow the owner-confirmed no-TTL contract: old live tokens survive recovery, another session cannot clear them, exact finish can, and proven-dead repair requires retained-tail evidence. The table keeps separate live/orphan rows and documented exemptions, with monitoring obligations preserved and negative controls preventing other automatic states from borrowing exemptions. Add a scoped extra-test-module argument and explicitly pass it from the existing listen/pusher CI tail. The default target list remains the original WP-A module. Released WP-A owner uicleanup authorized this seam and the assertion-only correction of its obsolete job-generation xfail; it now accepts the actual outbox rearm. Fixture implementations are unchanged. The conservative inventory also registers seven new upstream evaluation-response payloads. ## Product invariants affected none ## How it was verified The canonical seven-file backend unit gate passed **998 tests with 68 clause-specific strict xfails**. The final combined Firestore simulator passed **10 tests with 3 strict xfails**. With xfail disabled, exactly the same three final `LifecycleInvariantError` cases failed, all ten controls passed, and there were no setup errors or skips. Timing/slot limits stayed unchanged. The three runtime gaps still wait on no-job-after-seal recovery, failed-upload re-entry, and completing a conversation while audio custody is open. Reasons retain their repair owners. Producer age is not a failing clause: live/orphan custody exemptions are explicit and monitoring gaps remain strict. All local checks use the workspace heavy wrapper, `nice -n 19`, serial execution and isolated emulator authority. Credential/project variables are unset. Pure unit file-list input: `data/run-2026-11-04-lifecycle-invariants/evidence/backend-b2-unit-files.txt` in omi-workspace. ```bash bash backend/testing/lifecycle_sim/run.sh --keep --extra-test-module testing/lifecycle_properties/test_properties.py ``` Run through `bin/omi-heavy run -- nice -n 19` from the workspace, with the simulator's private HOME/config/cache. The final combined scenario-runner wall time was **116.667s** and B2 case/setup time was **11.196s**. An initial same-source comparison measured 69.072s without B2 versus 74.999s with B2 (+5.927s), before the final custody refinement. Host load and upstream source changed afterward; a final paired baseline refresh is tracked before merge. The added-time budget is approximately 60s (owner ruling 1994ce). ## Tests Real admission/result/projection/outbox transactions; derived phase shadows; generated quiet-read ladders; exact-token and proven-dead custody; unchanged-outbox negative case; no-argument and explicit CLI collection; scoped target refusal; selector coverage; four-clause table and exemption guards. ## UI evidence UI-Evidence: none -- test infrastructure only ## Failure class (fixes) Failure-Class: none ## New guards The existing PR-gated lifecycle tail collects the new property module. Strict legacy failures accept only their final LifecycleInvariantError. Source/table monitoring gaps remain clause-specific strict xfails. An early completion bit alone is permitted; the checked temporal obligation is durable titling rearm when late results commit. ## Tracking Owner: lcinv. ANX card:lcinv-lifecycle-invariants, capture initiative; remote updates remain assigned to uicleanup's pending queue while ANX is unavailable. Dated evidence: `data/run-2026-11-04-lifecycle-invariants/README.md` in omi-workspace. B2 go 006899; shared seam 4ac9fd/1994ce; WP-A assertion 3fe98b; producer custody 7a6181/4bf62d. No product/workflow/flag/cloud changes. Deploy needed: none. Normal Luna review and exact-head green/CLEAN are required before canonical merge. <!-- This is an auto-generated description by cubic. --> <a href="https://cubic.dev/pr/BasedHardware/omi/pull/24629?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/24629?returnTo=https%3A%2F%2Fgithub.com%2FBasedHardware%2Fomi%2Fpull%2F24629&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. -->
Requested by David
Fair use could escalate none → warning → throttle → restrict, but throttle had no reader for its written expiry and warning had no exit. F1 in the November 3 latch audit counted 658 users in throttle. This is the first latch-invariant PR in David's explicit-state program: https://claude.ai/artifact/7srvSdinev4M8oiSKotRiU. The count comes from the supplied audit; this work performs no production reads or writes.
The shared read normalizer now persists expired throttle → warning, then warning → none after seven quiet days. It stamps
warning_untilat entry and renews it for a qualifying violation that does not yet escalate. Upward thresholds are unchanged. Administrative warning/throttle entries stamp the same deadlines while the switch is enabled. Restrict expiry still returns throttle on the same read, with a fresh seven-day throttle deadline; sync/listen restrict enforcement remains unchanged. Conditional Firestore transactions protect the new decays against a concurrent escalation or deadline renewal.Existing throttle rows with expired, missing, or malformed
throttle_untilrecover to warning on their first uncached state read. That read writeswarning_until = now + 7 days; a second uncached read after the quiet period clears to none. Thus recovery takes two read-path calls with at least seven quiet days between them, without a migration: the first exits throttle, the second clears warning. Each decaying call performs the initial Firestore document read plus one transactional reread, so those two calls use four document reads without contention; transaction retries and intervening status calls add reads. The existing Redis stage cache can delay a stage-only reader by up to 60 seconds. Active throttle deadlines are honored. Legacy warnings use the last violation plus seven days, or receive one bounded seven-day period on first read when their age is unknown.FAIR_USE_THROTTLE_DECAY_ENABLEDis on by default. Setfalse,off, or0to restore the previous restrict-only behavior and writes. Only the rollout lead deploys; this PR is for review, with no merge or deployment authorization.Telemetry:
omi_fair_use_stage_dwell_seconds{stage}emits last-read dwell from persisted entry time (legacy fallback: last violation, then updated time). It has four bounded labels and is not a population percentile or full-store scan.omi_fair_use_stage_decay_total{from_stage,to_stage}counts persisted downward transitions using three fixed label pairs. Malformed throttle recovery also emits the existing fallback telemetry. No fleet alert is installed by this PR.Validation:
/Users/dazheng/workspace/omi/bin/omi-heavy,BACKEND_PYTEST_WORKERS=2, file isolation, viabackend/test.sh.GET /v1/fair-use/statusreturns HTTP 200 and the persisted warning/none stage and matching message, using fake stores and no credentials.make preflightpassed all 41 selected checks; PR-body metadata validation passed all 4 checks; the complete pre-push hook also runs before branch publication.Product invariants:
scripts/pr-preflight --suggestreports no required INV IDs for this diff; the push hook also validates these requirements.Failure-Class: new
Adds
FC-state-deadline-without-reader-exitwith the fake-clock ladder contract as its prevention artifact.