Skip to content

Fix/herdr container detection - #9

Merged
cloud-practitioner merged 8 commits into
mainfrom
fix/herdr-container-detection
Sep 27, 2026
Merged

cloud-practitioner merged 8 commits into
mainfrom
fix/herdr-container-detection

Conversation

@cloud-practitioner

Copy link
Copy Markdown
Owner

No description provided.

fm-bb-pr-support and others added 8 commits September 22, 2026 00:06
Add fallback detection via HERDR_SOCKET_PATH when HERDR_ENV=1 is not
injected into container environments. This handles the case where Herdr
launches crewmates or Pi processes inside devcontainers with an accessible
socket file.

The fix preserves all existing behavior:
- Normal Herdr shells: detects via HERDR_ENV=1 (unchanged)
- Containers with socket: detects via HERDR_SOCKET_PATH (new)
- No Herdr markers: falls back to default tmux (unchanged)
fm_backend_detect()'s HERDR_SOCKET_PATH fallback correctly reports the
herdr backend for a container that has only a forwarded/mounted socket,
but every downstream operational call (fm_backend_herdr_session and
everything built on it) resolved its target purely by HERDR_SESSION,
defaulting to "default" independent of that socket. Without an
equally-forwarded HERDR_SESSION naming the same session, a container's
herdr binary could silently start a brand-new, disconnected server
instead of reaching the real one - a worse failure mode than the
pre-fix broken-tmux fallback because it fails silently.

fm_backend_herdr_session() now derives the session name directly from
HERDR_SOCKET_PATH's verified sessions/<name>/herdr.sock shape when
HERDR_SESSION is unset, so detection and every operational call
provably agree on the same session and socket. An explicit
HERDR_SESSION still wins outright, and an unrecognized socket shape
(or the default session's own no-"sessions"-component socket) still
falls back to "default" exactly as before.

Also add the missing precedence test noted in review: the
HERDR_SOCKET_PATH fallback still wins over CMUX_WORKSPACE_ID.

Test coverage: pure-function unit tests for the new derivation logic
in tests/fm-backend-herdr.test.sh, the cmux precedence case in
tests/fm-backend.test.sh, and a new real-herdr end-to-end suite
(tests/fm-backend-herdr-container-session-e2e.test.sh) proving against
a live herdr binary that a devcontainer-shaped env with only
HERDR_SOCKET_PATH set resolves to and reaches the exact already-running
session, never a fresh disconnected one.
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