Skip to content

Make workdir consistent with the sidecar structure.#359

Open
michael-webster wants to merge 2 commits into
mainfrom
webster/standardize-work-dir
Open

Make workdir consistent with the sidecar structure.#359
michael-webster wants to merge 2 commits into
mainfrom
webster/standardize-work-dir

Conversation

@michael-webster
Copy link
Copy Markdown
Contributor

@michael-webster michael-webster commented May 22, 2026

Chunk sidecars use /home/user as the home dir. This makes the command logic reference that known location instead of relative paths.

Changes

  • Replace hardcoded `/home/user` constant with `sidecarHome()`, which reads `CHUNK_SIDECAR_HOME` env var and falls back to `/home/user`. This allows the base path to be overridden if the sidecar image ever changes its OS user.
  • `ResolveWorkspace` now returns `(string, error)` and errors when `repo` is empty and no workspace is saved — previously this would silently return the bare home dir, which the retry `rm -rf` path would then wipe entirely.
  • Update callers in `sync.go` and `validate.go` to handle the error.
  • Add tests for the empty-repo error case and the env var override.

Chunk sidecars use /home/user as the home dir, this makes the command
logic reference that known location instead of relative paths.
@michael-webster michael-webster marked this pull request as ready for review May 22, 2026 23:53
Comment thread internal/sidecar/sync.go Outdated
)

const workspaceDir = "./workspace"
const workspaceDir = "/home/user"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If repo is empty, ResolveWorkspace returns bare /home/user. The retry path at line 92 runs rm -rf on whatever ResolveWorkspace returned — previously that would have been rm -rf ./workspace (contained), now it's rm -rf /home/user (wipes the sidecar home dir). DetectOrgAndRepo guards the Sync flow, but ResolveWorkspace is public — shouldn't this at least validate that the final path is deeper than the base before returning it?

Comment thread internal/sidecar/sync.go Outdated
)

const workspaceDir = "./workspace"
const workspaceDir = "/home/user"
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The old relative ./workspace worked regardless of which OS user ran the process. /home/user assumes the sidecar user is literally user — if the image ever changes the default user, or someone invokes this outside the expected sidecar, it silently targets the wrong location. Worth deriving from $HOME or an env var instead?

…om env

- ResolveWorkspace now returns (string, error) and errors when repo is
  empty with no saved workspace, preventing rm -rf on the bare home dir
- Replace hardcoded /home/user constant with sidecarHome() which reads
  CHUNK_SIDECAR_HOME env var, falling back to /home/user
- Update callers in sync.go and validate.go
- Add tests for the empty-repo error and env var override

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@michael-webster michael-webster requested a review from danmux May 27, 2026 16:08
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.

2 participants