feat: say which machine commands actually run on #6
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "say-where-commands-run"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Closes the audit item «Написать в описании run_command, что команда идёт ВНУТРИ контейнера babash, а не на хосте» — by stating the fact rather than documenting it.
The problem
A model asked to check "the server" cannot tell whether babash is the shell of the machine it means. Over stdio it usually is; deployed it usually is not. In babash-remote,
docker pslists the container's own view andsystemctltalks to nothing — so commands run, exit zero, and describe a machine nobody asked about. Wrong answers, confidently delivered.The fix
babash_initializenow reports hostname and containment, observed at runtime.BABASH_SERVER_INSTRUCTIONS; the code stopped reading it infb67093and the deployed stack still sets it, silently doing nothing since. Worth removing from the stack separately.run_command's description no longer opens with a bare "Execute a shell command" either — it names where that happens and points atbabash_initializefor which machine this is.The detail that matters
Marker files are checked before the cgroup, and that order is the whole trick. babash-remote runs with
pid: host, so pid 1 is the host's init and/proc/1/cgroupreads0::/../../init.scope— a host cgroup, read from inside a container. Detection leaning on that line alone would be confidently wrong for the one deployment this matters most for.Verified by reading all three signals inside the running container:
/.dockerenvTrue,/run/.containerenvFalse, cgroup host-looking.Verification
119 passed,mypy --strictandruffclean. The decision is a pure function over three readings, so both directions are tested without needing a container to run in: no false positive on a laptop or on macOS (where the file does not exist), and no silence inside one.🤖 Generated with Claude Code
Pull request closed