Record order-pane validation crash in Taken

Capture the units-limit crash at position 8 / limit 1, the related
slot-refresh mutation, and the proposed console/status-bar feedback
with restoration of the accepted setting.

Record validation gaps, isolated probe results, regression coverage
and the alternative over-limit policy. Link the verified guard at
line 325 and preserve every existing task state.

(this patch was generated in some part by `codex` using
GPT-6 family models (`openai`); exact model ID unavailable)
wkt/federated_project_stores
Gud Boi 2026-10-23 12:21:09 -04:00
parent 6f4cb01e95
commit 4275fe7338
1 changed files with 103 additions and 0 deletions

View File

@ -209,6 +209,109 @@
:CARRIED: 29 :CARRIED: 29
:END: :END:
- [ ] PUT PRs here - [ ] PUT PRs here
*** TODO Reject invalid order-pane settings without crashing the chart
:PROPERTIES:
:ID: piker-order-pane-allocation-validation
:CREATED: [2026-10-23]
:CARRIED: 0
:REPO: /home/goodboy/repos/piker
:AI_HARNESS: codex
:AI_DIALOG_ID: 01a1691b-455c-7b32-9f90-72331a112e46
:END:
Objective: keep the chart and order controls running after an invalid
allocation edit; report the reason in the chart console and status bar,
and restore the previous accepted setting. Suggested priority: high,
since a routine edit terminates chart monitoring with a position open.
Next action: implement recoverable validation at the settings boundary,
with atomic application of valid settings and consistent field feedback.
Original report, 2026-10-23:
#+begin_quote
ok well i just noticed that in the order control pane if you set the
slots to <= limit when limit is set to "units" value we crash the chart
purposely. that's not ideal, instead we should emit an error log to both
the chart's console and the status bar in the chart and revert the
setting i'm thinking. eval the current code and make any alt suggestions
you might have.
#+end_quote
User-supplied chart traceback and debugger values confirm a direct
units-limit edit, rather than establishing the reported slots <= limit
rule. At Oct 23 11:58:10, chart PID 2765259, Ctrl-A then 1 then Enter:
#+begin_example
limit must > then current pp: 8.0
_forms.py:524 handle_field_input -> on_value_change(key, value)
_position.py:235 on_ui_settings_change -> self.apply_setting(key, value)
_position.py:329 apply_setting -> raise ValueError
(Pdb+) size, value
(8.0, 1.0)
#+end_example
The exception escapes the input nursery, cancels order relay, trade/PnL
updates and other chart handlers, and opens the actor post-mortem REPL.
The repeated cancellation/ExceptionGroup output follows this ValueError.
Full supplied traceback remains in the originating conversation above.
Market and previously accepted setting were not supplied.
Inspected reported checkout: =wkt/ib_downstream_pin_eval= at
=e929fdc2d5c105453fd45c68e60045b68d428301=, clean tracked worktree.
The same units guard exists in the root checkout at
=3ec447a45acaa0dac9d8babbe49af94b2bfa14f0=.
Relevant code in the reported checkout:
- [[file:/home/goodboy/repos/piker/wkts/ib_downstream_pin_eval/piker/ui/_position.py::325][Units-limit guard]] compares signed =cumsize > value=, logs, then
raises before writing the limit. Equality is allowed; short exposure
is not protected by this signed comparison.
- [[file:/home/goodboy/repos/piker/wkts/ib_downstream_pin_eval/piker/ui/_position.py::223][Settings callback]] ignores the returned success flag. Currency
rejection changes the limit to current exposure instead of retaining
the accepted value; recovery behavior needs to be made consistent.
- [[file:/home/goodboy/repos/piker/wkts/ib_downstream_pin_eval/piker/ui/_position.py::906][Position refresh]] assigns derivatives' units limit from slots.
A slot edit can therefore change the limit implicitly. With live size
8 and startup size 0, slots 8 -> 1 leaves limit 1; the next status
refresh raises. A startup size of 8 instead clamps both back to 8.
This is a separate, conditional path from the supplied traceback.
- =slots= accepts positive fractions then truncates to int; 0.5 becomes
zero and later divides by zero. Empty input, NaN and infinity also
escape the current numeric parsing/conversion checks.
Recommended behavior and implementation boundaries:
- Validate the whole proposed allocation before mutation. Slots must
be finite positive integers; limits must be finite and positive.
Apply the position floor consistently using absolute exposure.
- Return an explicit rejection reason, log it once per submitted edit,
and use the existing =OrderMode.multistatus.open_status()= interface.
Restore the accepted field value and retain focus for correction.
Replace/clear the validation message without clearing order statuses.
A field highlight or tooltip can supplement the status-bar message.
- Make display refreshes read allocation state without silently changing
limits or re-entering edit validation. Move asset defaults and coupled
slot/limit normalization into initialization or explicit validation.
Merely changing the one raise to return False is an incomplete fix.
- Validate per-slot quantity against the market's size increment; do not
introduce a blanket slots <= limit rejection. Treat genuine position
updates beyond a ceiling as an over-limit state, not invalid input.
- Alternative policy for a later decision: permit a ceiling below current
exposure, show over-limit, block exposure-increasing entries and retain
reductions/exits. The allocator already clamps remaining entry capacity
at zero, but the UI and order paths need verification for this policy.
Verification so far: isolated execution of unchanged source methods with
inert display dependencies reproduced the supplied 8 -> 1 ValueError,
accepted equality at 8, and distinguished both slot/startup cases above.
Additional root-checkout probes reproduced fractional/empty/nonfinite
slot failures. These were not end-to-end GUI or broker/order tests.
- [ ] cover invalid edits without chart/input-task cancellation
- [ ] verify console + status-bar feedback and restoration of model/UI
- [ ] cover long/short positions, equality, empty/nonfinite values,
fractional/zero slots, currency mode and market quantity increments
- [ ] cover Enter, numeric slot shortcuts, unit changes and subsequent
position/status refreshes; preserve reductions/exits while over limit
Expected handback: focused code diff, validation results, remaining policy
choices, and any manual GUI reproduction needed for human acceptance.
Leave this task and its checklist states under human ownership.
** brokers ** brokers
:PROPERTIES: :PROPERTIES:
:CATEGORY: piker.brokers :CATEGORY: piker.brokers