fix: wait out a degraded inventory answer instead of freezing the tick #2

Open
davidagentmm wants to merge 2 commits from agent/fix-bff-degraded-position into main

2 commits

Author SHA1 Message Date
71a152f626 docs: attach the timed clone-to-tick walkthrough log
Some checks are pending
CI / checks (pull_request) Waiting to run
Clone, install, npm test and one dry-run tick per pool, with the wall clock
on every step. The log also shows the three STX ticks that froze on the
degraded inventory answer, and the two ticks after the fix.
2026-12-03 03:17:37 +07:00
bfa0f0e56a fix: wait out a degraded inventory answer instead of freezing the tick
Some checks are pending
CI / checks (pull_request) Waiting to run
The v2 inventory read answers 503 NODE_POSITION_SELECTION_MOVED while the
engine re-selects the node that holds the wallet's position. Measured on
2026-12-03: 4 of 40 reads over 2.5 minutes were degraded, in runs of seconds,
and 12 in a row across three consecutive dry-run ticks.

The kit read that 503 as a failed snapshot, so the tick froze, the wallet's
position stayed unknown and the error counted toward the api-error breaker
(5 in a row halts the bot). readCurrentBins now retries a transient code for
up to BFF_INVENTORY_RETRY_MS (default 30s, longer than the worst measured
degraded window) and only then fails the tick.

Reading an empty book instead would be the wrong answer: the bot would
redeploy over liquidity it already owns, which is what the clean/complete/
tip-lag rules exist to prevent.

The new test in test/bff.test.ts fails on main and passes here. The friction
points seen during the walkthrough are listed in
docs/onboarding-friction-points.md.
2026-12-03 03:15:10 +07:00