Repository navigation
fix(repl): a bare-CR pair at chunk-open is typeahead, not paste data — the submit requeues its partner (closes #420) - #426
Merged
Conversation
…— the submit requeues its partner (niubash#420) The #341 CrPartner rule folded a bare CR queued behind a bare CR as the WT KEY_EVENT paste's empty line at CHUNK-OPEN. The same bytes are TWO TYPEAHEAD SUBMITS in one pty write — a driver's send("cmd\r\r"), an expect script's back-to-back Enters, the Ctrl+R accept-Enter followed by the submit-Enter (PR #418's E2E, which is where the wedge surfaced). The fold swallowed the first submit: the line echoed and parked in the PS2 continuation buffer forever — the shared-driver wedge of niubash#420. GNU typeahead semantics win: at chunk-open a CR partner is no longer paste evidence. The first CR SUBMITS; the probe-consumed partner CR goes back to the head of the input stream verbatim (WriteConsoleInputW — the niubash#417 requeue face; the in-process pushback is forbidden there by the #341 batch-crossing invariant) to submit the empty line, or to submit the loaded Ctrl+R match, on its own dispatch. A chunk now only opens on paste evidence: the LF partner, or an already-pending chunk (the mid- chunk fold keeps #341's live-paste empty-line semantics, and the WT owner-script guard stays green: the bare-CR feed executes per line, the documented degraded shape). Baseline five of niubash#420 (byte-stable on master, none of them the wedge): - continuation_single_quote: the expectation wanted expansion inside single quotes; GNU bash (5.3 msys oracle) prints the word literally and niu matches bash. Test re-pinned to the oracle semantics. - continuation_subshell_paren: the trailing ');)' is accepted by msys bash (subshell runs, exit 0) but rejected by rubash's parser — engine divergence filed for rubash; the test now pins the clean ')) close. - ctrl_c_interrupts_external_command / ctrl_d_after_background_job: bare 'ping' resolves via 'type -a' but the exec path reports command- not-found on hosts whose System32 ships PING.EXE uppercase (rubash case-sensitive lookup); the tests invoke the absolute path, keeping the Ctrl-C/Ctrl-D intent. - gitbash_factory_prompt: the branch segment spawns git through the session PATH, which the System32-only sandbox never had — the test now prepends the host git's dir. New regressions: typeahead_bare_cr_pair_submits_per_line_420 and ctrl_r_accept_submit_in_one_burst_420 (echo-proof, execution-level). Verification (this host, Win10 19045, --test-threads=1): runtime lib 552 passed / 0 failed; interactive 81 passed / 0 failed (one ctrl_d host-noise flake observed in one of three full runs, green alone and in the following full run — the documented dev-box noise family); repl_command 11, completion_probe 29, smoke_1_3_0 11, issue182 1, issue359 2, compat 48. No GPL code introduced.
This was referenced Oct 19, 2026
Member
Author
独立评审结论:APPROVE-WITH-NITS独立代码评审(worktree BLOCKER 清单无。逐项复核未发现任何一条粘贴合同变形或真回归遮掩。 逐验证点(全部实做)
非阻塞 NITS
不合并。意见来自独立评审 worktree,复核后可收口。 |
This was referenced Oct 19, 2026
fix(repl): the submit writes the probe-parked typeahead back to the console queue (niubash#417)
#433
Merged
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.
Verdict
Product face (niubash
PasteChunkEditMode), not the harness. The shared driver and the independent harness deliver byte-identical events (proven with a crossterm event probe: every key record arrives, the second CR ~1 ms behind the first); the loss is in the Enter-signature decision.Root cause (one paragraph)
cr_paste_partner'sCrPartnerrule (niubash#341) folded a bare CR queued behind a bare CR as the Windows-Terminal KEY_EVENT paste's empty line at chunk-open. The same bytes are two typeahead submits in one pty write — a driver'ssend("cmd\r\r"), an expect script's back-to-back Enters, and exactly the Ctrl+R accept-Enter + submit-Enter flow of PR #418's E2E (its shared-driver version sent\r\runpaced; the independent harness's 150 ms pacing is the one variable that made it green). The fold swallowed the first submit and consumed the second: the line echoed, then parked in the PS2 continuation buffer forever — the wedge. It is the #806/#417 typeahead family's state machine, but the specific decision (the fold at chunk-open) is not covered by #417's pushback-reinjection scope; coordination note left there.Fix
At chunk-open a CR partner is no longer paste evidence (GNU typeahead semantics): the first CR submits, and the probe-consumed partner CR is requeued verbatim to the head of the input stream —
WriteConsoleInputWin production (the #417 requeue face; the in-process pushback is forbidden there by the #341 batch-crossing invariant), push-front on the scripted test queue. A chunk now opens only on real paste evidence: the LF partner (humans never send Ctrl+J) or an already-pending chunk — the mid-chunk fold keeps #341's live-paste empty-line semantics, and the WT owner-script guard stays green (a bare-CR feed executes per line, the documented degraded shape — identical output).Baseline five of #420 (byte-stable on master; none of them the wedge)
continuation_single_quote'makes the word literal; GNU bash 5.3 (msys oracle, re-run 2026-10-13) prints\verbatim and niu matches bash. Re-pinned to the oracle semantics.continuation_subshell_paren(A;B);)(subshell runs, exit 0); rubash's parser rejects the lone)'. Filed for rubash — out of this repo. Test pins the clean closing)'.ctrl_c_interrupts_external_commandpingresolves viatype -abut the exec path reports command-not-found on hosts whose System32 shipsPING.EXEuppercase (case-sensitive lookup;where.exesees the file, the full path runs). Tests invoke the absolute path; rubash follow-up.ctrl_d_after_background_job_exitsgitbash_factory_promptgitthrough the session PATH; the System32-only sandbox never had git and thecdsubmit itself always ran. The test now prepends the host git's dir.New regressions (echo-proof, execution-level)
typeahead_bare_cr_pair_submits_per_line_420— the minimal wedge:send("echo \\r\r")must submit on the FIRST CR (pre-fix: parked, no output until the next Enter).ctrl_r_accept_submit_in_one_burst_420— the PR fix(repl): a DSR-silent terminal keeps its shell; TAB completion commits (closes #373) #418 flow: reverse search, query, then\r\rin one burst; the accept loads, the requeued Enter submits.Unit-level: the open-fold contract is re-pinned (
paste_chunk_detector_open_cr_pair_submits_and_requeues_420, pushback-invariant kept), the mid-chunk fold re-pinned (..._midchunk_cr_pair_still_folds_341), and the #341 protocol sweeps (wt_bare_cr_paste_survives_*) pass unchanged.Verification (this host, Win10 19045,
--test-threads=1, rebased on master @ 117147a incl. #418's reedline 0.52)cargo test -p niubash-runtime --lib: 552 passed / 0 failed--test interactive: 81 passed / 0 failed (5 ignored, pre-existing pins). Onectrl_dhost-noise flake in one of three full runs (green alone and in the following full run) — the documented dev-box noise family; CI's clean runner is the gate.repl_command11 ·completion_probe29 ·smoke_1_3_011 ·issue1821 ·issue3592 ·compat48 — all green.Coordination
unreadrequeue implemented here is the same reinjection primitive [P2][input] PasteChunkEditMode's Enter-signature probe consumes kernel typeahead at commit: the accepted command's 'read' sees an empty console queue (rubash#806 host half) #417's fix direction prescribes; [P2][input] PasteChunkEditMode's Enter-signature probe consumes kernel typeahead at commit: the accepted command's 'read' sees an empty console queue (rubash#806 host half) #417's own scope (pushback-parked typeahead starving an accepted command'sread) remains open there — no double fix.)parser divergence vs msys bash; case-sensitive bare-name exec lookup (PING.EXE).