feat(wrapper): serve cwd probe + readable fallback — fix OpenChamber HTTP 500 under UID separation - #45
Merged
Conversation
…ber HTTP 500) Headless serve inherited the caller's working directory — typically the developer's $HOME, unreadable for the opencode user by design. The server booted but every config load for that directory answered HTTP 500 (EACCES on <dir>/opencode.jsonc treated as a hard error). The wrapper now probes readability from the opencode user's context via the new gated cwd-check.sh helper (sudoers rule, stat-only), warns on stderr and starts the server from a readable fallback: the projects root containing the cwd, else the first readable configured root, else the opencode home. Unavailable probe (older sudoers) changes nothing. Docs: OPENCHAMBER_OPENCODE_CWD recommendation in the OpenChamber how-to plus wrapper concept; deploy lists, Makefile lint scope and CI chmod lists extended; 16 new unit tests.
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.
What
Headless
opencode serveinherited the caller's working directory —typically the developer's
$HOME, unreadable for theopencodeuser bydesign (UID separation). The server still booted, but every request that
loads config for that directory (
/session,/config,/project)answered HTTP 500: opencode treats
EACCESon<dir>/opencode.jsoncas a hard error instead of "no config file".
The wrapper now probes the serve cwd from the opencode user's context
via a new, sudoers-gated
cwd-check.shhelper (stat-only, mirrorssocket-check.sh). When unreadable it warns on stderr and starts theserver from a readable fallback:
projects.confroot containing the cwd,An unavailable probe (older sudoers without the rule) changes nothing.
Docs recommend persisting
OPENCHAMBER_OPENCODE_CWD=<projects root>fora deterministic server directory; a troubleshooting entry documents
projectless chats as an upstream OpenChamber limitation (chat worktrees
hard-pinned to
$HOME/.config/openchamber/chats+ config rootforce-chmodded to 0700 — not solvable kit-side).
Includes VERSION bump to 0.0.23.
Changed
files/opencode-permissions-kit-lib/bin/cwd-check.sh(new) —readable/unreadable probe, always exits 0 (empty output = unknown)
files/opencode-permissions-kit-lib/wrapper— probe, stderr warning,fallback selection before the exec
files/sudoers.template— NOPASSWD rule forcwd-check.sh(update.sh re-renders sudoers, so existing installs pick it up)
files/install.sh,files/update.sh— fetch/deploy/chmod listsMakefilelint scope + CI chmod lists (all three workflows)tests/test-wrapper-validation.sh— +16 tests (helper functional,fallback selection with stubbed probe, wiring/sudoers static)
docs/how-to/openchamber.md,docs/concepts/wrapper.mdValidation
sh tests/check-host.sh— host readymake test— all shell tests pass (incl. 71 wrapper-validation)make lint(ShellCheck incl. new helper),make check-version— OKmake e2e— 238 PASSmake e2e-rootless— 42 PASS$HOME,serve process fell back to
/var/www/vhosts,/api/*answered 200