Skip to content

Commit 863b21f

Browse files
committed
fix: unblock the pre-push gates (clippy, ruff, failure_policy config)
- degenbot_rs: drop a redundant struct-field name and two useless i128 conversions that failed the clippy -D warnings gate - _render.py: reflow an f-string line past the 100-col ruff limit - config.py: register the ADR-040 [failure_policy] override table on DegenbotConfig. The Rust core reads this table directly from config.toml (empty = default matrix), but pydantic-settings' extra=forbid rejected any config file carrying it, so every Python path through load_config_from_file (incl. the RPC cascade) failed against a config the Rust side accepts. Bucket/action-name validation stays boot-time in the Rust core; Python only carries the table.
1 parent c2a5f96 commit 863b21f

5 files changed

Lines changed: 13 additions & 5 deletions

File tree

rust/crates/degenbot-python/src/bot/engine/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ pub(crate) fn make_tick_info(
201201
use alloy::primitives::U128;
202202
degenbot_bot::bot_core::TickInfo {
203203
liquidity_gross: U128::from(liquidity_gross),
204-
liquidity_net: liquidity_net,
204+
liquidity_net,
205205
block: 0,
206206
}
207207
}

rust/crates/degenbot-python/src/bot/engine/solve.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ impl PyArbitrageEngine {
302302
let dict = pyo3::types::PyDict::new(py);
303303
for (&tick_idx, info) in &tick_data {
304304
let lg = info.liquidity_gross.to::<u128>();
305-
let ln: i128 = info.liquidity_net.try_into().unwrap_or(0i128);
305+
let ln: i128 = info.liquidity_net;
306306
dict.set_item(tick_idx, (lg, ln))?;
307307
}
308308
Ok(Some(dict))

rust/crates/degenbot-python/src/bot/pool.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ impl PyLiquidityPool {
23842384
Ok(s.tick_data()
23852385
.iter()
23862386
.map(|(tick, info)| {
2387-
let net: i128 = i128::try_from(info.liquidity_net).unwrap_or(0);
2387+
let net: i128 = info.liquidity_net;
23882388
let gross: u128 = info.liquidity_gross.to::<u128>();
23892389
(*tick, (gross, net, info.block))
23902390
})

src/degenbot/config.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,13 @@ class DegenbotConfig(BaseSettings):
9696
# OpenTelemetry settings (epic RMH23E T5). Optional so existing config
9797
# files without an [otel] section keep loading unchanged.
9898
otel: OtelSettings = OtelSettings()
99+
# Per-bucket failure-reaction overrides (ADR-040 D3; docs/failure-policy.md).
100+
# Flat form: bucket or quoted "kind.reason" -> action string; nested form:
101+
# kind = { reason = "action" }. Bucket/action *name* validation is the Rust
102+
# core's boot-time job (unknown bucket/action exits 2); this model only
103+
# carries the table so a config file the Rust side accepts also loads in
104+
# Python (the RPC cascade reads this file via load_config_from_file).
105+
failure_policy: dict[str, str | dict[str, str]] = {}
99106

100107
@field_validator("rpc", mode="after")
101108
def validate_paths(

src/degenbot/runner/_render.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -381,8 +381,9 @@ def _render_sim_failures(outcome: DispatchOutcome, *, current_block: int) -> Non
381381
else:
382382
bot_logger.error(
383383
f"[sim-trap] {len(trap_failures)} sim failure(s) at block={current_block} "
384-
f"(failure_policy sim_failure action={action}) — continuing; failures surface via OTel "
385-
f"(degenbot.errors{{kind=sim_failure}}). See [sim-fixture] above.",
384+
f"(failure_policy sim_failure action={action}) — continuing; "
385+
f"failures surface via OTel (degenbot.errors{{kind=sim_failure}}). "
386+
f"See [sim-fixture] above.",
386387
)
387388

388389
overflow = len(failures) - cap

0 commit comments

Comments
 (0)