feat(boxen): C M3 #811 -- input_decoder SGR mouse + X10 fallback + burst-read#818
Merged
Conversation
…rst-read - SGR mouse parsing (\e[<...M/m): press/release/motion, wheel up/down - X10 legacy fallback (\e[Mbxy): 3-byte payload, mod bits on button byte - Mouse modifier bits: Shift=4, Meta=8, Ctrl=16 - Double-click synthesis ported from backend_tb2.c:54-83 - Burst-read: poll drains all available bytes into ring before returning - All M3 SKIP'd tests in tests/input_decoder_tests.c now pass (10 stubs converted to behavioral tests, plus 5 additional coverage tests added) - input_decoder_set_mouse() now writes \e[?1000h/1006h/2004h to tty_fd (tty_fd=-1 test-seam path skips the write, as expected) No regressions on M2 cursor-key tests. Full unit suite: 940/940 passing (+5 tests: 119 vs prior 114 in input_decoder_tests). Integration suite: 18 failures vs 21-failure baseline (no new failures). Refs #811
bar-raiser P1 input-validation hardening: - decode_sgr_mouse: reject empty params, excess params (>3), and zero coordinates (col<1 / row<1) rather than silently coercing to plausible events. Previously "\e[<;5;3M" decoded as left-click at (4,2) and "\e[<0;10;5;99M" silently dropped the 4th param; both are confused- deputy hazards. - X10 payload validation: reject btn<32 / x<33 / y<33 (the protocol +32/ +33 offsets must hold). Garbage trailer after a stray "\e[M" no longer emits a negative-coord event or pollutes last_press for future double- click matching. Bumps parse_errors for test observability. bar-raiser P1 test-determinism: - Add input_decoder_set_clock_for_testing() test seam so double-click tests can lock dec_now_ms() to deterministic values rather than depending on real CLOCK_MONOTONIC scheduling. Convert the existing test_double_click_synthesis to use it, and add three companion tests: test_double_click_outside_window (negative path past 500ms), test_double_click_outside_radius (same time, far position). bar-raiser P2 cleanups: - Extract SGR_COORD_CAP (9999) and SGR_MOUSE_MOD_MASK (0x1C) as named constants used by both SGR and X10 paths; removes magic-number drift. concurrency-reviewer P1 documentation: - input_decoder.h: document set_mouse threading precondition (caller must not invoke while another thread is blocked in poll on the same decoder; M6 will enforce with an explicit poll_active flag). - input_decoder.c: document last_press as NOT-thread-safe with the single-owner invariant required for M3-M5; flag for review when M4-M7 add concurrent paths. - dec_now_ms: document CLOCK_MONOTONIC sleep/wake behavior (safe on macOS 10.12+; unsigned subtraction makes earlier macOS wrap-around fail safe by missing the double-click rather than spuriously firing). New tests (registered in main()): - test_double_click_outside_window - test_double_click_outside_radius - test_sgr_mouse_malformed_empty_param - test_sgr_mouse_malformed_excess_params - test_sgr_mouse_malformed_zero_coord - test_x10_mouse_malformed_payload_under_min input_decoder_tests: 119/119 -> 125/125 (+6 gate-fix tests). Full unit suite: 940/940 -> 946/946. Integration suite: 21 failures (matches baseline; no new failures). No regressions on M2 cursor-key tests. No behavior change to the rendering path; decoder still not wired into backend_tb2.c (M6 cutover). Refs #811
Owner
Author
/gate Review: PR #818 (phase-c-m3-mouse-decoder)Verdict: PASS WITH NOTES (initial) -> PASS (after fix commit cdf8643)Tests
Reviewers run
P0 — BlockingNone across any reviewer. P1 — Important (addressed in cdf8643)
P2 — Nice to have (addressed where cheap; remainder deferred to M6 as follow-ups)
New tests added (gate-fix commit)
Stats
Final verdict: PASSAll P1 input-validation findings hardened. The decoder now rejects malformed SGR and X10 sequences with explicit parse_errors bumps that tests can observe. Double-click synthesis is deterministically testable. Threading and clock-source concerns documented for M6 enforcement. Required test layers re-confirmed at HEAD
|
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.
Summary
Milestone M3 of the Phase C input decoder: mouse protocol parsing and burst-read robustness contract. M1 (PTY-replay harness + stub) and M2 (CSI cursor keys + modifiers) are already on develop; this PR layers SGR mouse, X10 fallback, double-click synthesis, and the burst-read contract on top.
\e[<button;col;row M/m): press/release/motion, wheel up/down, all three buttons\e[Mbxy): 3-byte payload after\e[M, mod bits on button bytebackend_tb2.c:54-83(BOXEN_DOUBLE_CLICK_MS=500, radius=1)input_decoder_pollcall drains all available bytes into the ring buffer before returning the first event, leaving the rest for subsequent callstty_fdwhen set (test seam:tty_fd=-1skips the write)Per the M3 spec in
planning/phase_c/INPUT_DECODER_PLAN.mdsection 7, this PR does NOT wire the decoder intobackend_tb2.c-- that's M6 (cutover).tb_set_input_mode(TB_INPUT_MOUSE)is not called anywhere, and the rendering path is untouched.Test plan
input_decoder_tests: 119/119 passing (was 114/114 with 10 M3 SKIP stubs; all 10 un-SKIP'd + 5 supplementary tests added)Diff stat
Constraints honored
databases/Virgin.root,ws_server.c,ws_server.htb_set_cell,tb_present,tb_clear,tb_width,tb_height)tb_set_input_mode(TB_INPUT_MOUSE)backend_tb2.c(deferred to M6)Closes #811