fix(lucidly): status() idle_target_pct must be a 0..1 fraction (was 100x off)#117
Merged
abhicris merged 1 commit intoJun 7, 2026
Conversation
`LucidlyAutoPark.status()` returned `idle_target_pct` using `bps / 100`, so an 8000-bps target reported as `80.0` while the rest of the module treats this value as a 0..1 fraction: - `LucidlyConfig.idle_target_pct` (same name) = `idle_target_bps / 10_000` -> 0.8 - `rebalance()` math: `target_pct = self._target_bps(chain) / 10_000` - `ensure_liquid()`: `unpark_threshold_bps / 10_000` So the public `status()["idle_target_pct"]` disagreed with the identically named `LucidlyConfig.idle_target_pct` by 100x. A consumer reading status to size the idle target (balance * idle_target_pct) would massively overshoot. Fix: reuse the existing `_target_bps()` helper and the module's `/ 10_000` convention so status() returns the same fraction as the config property and the rebalance logic. +2 regression tests pinning the convention (default and per-chain fallback). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Contributor
|
🤖 Audit verdict: Legitimate bug fix (100x off-by-one in fraction conversion) with added test coverage, no malicious code, credentials, or supply-chain risks detected. Audited by the kcolbchain PR pipeline. See pipeline docs. |
Contributor
|
Merged — thanks, @kite-builds. That's 5 merged PRs to kcolbchain now. You're a Fellow — when paid research, partner-org work, or grant milestones come up, you're in the first invite pool. Next-up issues across the org: https://kcolbchain.com/invitations/ |
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
LucidlyAutoPark.status()reportsidle_target_pctusingbps / 100, so an 8000-bps target is returned as80.0. Everywhere else in the module the same quantity is a0..1fraction:LucidlyConfig.idle_target_pct(same name!)idle_target_bps / 10_0000.8rebalance()mathtarget_pct = self._target_bps(chain) / 10_0000.8ensure_liquid()unpark_threshold_bps / 10_000status()(this bug)... / 10080.0❌So the public
status()["idle_target_pct"]disagrees with the identically namedLucidlyConfig.idle_target_pctby 100x.Reproduction on current
main:A consumer that sizes the idle target from
status()(e.g.balance * idle_target_pct) would overshoot by 100x.Fix
Reuse the existing
_target_bps()helper and the module's/ 10_000convention sostatus()returns the same fraction as the config property and the rebalance logic. One-line change; no behavior change to the parking math itself.Tests
test_status_idle_target_pct_is_a_fraction_matching_config_convention— pinsstatus() == config.idle_target_pct == 0.8and0 ≤ pct ≤ 1.test_status_idle_target_pct_falls_back_to_default_bps_as_fraction— fallback path (chain absent fromper_chain_targets) also returns a fraction.pytest tests/test_lucidly.py→ 15 passed. Full suite → 218 passed, 62 skipped.ruff checkclean on changed files.🤖 Generated with Claude Code