Skip to content

tests/regression: re-baseline stale suite snapshots + airtight snapshot env + CI golden-refresh artifact - #496

Merged
caomengxuan666 merged 2 commits into
masterfrom
fix/upstream-snapshot-golden
Oct 10, 2026
Merged

caomengxuan666 merged 2 commits into
masterfrom
fix/upstream-snapshot-golden

Conversation

@caomengxuan666

@caomengxuan666 caomengxuan666 commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

结论

常红 job("GNU regression goldens and canaries",每个 PR 必红,upstream_suite_slice_snapshots 26 passed / 1 failed)的根因是 #480 对 ${var@P} 的过度剥离——一个被快照系统正确抓住的 GNU 奇偶回归。本 PR 修复引擎语义 + 加固快照基础设施,13 个 golden 切片零字节改动。

根因链(CI 日志 + oracle 实证)

  1. CI 端首个红点 = 10ff8a3 (fix(prompt): strip \[ \] ignore-markers on every PS1 render path #480):master 最后一个绿 run 是 4744083,第一个红 run 就是 fix(prompt): strip \[ \] ignore-markers on every PS1 render path #480,相邻提交。失败切片固定为 exp。
  2. 漂移内容只有一行(exp.snap:359):argv[1] = <x^Ay^?z> → argv[1] = <xy^?z>。对应上游 exp8.sub:26 的 recho ${var@P}(var=$'x\001y\177z')。
  3. 判定为引擎回归而非 golden 过期:GNU 5.3.0 自己的期望输出 exp.right:253 记录 argv[1] = <x^Ay^?z>——字面 \x01 必须在 ${var@P} 结果中存活;WSL GNU 5.3.0 与 Git GNU 5.2.37 的 %q 双 oracle 一致($'x\001y\177z')。fix(prompt): strip \[ \] ignore-markers on every PS1 render path #480 把 ${var@P} 也接入了 strip_prompt_ignore_markers,把值里字面的 \x01/\x02 误当宽度标记剥掉了。
  4. fix(prompt): strip \[ \] ignore-markers on every PS1 render path #480 的剥离对渲染通道是正确的(readline display.c expand_prompt 组装显示时不含宽度标记),对脚本可见的变换结果是过度泛化。

修复

  1. 引擎(8541e71f):${var@P} 还原为 GNU 语义——decode_prompt_string 本身(\[/\] 的处理按 parse.y:6609-6622 已在解码器内完成:无行编辑时丢弃、emacs/vi 开时产出标记字节);字面 \x01/\x02 原样透传。渲染通道(expand_prompt_string{,_mut}、piped -i 驱动、niubash BashPrompt 桥)保持剥离不变。#431 回归 4/4 绿、parameter-transform 测试全绿。
  2. 快照基础设施(d8559c8e):
    • run_suite_snapshot 改用与 goldens 相同的密闭环境(env_clear + 机器基础设施白名单 + 显式 PATH/HOME)。原实现泄漏环境变量,快照字节因此机器相关——实锤:exp.tests:416 执行 ${THIS_SH} -c ...,导出 THIS_SH 的 shell 会录出干净 runner 永不产生的行;
    • CI 新增 "Record upstream-suite snapshots" 步骤(always)+ regression-snapshots artifact:golden 过期时 artifact 即替换内容的真值,不再手工转录 40 行截断 panic 窗口。本次调查正是用它把漂移精确锁定到一行;
    • tests/regression.rs 模块头写明重录协议:重录只能用 RUBASH_REGRESSION_RECORD=1,且录制提交信息必须按切片引用导致字节变化的行为修复 ISSUE/PR——"update golden" 不带行为出处 = 基线红灯自我复制(fix(prompt): strip \[ \] ignore-markers on every PS1 render path #480 事故正是如此)。

Golden 状态

零改动。CI 录制 artifact 与提交版逐字节比对:修掉 ${var@P} 过度剥离后,13 个切片全部与 tests/regression/snapshots/ 一致(修复前仅 exp 一行漂移,且该漂移是回归不是改进)。子模块 gitlink(b460816)全程未变,排除上游输入漂移。

验证

  • CI(38036897417,本 PR 最新 commit):GNU regression goldens and canaries 绿,Rust tests / Rust tests (macOS) / Cross-target / Shell functionality 全绿(bash-upstream-progress 按 if: github.event_name != 'pull_request' 设计在 PR 上跳过)。
  • 本地:全量 --test regression 26/27 绿——唯一失败是 comsub 切片在本机(Win10 19045)与 runner(Server 镜像)间的 OS 级输出差异,runner 与 GNU 侧一致、与提交版字节一致(artifact 证明),本机差异已由密闭环境最小化、以 runner 为准。cargo fmt 干净;--lib 在本机有 2 个既有的机器相关失败(pwd 驱动器格式/path 虚拟根),与本 PR 无关且 CI 上为绿。

…h artifact (drift protocol)

The 'GNU regression goldens and canaries' job has been red on every PR
since 10ff8a3 (#480): the ${var@P} marker-strip fix (#431) legitimately
changed the exp slice's stdout, and tests/regression/snapshots/exp.snap
was never re-recorded — every later PR inherited that red (26 passed /
1 failed, upstream_suite_slice_snapshots).

Two structural fixes so a stale baseline cannot snowball again:

1. run_suite_snapshot now runs the suites in the same airtight
   environment as the goldens (env_clear + machine-infrastructure
   whitelist + PATH/HOME), instead of only removing OLDPWD/BASH_ENV/
   WINUXSH_ROOT. The old ambient-env pass-through made snapshot bytes
   machine-dependent: exp.tests:416 executes `${THIS_SH} -c ...`, so any
   shell that exports THIS_SH records argv lines a clean runner never
   emits, and shell-option variables (BASHOPTS/SHELLOPTS/POSIXLY_CORRECT
   classes) are exactly what the alias-expansion machinery keys on.
   A snapshot byte that depends on ambient env cannot be a baseline.

2. The regression job records the snapshots on the runner and uploads
   them as the regression-snapshots artifact (always()). When the
   comparison fails because committed .snap files are stale, that
   artifact is the runner-true replacement content — no more
   hand-transcribing the truncated 40-line panic window.

Module header documents the re-record protocol: a snapshot diff IS a
semantic change; a recording commit must cite the behavior-fix issue/PR
per slice, or the red baseline ships itself forward.

Gate: cargo fmt clean; snapshot suites byte-identical on the recording
path; full regression suite green modulo the stale exp.snap this PR
re-records next.
…els strip the ignore markers (rubash#431 scope fix)

#480 funneled the ${var@P} prompt transform through
strip_prompt_ignore_markers alongside the render channels. For a PS1 the
strip is display semantics (readline display.c expand_prompt assembles
the prompt without the width-accounting bytes), but a script-visible
transform result must keep bytes that were IN the value: upstream
bash-tests exp8.sub:26 runs `recho ${var@P}` against
var=$'x\001y\177z' and GNU 5.3.0 records `argv[1] = <x^Ay^?z>` in
exp.right:253 — the literal \x01 survives. %q probes on WSL GNU 5.3.0
and Git 5.2.37 agree ($'x\001y\177z').

The strip ate the literal byte (`xy^?z`), a GNU-parity regression that
the exp suite-slice snapshot pinned as a CI failure — the red
'GNU regression goldens and canaries' job every PR inherited since
#480 was exactly this one byte.

${var@P} is decode_prompt_string and nothing else again:
- the \`\\[\\]\` markers are already handled per GNU parse.y:6609-6622
  inside decode_prompt_string (dropped when no line editor is active,
  marker bytes when emacs/vi is on) — the prompt_transform_strips_
  ignore_markers regression stays green on that branch, not on a strip;
- the render channels (expand_prompt_string{,_mut}, the piped -i
  driver) keep their strip: a terminal-bound prompt must not carry the
  width-accounting bytes. niubash's BashPrompt bridge is unaffected.

Gate: issue431 regressions 4/4, parameter-transform tests green, full
regression suite 26/27 locally (the snapshot leg is the OS-dependent
comsub slice this machine cannot reproduce; the CI artifact from the
previous commit proves the runner records the committed bytes for all
13 slices once this revert lands).
@caomengxuan666
caomengxuan666 merged commit 61dd62f into master Oct 10, 2026
6 checks passed
@caomengxuan666
caomengxuan666 deleted the fix/upstream-snapshot-golden branch October 10, 2026 08:16
caomengxuan666 added a commit that referenced this pull request Oct 13, 2026
…601)

40 commits (PRs #496-#600) folded into [1.4.0] by theme instead of
per-commit listing:
- GNU semantics waves 1-4b with their issue families
- argv re-expansion P0 pair (#511/#555), PWD POSIX persona (#537)
- -s on-demand stdin driver as the canonical library reader (#586)
- CLI entry-shape semantics (#589-#591) and the GNU usage contract (#585)
- diagnostic message fidelity (#551) and parser diagnostic tokens
- Windows path contract (#568/#592)
- lexer/executor performance rounds (#554/#562/#501)
- docs: boundary invariants, platform gap, baselines, debugger M0

Commit message deliberately carries no release/version claim.
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