Skip to content

WIP: host signal family — REPL SIGINT discard classification, prompt $? and ^C echo (#610 #611 #600) - #615

Merged
caomengxuan666 merged 5 commits into
masterfrom
fix/niu-host-signal-610-611-600
Oct 27, 2026
Merged

caomengxuan666 merged 5 commits into
masterfrom
fix/niu-host-signal-610-611-600

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Host signal family (REPL SIGINT surface), one commit per issue:

Acceptance: Linux tmux PTY matrix (single/burst × ext/loop/pipe/prompt/half + ^C forensics) against the GNU bash 5.3.20 oracle — see the cluster REPORT. Regression pins land in tests/interactive.rs (ConPTY lane, NIU_INTERACTIVE_TESTS=1) in the same commit as each fix.

Fixes #610
Fixes #611
Fixes #600

…not a session exit (niubash#610)

A Ctrl-C that interrupts a pipeline in the REPL killed the whole
session: the pipeline members die of SIGINT, the engine's boundary
dispatch (rubash executor/trap_exec.rs, rubash#1662) converts the
shell's own queued SIGINT into Err(ExitCode(130)) marked
signal_discard_pending, and the host's ExitCode arms treated every
unwind as a top-level exit jump — note_session_exit_jump consulted
only take_parse_error. The REPL therefore ran end_repl_session(130):
the EXIT trap fired and the process exited 130. GNU (verified against
the 5.3.20 oracle, PTY matrix) returns to the prompt with $?=130, no
EXIT trap, no diagnostic. The engine's own grouped driver
(script_driver.rs) makes exactly this split; the host now mirrors it:

- new note_exit_code_unwind: a discard-marked ExitCode arms no jump
  (parse flag still consumed so nothing stale leaks forward);
- execute_script_inner's ExitCode arm applies the same check before
  setting script_exit_jump / the session jump;
- ExecuteError::SigintUnwind (the rubash#1639 discard shape a single
  external produces) gets an explicit arm in both line-route matches
  and in execute_script_inner: $?=130, no "niubash: interrupt:
  discarding current command line" diagnostic, no jump — previously
  it fell into the catch-all, printing the diagnostic and returning 1.

Regression pin (tests/interactive.rs, ConPTY lane):
issue610_ctrl_c_pipeline_returns_to_prompt_with_130 — ping|findstr
pipeline, Ctrl-C, prompt returns, st:130, EXIT-trap marker absent,
discard diagnostic absent, session still alive.
At the prompt, reedline runs the tty in raw mode: the ^C byte never
becomes a kernel SIGINT, no engine signal path runs, and the REPL's
Signal::CtrlC arm just cleared the line — $? kept whatever the last
command left (0 after any success). GNU leaves 130 (128+SIGINT) for
a discarded prompt line (verified against the 5.3.20 oracle, PTY
matrix prompt/half cells). The arm now sets the executor's last exit
code to 130 before continuing; the next iteration's PROMPT_COMMAND
pass reads that value and preserves it across the hook, as it does
for any command status.

Regression pin (tests/interactive.rs, ConPTY lane):
issue611_ctrl_c_at_prompt_sets_status_130 — st:0 after `true`,
Ctrl-C at the prompt, then st:130.
GNU shows a literal ^C at the point a prompt line is abandoned — the
kernel's ECHOCTL echoes it while the tty is cooked, and readline
echoes it in raw mode. Reedline (0.52) reports Signal::CtrlC without
printing anything, and its raw mode means no kernel echo either, so
niu showed nothing at all. The host now prints ^C at the head of the
Signal::CtrlC arm, ahead of the existing newline: the on-screen shape
is `<partial line>^C` then a fresh prompt, matching GNU for empty,
mid-typed and continuation lines alike.

The during-execution face of #600 needed no change: while a
foreground job runs the tty is cooked, ECHOCTL is active, and the
current master's PTY forensics show the ^C (the run2-era instability
did not reproduce — see the cluster REPORT).

Regression pin (tests/interactive.rs, ConPTY lane):
issue600_ctrl_c_at_prompt_echoes_caret_c — Ctrl-C at an empty prompt,
literal ^C in the transcript, session still alive.
…resh root Cargo.lock for stacker

rubash #1836 added the stacker dependency; the refreshed lock adds the
stacker subtree (stacker/psm/object/ar_archive_writer, additive only) so
--locked builds pass against the new pin.
@caomengxuan666

Copy link
Copy Markdown
Member Author

集成接棒证据(#610 / #611 / #600,基线 niu master 4e3e6b0)

本 PR 已普通 merge 当前 niu master 4e3e6b0c(#613 bind 桥 + #583 history 线),零文本冲突;语义双边保全逐文件核证:三文件(repl.rs / shell.rs / tests/interactive.rs)的分支自身 ± 内容行与合并树相对 master 的净差 ± 内容行逐行全等,合并树相对 master 净差恰为本 PR 三文件。合并树内三面共存已 grep 坐实:信号分类(note_exit_code_unwind + take_signal_discard_pending)、bind 桥分类(warn_unusable_engine_bindings)、history 共享 ledger(history_ledger() / with_shared_ledger),且 Signal::CtrlC 臂内 print!("^C") 与 set_last_exit_code(130) 同臂在位、三钉在 tests/interactive.rs 在位。

pin 与锁(配套动作)

  • chore(pin):scripts/release/rubash-pin.json 的 rubash_rev 升至当前 rubash master 495cf86eb46411dff8e4a0f40010be4a5bf86856(#1829 + #1836 合并后;rubash Cargo.toml version 仍 1.4.3,与 pin 的 rubash_version 一致)。
  • 红归因与消解(锁面):rubash #1836 给引擎新增 stacker = "0.1" 依赖后,rubash CI 的「niubash builds against this tree」红在 niu 侧根 Cargo.lock 未含 stacker 条目、--locked 拒绝改锁。本 PR 同批刷新 niu 根 Cargo.lock:diff 为纯增量 42 行(新增 stacker 0.1.25 + psm 0.1.32 + object 0.39.1 + ar_archive_writer 0.5.3,即 stacker 依赖子树,无无关版本漂移);本地构建槽内复验 cargo check --workspace --locked 在新 pin 下 rc=0(日志与 .done 产物在集成簇目录)。锁面拒绝已消解。
  • 另一条红(引擎面,非本 PR 可解,见 CI 节):新 pin 所含的 rubash 源码在 src/executor/job_builtins.rs 有一处 unused_parens(#1825 wait 修复带入),在 niu CI 的 -D warnings 口径下为硬错误——本 PR 的 CI 因此全红于编译步。修复归 rubash 线(删该处冗余括号);niu CI 是 clone rubash master HEAD 作 [patch] 兄弟目录,故 rubash master 修复落地后重跑本 PR 的 CI 即可转绿、无需再动本 PR;pin 指向的 495cf86e 与当前 rubash master 0e9f8d45(3559 行)均含此缺陷。

合并树验收(重跑)

  • 本地门(构建槽、JOBS=1、净化 env、python 句柄日志 + .done 产物):cargo build --locked rc=0(二进制产出);cargo test --test interactive --locked --no-run rc=0(三钉所在 ConPTY 车道在合并树编译无误);cargo test -p niubash-runtime --lib --locked shell::tests = 109 过 / 2 败,失败集 {run_startup_rc_syncs_process_path_from_executor, split_shell_path_list_preserves_windows_drive_colons} 与 pristine master(4e3e6b0c)同车道基线探针(同为 109/2)逐名全等——两条均为 Windows 语义测试在 Linux 本地的平台性既有失败,非合并引入。
  • PTY 矩阵(tmux harness,原簇 matrix.sh,oracle = GNU bash 5.3.20):合并树 niu 全格与 GNU 同形——ext/loop/pipe/prompt/half × single/burst 全部 survived=YES、INTRC=130、half typed=DISCARDED,F1/F2 的 ^C 回显 = YES(results-integ615.txt 与原簇 fix2 结果同形)。
  • [bug] REPL 管道命令被 Ctrl+C 中断时整会话以退出码 1 自愿退出(引擎同格全过) #610 专项 probe(管道预置 EXIT trap 后 ^C):子进程两次存活检查均 ALIVE,转录中 QQQFIRED 仅作为键入的 trap 设置命令回显出现、无 trap 执行输出——EXIT trap 未误触。
  • lib 面口径:脚本化 cargo test --workspace 不执行 niubash-runtime 的 lib 二进制,lib 面以 GitHub CI 为据(见下)+ 本地定向 cargo test -p niubash-runtime --lib shell::tests。

CI

  • run 40482135449(head 55ee0bf):除 api-ledger-sync 绿外全红,且全部红在同一上游编译错误:cross-check 的 cargo check (unix acceptance line) 与 build-and-test 的 cargo clippy (niubash-runtime, -D warnings) 均报 error: unnecessary parentheses around match scrutinee expression --> rubash/src/executor/job_builtins.rs:3559(-D unused-parens implied by -D warnings;could not compile rubash (lib))。测试步未曾执行,故本轮无 lib 失败集可对账——不是裁定环境 8 条集内/集外的问题,是测试前编译即死。
  • 解锁条件:rubash master 删除 job_builtins.rs 该处冗余括号后,重跑本 PR CI;届时再按裁定 runner 环境 8 条口径对账 lib 失败集。

说明:本评论为集成证据,PR 正文与关单词未动;未自合,待主会话合并。

@caomengxuan666
caomengxuan666 marked this pull request as ready for review October 27, 2026 10:47
@caomengxuan666
caomengxuan666 merged commit d7dcce5 into master Oct 27, 2026
17 of 28 checks passed
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
Integration refresh riding the niubash#618 merge-up onto niubash master d7dcce5 (after #615). Rolls up rubash#1848 (unused-parens lint fix), rubash#1850 (#1807/#1832 exec seams), rubash#1855 (stacker target gating - unbreaks the aarch64-unknown-linux-ohos cross-target check) and rubash#1857 (#1852/#1854).

Root Cargo.lock refreshed against the new pin and verified byte-identical (no dependency-set change in this range: #1855 only re-gates stacker by target expression); cargo check --workspace --locked rc=0 in the build slot.
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
Integration of PR #617 onto niubash master d7dcce5 (after #615 landed):
the pin moves from this branch's 0e9f8d45 to current rubash master
252ff19e (through rubash #1850/#1851/#1855/#1857, including the #1855
stacker target-gate that unbreaks the aarch64-unknown-linux-ohos
cross-target check). Root Cargo.lock refresh was performed against the
new pin's tree and verified a no-op (both merged branches had already
refreshed the lock to identical content; the stacker cfg-gate does not
change the lock's dependency representation) -- cargo check --workspace
--locked passes in the build slot.
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
* chore(pin): bump rubash pin to 0e9f8d45 and refresh root lock

Rubash master 0e9f8d45 rolls up the issue-clearance wave-1 merges
through rubash#1827 and rubash#1836; the latter's new stacker
dependency (plus psm) enters the root Cargo.lock with this bump.

* fix(history): keep the in-session list cleared after history -c (#614)

-c emptied the reader, but the file deliberately keeps the cleared
lines until the session-end write (#569) and reedline's sync/refresh
merges the whole file back into the reader — so the first list query
after any later append resurrected the entire pre-clear list. GNU
lists only the post-clear lines.

Apply the filed clear-generation/filter direction in the session
ledger shared by the provider and editor instances: -c records the
raw list length at clear time as a hidden prefix and bumps the view
generation; list queries (search/count/load) apply the latest
generation and answer from the suffix past the prefix, with ids
re-based onto the view. An explicit re-read (-r/-n) or an
authoritative replace ends the hide (GNU -r loads the file back on
purpose; the bash-it -c && -r cycle depends on it), while the -a
accounting rebuild keeps it. The file face and the #569 ledger/sync
semantics are untouched: all internal flush/save paths still read
the raw reader directly.

Pins: three lib tests (resurrection grid over the twin instances,
dual-session interleave, -r restoration) and a pty suite asserting
the builtin's list through history > file redirects.

* chore(pin): bump rubash pin to 252ff19e and refresh root lock

Integration refresh riding the niubash#618 merge-up onto niubash master d7dcce5 (after #615). Rolls up rubash#1848 (unused-parens lint fix), rubash#1850 (#1807/#1832 exec seams), rubash#1855 (stacker target gating - unbreaks the aarch64-unknown-linux-ohos cross-target check) and rubash#1857 (#1852/#1854).

Root Cargo.lock refreshed against the new pin and verified byte-identical (no dependency-set change in this range: #1855 only re-gates stacker by target expression); cargo check --workspace --locked rc=0 in the build slot.

---------

Co-authored-by: 曹梦轩 <[email protected]>
caomengxuan666 added a commit that referenced this pull request Oct 27, 2026
…#617)

* chore(pin): bump rubash pin to 0e9f8d45 (master through rubash#1827)

Baseline refresh for the #603 branch. Rolls up the rubash clearance
wave merged since 8fffc99e, including the stacker dependency
rubash#1836 added for the #1801 stack-growth fix; the root Cargo.lock
gains stacker/psm (and their object/ar_archive_writer deps) with this
bump.

* fix(startup): load the generated plugin loader for posix interactive shells (#603)

run_startup_files' posix branch sourced $ENV and returned without
ever loading the generated plugin loader, so posix interactive shells
silently lost every plugin and theme in both login states — the #590
defect class on the one branch #590 could not reach.

Per the product-semantics ruling on #603, the loader is niu's own
activation plane, not a user file: posix mode governs the choice and
order of user files (profile chain, then $ENV), not whether the
product integration loads. The posix branch now loads the loader
before $ENV, mirroring the ordinary branch's relative order — a
login shell has just sourced the profile chain, so the loader lands
after it (the #590 slot) and before $ENV; a non-login shell loads it
at its rc face's seat, before $ENV, so $ENV lines win just as rc
lines do. An exit inside the loader unwinds before $ENV and the
login tail, like any startup file. No rc is sourced in posix mode,
so the double-execution guard gets None, as on the login branch; the
NIU_PLUGIN_LOADER=off switch and the validate gate still apply.

Regression pins (tests/issue603_posix_loader.rs): the four-cell
login/non-login x posix/ordinary matrix asserting loader effect and
order via an ORDER sequence (PLE / LE / PL / LR), plus a login-posix
loader-exit unwind pin.

* docs(startup): declare the generated loader's posix behavior (#603)

advanced-usage.md's startup section and getting-started.md's plugin
section now state that POSIX interactive shells load the generated
loader — after the profile chain and before $ENV for login shells,
before $ENV otherwise — with $ENV in the rc's seat.

* style(fmt): rustfmt the issue603 pin file

* chore(pin): bump rubash pin to 252ff19e for the #617 integration

Integration of PR #617 onto niubash master d7dcce5 (after #615 landed):
the pin moves from this branch's 0e9f8d45 to current rubash master
252ff19e (through rubash #1850/#1851/#1855/#1857, including the #1855
stacker target-gate that unbreaks the aarch64-unknown-linux-ohos
cross-target check). Root Cargo.lock refresh was performed against the
new pin's tree and verified a no-op (both merged branches had already
refreshed the lock to identical content; the stacker cfg-gate does not
change the lock's dependency representation) -- cargo check --workspace
--locked passes in the build slot.

---------

Co-authored-by: 曹梦轩 <[email protected]>
@caomengxuan666
caomengxuan666 deleted the fix/niu-host-signal-610-611-600 branch October 30, 2026 01:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant