Repository navigation
test(repl): echo-proof ctrl_d_midline; #368 read-unit/line-identity audit report - #419
Conversation
…t/line identity
- ctrl_d_midline_does_not_exit: the expected marker ('half-typed') appeared
verbatim in the submitted input, so the terminal echo could satisfy the
assertion without the completed line ever executing — the exact class
niubash#367 called out. The probe now extends the word in place after the
EOF key and expects 'half-typed-ok', which the input never contains, so
the assertion proves the line survived Ctrl-D AND executed.
- docs/audit/findings/i368-read-unit-line-identity.md: niubash#368 audit —
65 __RUBASH_CURRENT_LINE consumers classified (1 load-bearing: the alias
same-read guard, confirmed cross-read-unit collision filed upstream as
rubash#817); host fast-path vs grouped-reader parity verified clean;
child-env leak analysis clean; -i/-i -c expand_aliases + LINENO match
GNU; alias matrix echo-proof status recorded.
caomengxuan666
left a comment
There was a problem hiding this comment.
Independent CR (cr-419) — verdict: APPROVE-WITH-NITS
Reviewed at 98bd821 in an isolated worktree; mutation experiments were run and fully reverted (tree pristine afterward, ctrl_d_midline_does_not_exit re-verified green).
1. Echo-proof hardening works (mutation-verified)
Mutation: rebound mid-line Ctrl-D in the emacs keymap to EditCommand::Clear (reedline 0.50 add_binding(CONTROL, 'd', Edit([Clear]))) — models the masked failure class "half-typed input handled/echoed, completed line never executes".
- NEW test turns red on the mutant (
half-typed-oknever appears;-okruns alone → command not found). Reverted → green again. This is exactly the regressionctrl_d_midline_does_not_exitexists to catch, and the oldexpect("half-typed")+expect_prompt()pair could not catch it (a discarded line still produces an echo satisfiablehalf-typedand a fresh prompt on non-coalescing render paths). - Empirical note: on this Windows host the old assertion also failed on this particular mutant, but for a different reason — the paste-chunk state machine (crates/niubash-runtime/src/repl.rs
PasteChunkEditMode) buffers a key burst and only flushes it into the edit buffer on the next key event, so the mutant's flush+Clear coalesced into one repaint and the typed text never rendered at all. So the docstring's mechanism ("the terminal echo of the typed text satisfies expect") is host/timing-dependent rather than universal; on per-char render paths (Unix delegate, gap-separated keys) it applies as written. The hardening strictly dominates either way.
2. NIT — residual hole: the marker is still a literal of the completed buffer
half-typed-ok is a verbatim substring of the buffer once -ok lands (echo half-typed-ok). If a regression swallowed Enter after the suffix reached the buffer, the editor's repaint of the unsubmitted line prints echo half-typed-ok contiguously → expect("half-typed-ok") satisfied, and expect_prompt() is satisfied by the same repaint (the prompt is re-rendered on every redraw). False pass remains possible in that narrow shape. The alias-matrix discipline this PR's own report praises (markers must be runtime-derived output — rc variables / printf formats — never a literal that can sit in the buffer) would close it, e.g. complete with && echo ok-$((40+2)) and expect ok-42. Also fine to leave as-is given the realistic regressions (exit on Ctrl-D, discard on Ctrl-D, split-line) are all caught; but the docstring's "a string the input never contains" deserves a footnote that it means the input byte stream (the \x04 separates the halves), not the completed buffer.
3. Audit report — spot-checks pass (5/5)
All verified against the pinned engine base rubash 8ab35e89:
src/executor/arithmetic_aliases.rs:832-834gate +:867-878reader/comparison — exact; both lines unchanged on current rubash masterc6f4a9b.src/executor/alias_set_builtins.rs:65(record_alias_definition_lines(.., cmd.line)) +:88(marker insert) +:15,20-57(clear_alias_definition_lines) — exact.src/executor/trap_exec.rs:460-480eval renumberingcaller_line + i - 1— exact.src/builtins/source/execution.rs:291-293,351-358__RUBASH_CURRENT_LINEsave/restore — exact.- Host refs:
tests/interactive.rs:64/:82(closed/closed'weak secondaries, load-bearing markers precede them) — accurate;:351/:372-407ignore reasons — accurate;shell.rs:770-812execute_interactive_reader_batch(actual 777-809) and normalizers2435-2560,2682-2869— land.
Nit: the report cites tests/interactive.rs:380-575 as "the whole alias matrix" — the six alias fns actually span 416-577 on d60276e; 380-407 is history_bang_*. Substance correct, range off by a few lines on both ends.
4. Change surface & gates
- Diff vs
d60276e: exactly 2 files —tests/interactive.rs(+15/-3, one test + doc comment) and the new report. No product code, no stowaways. - Full interactive suite,
--test-threads=1: 64 passed / 4 failed / 7 ignored. Failure set = {continuation_single_quote_ps2_and_completes, continuation_subshell_paren_completes, ctrl_c_interrupts_external_command, gitbash_factory_prompt_renders_and_tracks_the_branch} — exactly the four pre-existing named in the PR description; the fifth disclosed flakectrl_d_after_background_job_exitsdid not fire in the suite run but reproduced intermittently in isolated re-runs afterward (ok → FAILED → ok on three consecutive solo runs), matching the "occasionally" disclosure.ctrl_d_*trio green on the branch.
5. rubash#817 cross-reference — accurate
unixwin/rubash#817 exists (OPEN), and its title/body match the report's defect section verbatim in substance (both repros, the load-bearing sites, the must-survive table, the read-unit-generation fix direction). PR body's "Closes part of #368 (host-side deliverables)" is consistent with the report's deliverables section.
Not merging. Nits are non-blocking; fix-or-followup at author's discretion.
Closes part of #368 (host-side deliverables). Engine defect found by the audit is filed upstream: unixwin/rubash#817.
What
tests/interactive.rs—ctrl_d_midline_does_not_exitecho-proofing. The expected marker (half-typed) appeared verbatim in the submitted input, so the terminal echo of the typed text could satisfyexpecteven when the completed line never executed — the exact trustworthiness class niubash#367 called out for the alias matrix. The probe now typesecho half-typed, survives the Ctrl-D, extends the word in place (-ok), and asserts onhalf-typed-ok— a string the input never contains — so the assertion proves the line both survived the EOF key and executed. Checklist item D of [P2] Audit read-unit / line-number identity across alias + line-based semantics (follow-up to #367) #368.docs/audit/findings/i368-read-unit-line-identity.md— the [P2] Audit read-unit / line-number identity across alias + line-based semantics (follow-up to #367) #368 audit report (checklists A/A2/B/C/D, file:line evidence, GNU differ tables, runtime probe inventory).Audit verdicts (details in the report)
__RUBASH_CURRENT_LINEreferences on rubash master8ab35e89, exactly one is load-bearing (the alias same-read guard,arithmetic_aliases.rs:832-834,867-878); all others are report-only (LINENO/caller/diagnostic prefixes/comsub line seeding). That one site carries a confirmed cross-read-unit collision (source/eval-defined alias suppressed withcommand not foundwhere GNU expands) → rubash#817 with two GNU-differed repros and a must-survive semantics table.$LINENO/caller/ trap stamping match GNU in the probed shapes;-i/-i -cexpand_aliasesdefault and cumulative interactive$LINENO(1, 2) match GNU.cd C:/x, bareC:,cd /c/x, pipeline) — both routes converge byte-identically (ConPTY probe,--test-threads=1).unalias/unalias -amarker cleanup already fixed upstream (alias_set_builtins.rs:15,20-57, pinned by rubash'sissue367_alias_line_hygiene_regressions.rs); child-env leak analysis clean (env_clear spawn path; wrapper/coproc line identity is designed GNU-fork equivalence; child parse errors use token-derived lines — verifiedline 1, not the parent's stale marker).d60276e); this PR fixes the one remaining echo-satisfiable active test.Test gates
ctrl_d_*trio: green on this branch (--test-threads=1).continuation_single_quote_ps2_and_completes,continuation_subshell_paren_completes,ctrl_c_interrupts_external_command,gitbash_factory_prompt_renders_and_tracks_the_branch, occasionallyctrl_d_after_background_job_exits) reproduce identically on pristined60276e(baseline run: same 4 + flake) — pre-existing ConPTY-timing flakes on this host, unrelated to this change.Not to be merged by the author; based on
origin/masterd60276e.