Repository navigation
test+lint: marker protocol enforcement gates — golden expansion, blind-consumer lint, registry census (Refs #2885) - #3015
Merged
Conversation
…#2885) E6 of the #2885 enforcement gates (follow-up to the #2879 sweep): - tests/marker_leak_golden.rs grows from the original channels to one cell per output channel of the sweep's section 2.1 matrix: set listing, PS4 template (battery c21 shape), prompts via the public Session::expand_prompt API (incl. the Q1 TAB-value leg), declare -f, diagnostics (bad substitution / command-not-found / redirect error), external env+argv against real child binaries, env import, compgen, jobs text. Expectations collected byte-for-byte from GNU bash 5.3.20 with script-file probes. - tests/marker_leak_golden_pty.rs (+ .py driver) covers the interactive-only channels through the sweep's job-control-parent PTY harness: PS1/PS2/PS4 rendering, typed-PUA prompt, history file. Output-quiescence waiting instead of fixed sleeps (load-robust). The read -p leg is enrolled as #[ignore] pending #2883. - src/executor/markers.rs gains a registry-driven test: every MARKERS codepoint typed as user data must round-trip through printf %s / echo / assignment-concat (GNU-collected: 52/54 identical). New markers get cells automatically. Known-broken cells are pinned in an exception table asserted to still differ: QUOTED_NULL_MARKER (#2882) and PROMPT_ESCAPE_GUARD shape 3 (candidate finding in the lane REPORT). Verification: cargo test --locked --lib 1199/0/4 (one new lib test); --test marker_leak_golden 18/0; --test marker_leak_golden_pty 1/0 (+1 ignored).
E7 of the #2885 enforcement gates: - scripts/check-marker-literals.py: the blind-consumer lint. L1/L2 forbid raw registry-zone / C0 carrier literals (\u{...} spelling) in code position outside markers.rs; L3 forbids textual needle surgery (.replace/.contains/trim_*_matches/cow_replace, needle = replace's first / cow_replace's second argument) on registry consts at unreviewed sites. Reviewed sites live in scripts/marker-lint-allowlist.txt (261 entries, each adjudicated with its invariant; stale entries fail). Wired into CI next to the UTF-8 boundary hygiene step. Fail-first proven: three planted violations (one per rule) all fire on a scratch copy; the clean tree is green. - Conversions (behavior-identical): ~91 production-code literals to named registry consts — assignment_expansion's '\u{E302}' family, lexer/quotes.rs CTLESC/DATA_* match arms, command_subst_helpers, embedded_mutations, subscript_expansion, expand/braces (via the existing *_STR consts), plus the STORAGE_WORD_PREFIX / PARAM_NAME_END_MARKER / IFS_GLUE / PREEXPANDED_STDIN_BODY scatter. - The two sweep-F2 cow_replace(QUOTED_NULL_MARKER_STR) strips are allowlisted as KNOWN BLIND SPOTs tracked by #2882 (delete the entries when it lands); the '\u{1}' shadow-word placeholders are allowlisted as the domain-local bytes they are, not converted into a false PROMPT_IGNORE_START semantics.
…(Refs #2885) E8 of the #2885 enforcement gates, all inside src/executor/markers.rs: - ENV NAMESPACE CENSUS block above the MARKERS table: every __RUBASH_* env-serialization key in the tree (130 EXACT + 11 FAMILY prefixes, from a full src/ census of 186 tokens), each with its purpose; env_namespace_census_is_complete keeps it exhaustive and stale-free against the source tree. - Boundary claims for the 10 adjudicable unclaimed rows: the PATSUB set claims Output (they are visible-decoder inputs: locale.rs drops START/END, maps AMP/BACKSLASH); the four backslash/IFS guards and the DIR_STACK/HASH_ENV field separators claim Storage, with the guards added to OWN_BOUNDARY_DECODERS naming their owning walkers + the locale.rs guard arm. - The remaining 5 rows are now explicitly internal-only: every_row_claims_boundaries_or_is_listed_internal pins them in INTERNAL_ONLY_ROWS with reasons and fails on any unlisted empty row (or a listed row that gains a claim). Module header documents the rule. No public API surface changes; docs/api-ledger.md untouched.
CI head 4eeb49d went red on three legs with the same panic: `src/executor/markers.rs:1786` `.expect("built rubash binary for the registry cells")`. `cargo test --lib` (ci.yml:171/192) does not build the bin target, so `CARGO_BIN_EXE_rubash` is unset and no `target/debug/rubash` exists for the `current_exe` fallback either. Not a product failure and not a designed fail-first: a harness defect in the E6 test. Fix, per the captain's ruling: the test now lives in `tests/marker_registry_roundtrips.rs` and drives the binary via `env!("CARGO_BIN_EXE_rubash")`, like every other binary-driving test. It stays registry-driven without any new public surface: the registry file is compiled into the test crate via `#[path]` (precedent: `tests/build_rs_dirty.rs` includes `../build.rs`), so `MARKERS` stays `pub(crate)` and docs/api-ledger.md is untouched. Supporting change 1, crate-internal only: `contains_word_marker_bytes` goes from `pub(in crate::executor)` to `pub(crate)` so the registry file compiles as a standalone module; the `crate::executor` path does not exist in the test crate. (The test crate silences the resulting dead-code noise for the included file crate-wide with `#![allow(dead_code)]` at its top; the library's own lints are unaffected.) Supporting change 2: the registry file's own `#[cfg(test)]` module must stay self-contained for the `#[path]` include to compile, so the two decoder-coupled tests move to `src/executor/markers_decoder_tests.rs` (new `#[cfg(test)]` module): `user_reachable_rows_have_an_entry_reencode_story` and `boundary_claims_name_a_decoder` call the real decoders through crate paths. Same assertions, same lib-suite membership — only their home changed. Also fixes a verification fallout in the E8 census test: the census block's prose line `// FAMILY lines are literal prefixes ...` parsed as a bogus FAMILY prefix `lines` (the parser takes the word after `FAMILY`). Reworded the prose and hardened the parser to reject any parsed entry that does not start with `__RUBASH_` with a clear message instead of a confusing coverage failure. Also relabels the E316 exception from `rubash#2885-report-candidate` to `rubash#3016` (filed by the captain, API-verified). Note: the `tests/marker_leak_golden.rs` header doc-reference update for the move rides in the next commit (golden-4 adjudication), which touches that file anyway; this commit carries the other move files.
…2885) The E6 golden cells were committed with four wrong expectations; the "18/0" figure recorded at E6 time is void (measured against a stale binary — see REPORT). On the pristine E6 tree (4eeb49d, e6check worktree) the cells fail 14/4 on this machine, identically to the current tree, so E7/E8/the registry move are exonerated; CI never ran these cells (ci.yml invokes only --lib and --test regression), so there was never a green CI signal for them either. Per-cell verdicts (all probed byte-for-byte against GNU bash 5.3.20): - jobs: test wrong. The background printf job legitimately prints the raw U+E314 it was asked for; the `jobs` listings themselves are clean (source spelling, GNU-identical). Its stdout now goes to /dev/null so the scan sees only the listings. - diagnostics/bad-substitution: test wrong. GNU also aborts the -c script on ${v@Z} (rc 127, no "after"); rubash matches byte-for-byte. The leg now asserts the GNU-identical abort. - compgen: harness wrong. The count of 2 was RUBASH_GIT_STAMP + RUBASH_GIT_DIRTY_SUFFIX imported from the test process env (build.rs cargo:rustc-env); rubash correctly lists imported env vars, as GNU does. The cell now spawns with a sanitized env (new run_clean_env). - diagnostics/command-not-found + redirect: real product gaps, rubash#3040 — the E400 pair reaches the diagnostic and the created filename instead of the raw char. Both legs pinned inverted. - prompts: real product gap, rubash#3038 — expand_prompt does not decode the E400 pair for U+E314 (E401/TAB decodes). Leg pinned inverted. Inverted pins follow the registry-test precedent (E002/#2882, E316/#3016): they assert the current broken form and flip red when a fix lands. Evidence and oracle probes in REPORT.md and ~/workspace/fix-2885/probes/g4_*. Also carries the move's doc-reference update for this file (the header now points at tests/marker_registry_roundtrips.rs).
`tests/cat_redirect_stream_regressions.rs::shell_bin()` trusted `CARGO_BIN_EXE_bash` unconditionally, but the `bash` bin is a Windows-only shim (required-features windows-shim; Cargo.toml: "Unix builds never produce it") — cargo still sets the env var at compile time on Linux, so both tests fail with spawn NotFound on the never-built `target/debug/bash`. Found while running the full `cargo test` for rubash #2885 (the failure is pre-existing and unrelated to this lane: the test file is untouched since #2468, and a fresh single-target run fails identically). Fix, test-only: take the bash path only when the file exists, else fall through to rubash (the existing branch 2). Behavior-preserving on Windows (the shim exists there, so it is still taken) and makes the full suite green on Linux. CI never runs the full integration suite (ci.yml invokes only --lib and --test regression), which is why this survived on master.
…2885) - markers.rs census: add EXACT entry for __RUBASH_CURRENT_FILE (new carrier from #3035/#3047, missing from the E8 census). - marker_registry_roundtrips: remove all four TYPED_DATA_EXCEPTIONS (E002 shapes 1-3 fixed by #2882/#3006; E316 shape 3 by #3016/#3041); the stem now asserts every shape round-trips. - marker-lint-allowlist: delete the two #2882 KNOWN BLIND SPOT entries (their own text said delete when #2882 lands), plus two entries made stale by master-side changes: set.rs ESC rendering entry (#3044 restructured the table) and command_prepare contains:QUOTED_NULL_MARKER (#3006 converted those consumers to E400-aware helpers). - marker_leak_golden_pty: un-ignore the read -p cell (#3001 landed the read -p decode). - marker_leak_golden: set-listing C0 scalar cell now expects the ansic-quoted GNU form (rubash#3017/#3044), byte-verified against GNU bash 5.3.20; the no-marker assertion is unchanged. Verified on the merged tree (merge bd87ed1 + this commit): lint OK (117 consts / 258 sites), registry 10/0, PTY 2/0, golden 20/0, lib 1200/0/4, -D warnings rc=0, hygiene/fmt/CR clean.
caomengxuan666
marked this pull request as ready for review
November 8, 2026 02:30
This was referenced Nov 8, 2026
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.
Refs #2885(PUA/载体协议执法门,#2879 普查后续;E9 已由队长在 #2885 评论中验收销账,本 PR 承接 E6/E7/E8)
本 PR 删除了什么
无删除。本 PR 为纯新增(执法门 + registry 文档)与等义改写(裸标记字面量 → 命名常量),不删除任何既有行为面。净行数:29 文件,+2156/−289(
git diff b4eaed55..HEAD --shortstat)。内容(逐 item 分提交,另见车道 REPORT
~/workspace/fix-2885/REPORT.md)4eeb49dd):golden 扩容到普查 §2.1 通道矩阵每通道一格——tests/marker_leak_golden.rs新增 set 列举 / PS4 模板 / 公开 API 提示符(含 Q1 TAB 腿)/ declare -f / 诊断 / external env+argv(真子进程)/ env import / compgen / jobs 共 9 格,期望值以 GNU bash 5.3.20 脚本文件探针逐格采集;PTY 兄弟测试(驱动改静默期等待,抗满载时序 flake)覆盖 PS1/PS2/PS4/历史文件,read -p腿以#[ignore]登记(base 不含 Interactive read -p prompt renders raw-byte marker pairs instead of the control bytes #2883 修复;rebase 到含 fix(read): decode raw-byte marker pairs in interactive read -p prompt (Refs #2883) #3001 的 master 后摘 ignore);markers.rs新增 registry-driven typed-data 测试:54 码点 × 3 形状与 GNU 对照(52 全同),新标记自动得格,已知坏格以例外表登记(E002→Escaped user U+E002 is eaten by blind QUOTED_NULL consumers (printf emits stray U+E400, echo emits nothing, concat drops the char) #2882;E316→fix: U+E316 (PROMPT_ESCAPE_GUARD) typed-data folds to backslash in assignment concatenation #3016)。9ff641c5):盲消费者 lint(scripts/check-marker-literals.py+scripts/marker-lint-allowlist.txt262 条 + CI 步)+ 生产代码约 91 处裸字面量转命名常量(机械值审计 clean)+ E7 fail-first 证据(scratch 副本埋三规则违规 → rc=1 全报)。33fc51aa):registry 补__RUBASH_*环境序列化命名空间普查(130 EXACT + 11 FAMILY,源自 src/ 全树 186 token)+ 未认领行边界声明(PATSUB→Output,guards/分隔符→Storage)+ 余 5 行显式 internal(新测试防腐烂)。无新增公开面,docs/api-ledger.md未动。9b7d123f,队长裁定):cargo test --lib不建 bin 目标致 registry 测试 panic——测试移到tests/marker_registry_roundtrips.rs(env!("CARGO_BIN_EXE_rubash"),#[path]编入 registry 文件,无新增公开面);两 decoder 耦合测试移到src/executor/markers_decoder_tests.rs;附带修 E8 census 解析 bug(散文行误读为 FAMILY 前缀lines);E316 例外标签改为 fix: U+E316 (PROMPT_ESCAPE_GUARD) typed-data folds to backslash in assignment concatenation #3016。2157b485):E6 时点 18/0 系 stale-binary 度量、作废;E6 净树在本机同条件复跑亦 14/4,CI 从未跑过这些格。逐格 oracle 裁决:jobs/诊断-bad-substitution/compgen 为测试或 harness 错(已按 GNU 修正);prompts(expand_prompt renders the E400 escape pair for a stored U+E314 value instead of the raw char #3038)与诊断 cmdnotfound+redirect(Stored U+E314 value used as a name renders the E400 pair: command-not-found diagnostic and redirect filename #3040)为真产品缺口,各腿 inverted pin(修复即翻红),两单均已立(标签 + assignee + 归宿 1.5.1)。1c4a1383,全量跑中发现的既存缺陷):shell_bin()无条件信任CARGO_BIN_EXE_bash,而bashbin 是 Windows-only shim、Linux 永不构建;仅当文件存在才取该路径,否则落到 rubash。Windows 行为不变。验证(构建槽 + scrubbed_cargo,日志
~/workspace/fix-2885/verify-*.log)cargo test --locked --lib:1198 passed / 0 failed / 4 ignored(三次确认;E6 时点 1197,+2 E8 新测试 −1 registry 迁出 = 1198)--test marker_registry_roundtrips:10 passed / 0 failed;--test marker_leak_golden:18 passed / 0 failed;--test marker_leak_golden_pty:1 passed / 0 failed / 1 ignored--test cat_redirect_stream_regressions:2 passed / 0 failed(修前 fresh 单跑同败 0/2)--test cli_tests(trap 腿--skip):470 passed / 0 failed / 4 ignored;--version显示干净build: 1c4a1383 (debug)RUSTFLAGS="-D warnings"cargo check rc=0(多轮);cargo fmt --checkrc=0;marker-lintOK (117 registry consts, 262 allowlisted sites)rc=0subshell_trap_listing_keeps_parent_table_entries——已知的 scrubbed_cargo 信号掩码 artifact(左含SIGXFSZ忽略行),plain cargo 单跑 1/0;产品无罪。字面 1238-target 一次性全跑未做(cargo 遇首败即停 + 数小时槽占用);覆盖面见 REPORT。合并时动作(队长)
pty_read_p_prompt_decodes_expansion_results的#[ignore]。Refs #2885;合入后不自动关任何单——Marker protocol enforcement gates: per-channel leak-golden coverage, blind-consumer lint, registry completeness (sweep #2879 follow-up) #2885 的 E6/E7/E8 由队长验后手动关。