Repository navigation
feat(os): let the kernel describe the system uname reports - #331
Merged
Merged
Conversation
uname printed fixed values for a virtual Linux system. An embedder that runs Shell over a real host, as Box does, has no way to report that host. Add Kernel::system, whose default is the same virtual system, and have uname read it.
Member
Author
|
@strandly-the-agent Please review this PR |
strandly-the-agent
approved these changes
Nov 19, 2026
strandly-the-agent
left a comment
Collaborator
There was a problem hiding this comment.
Approve at 548b268. Kernel::system is a small, opt-in hook in the right place, and standalone uname prints exactly what it did on base. Two inline comments, neither blocking:
- 🟡
tests/custom_kernel.rs:323: the fixture usesDarwinfor both-sand-o, so the test passes with the two fields swapped. - ❓
src/os.rs:92: howSystemInfogains a field later.
What I verified, questions, appendix
Verified (Linux aarch64, rustc 1.100.0, head 548b268, base 1e0dbfb)
cargo test --workspace --all-targets: 2680 passed, 0 failed, 0 ignored across 20 test binaries.cargo fmt --checkandcargo clippy --workspace --all-targetsexit 0; clippy warnings are the same on base and head, none in the changed files.RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-depsexits 0.- Base and head binaries compared over 42
unameinvocations (every short and long flag, combinations,HOSTNAMEvariants,--help, bad options): stdout, stderr and exit code are identical. - Mutations of
uname.rsthat the new test catches: release and version swapped, machine read from the hostARCH,os.system()ignored,-ohard-coded. The one it misses is the inline 🟡. - No other source of system identity in
src/disagrees withunameunder a custom kernel (noarch/hostnamecommand, noOSTYPE/MACHTYPE), andVfsKernelis the onlyimpl Kernelinsrc/, so nothing drops an override. The bindings don't exposeKernel.
Not run: pytest tests/python, npm test, a WASM build, anything on macOS.
Questions (non-blocking)
- Name: every command receives the kernel as
os, so the call isos.system(), which reads as "run a command" (Csystem(3), Pythonos.system) in a shell crate. Woulduname()orsystem_info()be clearer? It's free to rename now. - For the Box follow-up: reporting
Darwinsteers the model toward BSD flags, and Shell's own built-ins reject them. At this headsed -i '' 's/a/X/' ffails withsed: no such file or directory: /home/lash/s/a/Xanddate -v+1dfails withinvalid option '-v'. Worth checking thatDarwinis a net win before Box turns it on.
Appendix (2)
src/os.rs:90says "The system thatunamedescribes", but-ncomes from$HOSTNAMEand-p/-iare fixed. One line saying so would explain to an embedder whyuname -astill sayslocalhost.- The PR checklist box "I have reviewed and understand every line of code in this PR" is unchecked.
zastrowm
previously approved these changes
Nov 19, 2026
os.system() read like running a command, so the method takes the name of the POSIX call it mirrors, as stat() does. SystemInfo gains node_name, so a kernel over a real host can report its name; uname -n still prefers $HOSTNAME. The test fixture now gives -s and -o different values, so a swap of the two fields fails it.
Member
Author
|
Thanks for the review. Addressed in 7cc894a:
|
zastrowm
approved these changes
Nov 19, 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.
Description
Problem
unamealways describes a virtual Linux system. That fits Shell on its own, where the files, the user and the home directory are virtual too.It doesn't fit an embedder that runs Shell over a real host. Box is one: its Shell acts on host files and runs host programs. On macOS,
unamethere saysLinux, so an agent can pick commands the host doesn't have. The embedder can't routeunameto the host program either, because a command Shell implements answers its own name first.Solution
The kernel says which system
unamedescribes, the same waydate,ls,touchandfindaskKernel::nowfor the time.os::SystemInfoholds the fieldsunametakes from the system. They're named after its long options:kernel_name,node_name,kernel_release,kernel_version,machineandoperating_system.SystemInfo::default()is today's virtual system.Kernel::unamereturns that default, andunamereads it instead of its constants.Shell on its own doesn't change.
VfsKernelkeeps the default, sounamestill never shows the host.uname -nstill prefers$HOSTNAME, ashostnamedoes, and falls back to the kernel's node name.Usage
A kernel that serves a real host reports it:
Related Issues
Follows #286. Box will answer
Kernel::unamefrom the host'suname(2)in a follow-up PR once this merges.Documentation PR
None.
Type of Change
New feature
Testing
cargo test --lib: 86 passedcargo test --test shell_integration: 2017 passed. The 16 existingunametests pass unchanged.cargo test --test custom_kernel: 15 passed, including a new test where the kernel reports its own system anduname -aprints every field.cargo test --test date_fixed_clock: 5 passedBox's kernel crate (
cargo test -p strands-box-shell), built against this branch, withKernel::unameanswered from the host'suname(2): 146 passed. Its test checksuname -snrmagainst the host's ownuname.I ran the relevant test suites for the bindings I touched (
cargo test --workspace --all-targets,pytest tests/python,npm test)If I touched Rust, I ran
cargo fmtandcargo clippyChecklist
By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.