Skip to content

feat(cli): --version appends build hash/profile and a Windows persona note (rubash#488) - #490

Merged
caomengxuan666 merged 1 commit into
masterfrom
infra/version-build-metadata
Oct 10, 2026
Merged

caomengxuan666 merged 1 commit into
masterfrom
infra/version-build-metadata

Conversation

@caomengxuan666

Copy link
Copy Markdown
Member

Closes #488

What

rubash --version appends build metadata after the GNU license block, which stays byte-identical:

  1. build: <git-hash> (<profile>) — <git-hash> is git rev-parse --short HEAD captured by the new build.rs at compile time (unknown when git is unavailable, e.g. tarball builds; release packaging can pin it via the RUBASH_BUILD_HASH env var), <profile> is debug/release from cfg!(debug_assertions).
  2. On Windows only, a persona clarification line (owner-directed extension): the engine is a native Windows build with no MSYS runtime underneath, so the *-pc-msys MACHTYPE must not be read as an MSYS2/Cygwin bash port. The detailed docs section is landing in parallel on the niubash side; this PR only carries the pointer.

Before / After

Before (master — a dev build of the engine and the installed 1.3.3 release are indistinguishable, the #488 fake-baseline root cause):

GNU bash, version 5.3.0(1)-release (x86_64-pc-msys)
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

After (target/debug/rubash.exe --version built from this branch — hash shown is the base commit this dev build was made from; a build from a checkout of the merged commit carries that commit's hash, which is exactly what CI/release already do):

GNU bash, version 5.3.0(1)-release (x86_64-pc-msys)
Copyright (C) 2025 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>

This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
build: a7cce037 (debug)
note: native Windows build without an MSYS runtime; MSYS identifiers are a compatibility persona only (see docs/platform-support.md)

RUBASH_IDENTITY=native swaps line 1 to (x86_64-pc-windows); the appended lines are unchanged. Non-Windows builds print the build: line only.

Compatibility

  • The GNU block (rubash#154 persona banner + rubash#240 license block) is untouched, and the append sits outside it — ecosystem gates and the upstream .right assets are unaffected.
  • help / uname --version version banners are deliberately NOT touched: builtins10.sub pipes help | sed 1d and the manpage IMPLEMENTATION block is pinned by the static .right assets, so an extra banner line there would break byte comparisons. The issue's acceptance criterion (--version traceability) is fully met without them.
  • --version has a single print site (no interactive/tty branch — the banner is never shown at startup), so piped and terminal output are identical.

Tests

  • New tests/cli_tests.rs::version_appends_build_metadata_after_the_gnu_block_rubash_488 pins the full output shape (GNU block byte-exact + build line grammar + Windows note).
  • New src/build_info.rs unit tests: appendix shape, Windows note (4 info points), non-Windows single line, hash/profile grammar.
  • cargo test --lib: 640 passed / 2 failed — both failures pre-exist on clean master on this machine (D:-drive POSIX-path-form env issues), verified identical via a stashed clean-master run.
  • cargo test --test cli_tests: 447 passed (+1 new) / 29 failed — failure set verified byte-identical to clean master (bashdb fixture, examples, tilde/HOME, drive-path env failures; all environmental).
  • cargo test --test help_pages: 12/12 green; identity (5), uname (7), support_names (2) unit tests green.
  • cargo fmt --check passes (pre-commit hook enforced).

… note (rubash#488)

The MSYS-persona banner made dev builds indistinguishable from the
installed release - the fake-baseline root cause behind three agent
incidents on 2026-10-10. The GNU compat block stays byte-identical;
after the license block --version appends:

  build: <git-hash> (<profile>)
  note: native Windows build without an MSYS runtime; MSYS identifiers
        are a compatibility persona only (see docs/platform-support.md)

build.rs captures `git rev-parse --short HEAD` at compile time
(unknown when git is unavailable; RUBASH_BUILD_HASH pins release
packaging). The profile comes from cfg!(debug_assertions). The note
line is Windows-only: non-Windows binaries already report an honest
native triple. help/uname version banners are untouched - upstream
.right assets and the builtins10.sub `sed 1d` normalization gate on
them byte for byte.

Tests: a new cli_tests case pins the full output shape, build_info
unit tests cover the appendix, and the help_pages/identity/uname
suites stay green.
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.

[infra] --version 输出缺 build 元数据:dev 构建以假乱真导致 AI 代理假基线(三起事故根因)

1 participant