Skip to content

[GAP-13] Bind/readline assembly faces + shopt-flag read (rubash#2833, rubash#2848) - #2850

Merged
caomengxuan666 merged 2 commits into
masterfrom
gap13-bind-readline-faces
Nov 5, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
gap13-bind-readline-faces

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Refs rubash#2833, rubash#2848, niubash#863.

GAP-13 entity engine part (ten-round re-audit): three contract faces
plus the GAP-12 follow-up read, all pure lifts, no new semantics.

  • Session::register_binding (Q-A(ii)) — engine converts
    BindKindView and constructs the BindEntry itself, into the same
    registry pool the bind builtin writes.
  • Session::initialize_readline (Q-B(i)) — pure lift; ordering
    (after rc, before first snapshot) is the caller's duty.
  • Session::is_known_keymap (Q-F(ii)) — plain KEYMAP_NAMES
    membership, no alias folding.
  • Session::applied_invocation_shopt_flag (rubash#2848) — last
    -O/+O entry wins over the retained invocation; the read
    enter_interactive needs for expand_aliases.
  • CandidateKind re-exported at rubash::api (one line; the §6
    entry already existed).
  • Session::parse recorded in §6 as a staged entry (unconsumed).

U-1 probe: initialize flag-before-path parity holds against GNU
5.3.20 (bashline.c:451-456/:646) — no divergence, no separate issue.

Ledger §6 279 -> 284; §2.3 four staged-0 rows; §2.1 bind_registry
Q-E write-path note.

Pre-migration true counts: register seam = 1 host production site
(bind_surface.rs:46) + 2 engine-internal (bind builtin's two
register_bind_entry arms); initialize seam = 1 host production site
(shell.rs:3145, load_engine_bindings) + 2 engine-internal (bind
builtin's lazy init + interactive-stdin driver entry init).

本 PR 删除了什么: nothing (pure addition; BindEntry/BindKind revert
to internal only when the GAP-13 host lane deletes bind_surface.rs).
Net: +574/-7 across 4 files.

UNVERIFIED-BY-CAPTAIN. Pins: 9/9 issue863_gap13_* green.

…rse staged

rubash#2833 (niubash#863 GAP-13, ten-round re-audit entity part):
Session::register_binding (Q-A(ii): engine converts BindKindView
and constructs BindEntry itself, into the same registry pool the
bind builtin writes), Session::initialize_readline (Q-B(i): pure
lift of Executor::initialize_readline, ordering is the caller's
duty), Session::is_known_keymap (Q-F(ii): plain KEYMAP_NAMES
membership, no alias folding). U-1 probe: initialize
flag-before-path parity holds against GNU 5.3.20
(bashline.c:451-456/:646) — no divergence, no separate issue.

rubash#2848 (GAP-12 follow-up): Session::applied_invocation_shopt_flag
— last -O/+O entry wins over the retained invocation
(shell.c:931-958); the three GNU oracle arms are pinned. The apply
face's doc now says the host's startup_invocation field deletes
only once the host adopts the retained-invocation reads.

Also: CandidateKind re-exported at rubash::api (one line; the §6
entry already existed, the re-export makes its path true).

Ledger §6 279 -> 284 (three faces + Session::parse staged +
applied_invocation_shopt_flag); §2.3 four staged-0 rows; §2.1
bind_registry Q-E write-path note. No product semantics change:
pure lifts into the existing registry/inputrc pools.

Deletes: nothing (pure addition; BindEntry/BindKind revert to
internal only when the GAP-13 host lane deletes bind_surface.rs).
Net: +574/-7 across 4 files.
@caomengxuan666
caomengxuan666 marked this pull request as ready for review November 5, 2026 18:03
@caomengxuan666
caomengxuan666 merged commit 4f0d493 into master Nov 5, 2026
10 of 11 checks passed
@caomengxuan666
caomengxuan666 deleted the gap13-bind-readline-faces branch November 5, 2026 18:12
caomengxuan666 added a commit to unixwin/niubash that referenced this pull request Nov 5, 2026
The engine (rubash#2850) now contracts the bind/readline assembly
verbs. The host adopts them and deletes its gated hand-wiring:

* `Session::register_binding` replaces the `bind_surface.rs`
  `register_bind_entry` call — the plugin `rl_macro_bind` route
  (`Shell::register_macro_binding`) now lets the engine construct
  the entry itself.
* `Session::initialize_readline` replaces the direct executor call
  in `Shell::load_engine_bindings` (ordering unchanged: rc, then
  inputrc, then snapshot).
* `Session::is_known_keymap` replaces the `KEYMAP_NAMES` read in
  the `[keymap]` rule parser; the parser now takes the Session,
  and the config migration builds one throwaway session for that
  check (building a session reads no startup files).
* `bind_surface.rs` is deleted entirely; host production references
  to the engine's `bind_registry` types are zero.
* `CandidateKind` is now consumed through the `rubash::api`
  re-export the entity lane added (the GAP-11 NOTE about the
  missing re-export is retired); the ledger checker `--niu` goes
  from rc=1 (one MISSING path) to rc=0.
* Ledger mirrored byte-identical from rubash master 4f0d493c
  (284 symbols).

本 PR 删除了什么:
- `crates/niubash-runtime/src/bind_surface.rs` 整模块(Tier C 门,
  含 `register_engine_macro` / `is_known_keymap` 两面及其
  `internals` 双臂实现)。
- 宿主自家对 `rubash::shell::bind_registry` 类型的全部生产引用
  (`register_bind_entry` 直呼 + `BindEntry`/`BindKind` 直构 +
  `KEYMAP_NAMES` 直读)。
- `completion/mod.rs` 里 GAP-11 留下的 NOTE(重导出未落地已成过去)。

净行数:+421/−123(10 文件)。`internals` feature 保留为空操作——
普查结论:租户归零;保留是为 `--no-default-features` 构建的证明
范围(三枚新钉在两构建下都绿)。

Pins: three new `issue863_gap13_*` lib pins (register read-back
through `bind_view`, initialize second-call no-op, keymap true/false
sets) + one chained PTY case (`repl_pty_bind_inputrc_rc_runtime_
removal_chain`: inputrc → runtime bind → inputrc rewrite idempotence
→ `bind -r` removal; mutation self-checked — disabling the host
initialize call reds the chain at link 1). The rc carries no `bind`
line on purpose: the engine self-initializes on its first `bind`
invocation, which would mask the host call site.

Refs: #863, unixwin/rubash#2833, unixwin/rubash#2850.

Co-authored-by: 曹梦轩 <[email protected]>
caomengxuan666 added a commit that referenced this pull request Nov 14, 2026
…2847) (#3556)

Fixes #2847

## 修了什么

`scripts/check-api-ledger.py` 的 §6 校验从「子树里有同名声明」改为「记录的路径就是真实导出路径」:

- `item rubash::a::b::Name`:从 `src/lib.rs` 起逐段解析,每一段必须是 `pub mod`(内联或文件,含 `#[path]`)或把模块 `pub use` 出来的再导出;末段 `Name` 必须在该模块**顶层**以 `pub` 声明(fn/struct/enum/trait/type/const/static/union/mod),或被该模块 `pub use` 再导出(具名、`as` 改名、glob;glob 目标可以是私有模块,如 `parser` 的 `pub use nodes::*`)。只认裸 `pub`,`pub(crate)` 不算对外面。
- `variant` / `method`:其所属类型路径按同一解析器校验(此前 method 完全不看类型路径)。
- 诊断区分两种失败:`declared in the tree but not exported under rubash::…`(路径错)与 `not found in tree`(符号没了)。
- 源码级近似:先抹掉注释与字符串/字符字面量,再按花括号深度判定「顶层」;不追宏生成的条目(真遇到会大声失败、需人工处理)。
- 自检(`--self-test`)新增一组:真实导出路径(具名/改名/私有模块 glob/`#[path]`/根再导出/子模块路径)必须过;未再导出、穿私有模块、类型路径错的 item/variant/method 必须各自失败。

## 删了什么

`item_exists` 原先的「模块子树 rglob + 声明模式」判定(即 issue 所说的盲区)。`PUB_DECL_PATTERNS` 只保留用于失败诊断(区分「路径错」与「不存在」)。

## 依据

工程面,无 GNU 锚。

## 验证

- issue 复现:取 #2850 之前的树(`4f0d493c~1`,`CandidateKind` 尚未在 `src/api/mod.rs` 再导出):
  - 旧脚本:`all 279 ledger symbols present`,rc=0(假绿)
  - 新脚本:5 条失败(`item rubash::api::CandidateKind` + 4 个 variant,均为 `declared in the tree but not exported under rubash::api::CandidateKind`),rc=1
- 当前 master:`all 287 ledger symbols present`,rc=0;`--niu D:/repo/niubash`:287 present、97 consumed paths recorded,rc=0。
- `--self-test` rc=0(四段自检全部通过)。
- 运行时间与旧脚本持平(约 13.5s,瓶颈仍是原有的 method 全树扫描)。
- 另带一个仅格式化提交:`tests/d11_pipeline_squote_carrier_regressions.rs`(#3511 在 master 留下的 fmt 漂移,pre-commit hook 必红;与 #3531/#3547 中的同一 hunk 相同,合并无冲突)。

## Owed

- `docs/api-ledger.md` §5 第 1 条仍写「proves presence by declaration patterns only」,现已不准确;但该文件要求与 niubash 副本逐字节相同(canary `cmp`),需 rubash/niubash 成对改,本 PR 未动。
- 未在 CI(`niu-canary.yml` 的 `ledger` / `pairing` job)上实跑,仅本地 Windows Python 3 运行。


## 队长复核(合入时)

- 判词 PASS:L1–L8 一手跑过全绿(287/287、--self-test、复现树双向对照旧假绿 279 / 新 5 缺失、--niu 97 consumed、两份账本 sha256 identical)。
- CI run 43560449915:3 fail 逐名 = issue2875 ×2(goldens、macOS)+ issue2859 Linux-only;issue2859 按 #3292 类确认为 VOID(同头 macOS/goldens 该 cell 绿、零 Rust 产品代码、不碰 jobs/sleep 面)。
- 交集 ∅(merge-base 8b48c16 = live tip),无需 update-branch。
- 合入体:接受正文 Fixes #2847,#2847 随合入自动关闭。
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant