fix(tools): default AGENT_WORK_ROOT to $HOME/mosaic/agent-work #641

Merged
jason.woltje merged 1 commits from fix/pr-merge-agent-work-root-home into main 2026-06-23 13:40:14 +00:00
Owner

Problem

pr-merge.sh (and its regression test) hardcoded /home/hermes/agent-work as the AGENT_WORK_ROOT fallback — one operator's home dir baked into a framework tool. Any other user (e.g. jarvis) hits:

mkdir: cannot create directory '/home/hermes': Permission denied

on every merge, and --skip-queue-guard does not avoid it (the failing mkdir is in the API/tea-error path, not the queue guard). Hit live while merging #552.

Fix

Default to ${AGENT_WORK_ROOT:-${HOME:-/tmp}/mosaic/agent-work}:

  • Per-user isolated — resolves to /home/<user>/mosaic/agent-work, no cross-user collision or permission errors.
  • Separation of concerns~/.config/mosaic stays framework config (overwritten on upgrade); ~/mosaic holds runtime work artifacts.
  • Unset-HOME safety — falls back to /tmp for systemd/CI contexts where $HOME may be empty (an empty HOME would otherwise yield /mosaic/agent-work → root).
  • An explicit AGENT_WORK_ROOT still overrides everything.

5 occurrences across 2 files (pr-merge.sh ×4, test-pr-merge-gitea-empty-uid.sh ×1). All operator-agnostic.

Validation

  • bash -n clean on both files.
  • Regression test test-pr-merge-gitea-empty-uid.sh passes.
  • Verified all three resolution paths: HOME set → $HOME/mosaic/agent-work; HOME unset → /tmp/mosaic/agent-work; AGENT_WORK_ROOT set → honored.
## Problem `pr-merge.sh` (and its regression test) hardcoded `/home/hermes/agent-work` as the `AGENT_WORK_ROOT` fallback — one operator's home dir baked into a framework tool. Any other user (e.g. `jarvis`) hits: ``` mkdir: cannot create directory '/home/hermes': Permission denied ``` on every merge, and `--skip-queue-guard` does **not** avoid it (the failing `mkdir` is in the API/tea-error path, not the queue guard). Hit live while merging #552. ## Fix Default to `${AGENT_WORK_ROOT:-${HOME:-/tmp}/mosaic/agent-work}`: - **Per-user isolated** — resolves to `/home/<user>/mosaic/agent-work`, no cross-user collision or permission errors. - **Separation of concerns** — `~/.config/mosaic` stays framework config (overwritten on upgrade); `~/mosaic` holds runtime work artifacts. - **Unset-HOME safety** — falls back to `/tmp` for systemd/CI contexts where `$HOME` may be empty (an empty HOME would otherwise yield `/mosaic/agent-work` → root). - An explicit `AGENT_WORK_ROOT` still overrides everything. 5 occurrences across 2 files (`pr-merge.sh` ×4, `test-pr-merge-gitea-empty-uid.sh` ×1). All operator-agnostic. ## Validation - `bash -n` clean on both files. - Regression test `test-pr-merge-gitea-empty-uid.sh` passes. - Verified all three resolution paths: HOME set → `$HOME/mosaic/agent-work`; HOME unset → `/tmp/mosaic/agent-work`; `AGENT_WORK_ROOT` set → honored.
jason.woltje added 1 commit 2026-06-23 13:32:12 +00:00
fix(tools): default AGENT_WORK_ROOT to $HOME/mosaic/agent-work
All checks were successful
ci/woodpecker/push/ci Pipeline was successful
ci/woodpecker/pr/ci Pipeline was successful
57834ca8b1
pr-merge.sh and its regression test hardcoded /home/hermes/agent-work as
the AGENT_WORK_ROOT fallback, baking in one operator's home dir. Any other
user (e.g. jarvis) hit 'mkdir: cannot create directory /home/hermes:
Permission denied' on merge, and --skip-queue-guard did not avoid it (the
mkdir is in the API/tea-error path, not the guard).

Default to ${HOME:-/tmp}/mosaic/agent-work instead: per-user isolated,
kept separate from the framework's ~/.config/mosaic config tree, with a
/tmp last-ditch fallback for unset-HOME contexts (systemd/CI). An explicit
AGENT_WORK_ROOT still overrides. 5 occurrences across 2 files.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
jason.woltje merged commit e6b53ea103 into main 2026-06-23 13:40:14 +00:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: mosaicstack/stack#641