fix: wait out a degraded inventory answer instead of freezing the tick #2
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "agent/fix-bff-degraded-position"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Dry-run onboarding: clone to a tick on both pools, with the first friction fixed
Walkthrough (timed log attached as
docs/onboarding-walkthrough.txt):EXECUTION_MODE=dry_runthroughout. The signer was an address with no balance and no history;nothing was signed or broadcast — every tick ended in a decision, never in a transaction.
The friction: the tick froze on a degraded inventory answer
The next two STX ticks froze the same way, and the same request answered
200seconds later.What it is. The v2 inventory read answers
503 NODE_POSITION_SELECTION_MOVEDwhile the enginere-selects the node that holds the wallet's position. Measured against the live BFF on 2026-12-03
(40 reads of the same wallet and pool, 3 s apart): 4 degraded in runs of 2, 1 and 1, 36 answered
200; during the three failed ticks, 12 reads in a row were degraded. The body says what itmeans:
The position data is degraded, not absent — the answer is "not right now".
Why it hurt. The kit read the 503 as a failed snapshot, so the whole tick froze, the wallet's
position stayed unknown for that tick, and the error counted toward the api-error breaker — five
in a row halts the bot. A transient hiccup on the BFF could therefore stop a running bot.
The fix
readCurrentBinswaits the degraded answer out instead of failing the tick:NODE_POSITION_SELECTION_MOVED) is retried after a2 s pause, for up to
BFF_INVENTORY_RETRY_MS(default 30 s — longer than the worst degradedwindow measured above);
toward the breaker;
liquidity it already owns, which is exactly what the clean/complete/tip-lag rules in
README.mdexist to prevent.New config knob:
How to check
test/bff.test.ts("reads the position again instead of freezing the tick"):answers 503
NODE_POSITION_SELECTION_MOVEDtwice, then the real payload, and asserts the readsucceeds. It fails on
mainand passes with this change;npm test(19 files, 254 tests),npm run typecheck,npm run buildall pass.After the fix
Both pools tick clean, and the walkthrough log holds both runs.
The other friction points
Five in total, written up in
docs/onboarding-friction-points.md:View command line instructions
Checkout
From your project repository, check out a new branch and test the changes.Merge
Merge the changes and update on Forgejo.Warning: The "Autodetect manual merge" setting is not enabled for this repository, you will have to mark this pull request as manually merged afterwards.