Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,18 @@ sudo baudbot env set ANTHROPIC_API_KEY
# or: sudo baudbot env set OPENAI_API_KEY sk-... --restart
```

Migrating droplets and want to keep memory/todos/custom runtime state?

```bash
# old host
sudo baudbot state backup /tmp/baudbot-state.zip

# new host
sudo baudbot stop
sudo baudbot state restore /tmp/baudbot-state.zip
sudo baudbot start
```

See [CONFIGURATION.md](CONFIGURATION.md) for required environment variables and secret setup.

## The Slack broker (optional)
Expand Down
2 changes: 2 additions & 0 deletions bin/baudbot
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,7 @@ usage() {
echo " test Run test suite"
echo " update Build/test in temp checkout, publish git-free release, deploy"
echo " rollback Re-deploy previous (or specified) git-free release snapshot"
echo " state Backup/restore agent state (memory, todos, customizations)"
echo " uninstall Remove everything"
echo ""
echo -e "${BOLD}Options:${RESET}"
Expand Down Expand Up @@ -422,6 +423,7 @@ register_command "audit" "exec" "$BAUDBOT_ROOT/bin/security-audit.sh" "0" "0" ""
register_command "test" "exec" "$BAUDBOT_ROOT/bin/test.sh" "0" "0" ""
register_command "update" "exec" "$BAUDBOT_ROOT/bin/update-release.sh" "1" "0" ""
register_command "rollback" "exec" "$BAUDBOT_ROOT/bin/rollback-release.sh" "1" "0" ""
register_command "state" "exec" "$BAUDBOT_ROOT/bin/state.sh" "1" "0" ""
register_command "uninstall" "exec" "$BAUDBOT_ROOT/bin/uninstall.sh" "1" "0" ""
register_command "doctor" "exec" "$BAUDBOT_ROOT/bin/doctor.sh" "0" "0" ""
register_command "subagents" "exec" "$BAUDBOT_ROOT/bin/subagents.sh" "0" "0" ""
Expand Down
32 changes: 32 additions & 0 deletions bin/baudbot.test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,37 @@ EOF
)
}

test_state_requires_root() {
(
set -euo pipefail
local tmp fakebin out
tmp="$(mktemp -d /tmp/baudbot-cli-test.XXXXXX)"
trap 'rm -rf "$tmp"' EXIT

mkdir -p "$tmp/fakebin"
fakebin="$tmp/fakebin"
cat > "$fakebin/id" <<'EOF'
#!/bin/bash
if [ "${1:-}" = "-u" ]; then
echo 1000
elif [ "${1:-}" = "-un" ]; then
echo tester
else
/usr/bin/id "$@"
fi
EOF
chmod +x "$fakebin/id"

if PATH="$fakebin:$PATH" BAUDBOT_ROOT="$REPO_ROOT" bash "$CLI" state backup >/tmp/baudbot-state.out 2>&1; then
return 1
fi

out="$(cat /tmp/baudbot-state.out)"
rm -f /tmp/baudbot-state.out
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Hardcoded temp file path causes test isolation failure

The test declares local out (line 136) but then redirects command output to the hardcoded global path /tmp/baudbot-state.out instead of using the already-available $tmp directory. If two test processes run concurrently (or a previous run left the file behind), they will clobber each other's output and the grep on line 160 could read stale data from a prior run.

Suggested change
if PATH="$fakebin:$PATH" BAUDBOT_ROOT="$REPO_ROOT" bash "$CLI" state backup >/tmp/baudbot-state.out 2>&1; then
return 1
fi
out="$(cat /tmp/baudbot-state.out)"
rm -f /tmp/baudbot-state.out
if PATH="$fakebin:$PATH" BAUDBOT_ROOT="$REPO_ROOT" bash "$CLI" state backup >"$tmp/state.out" 2>&1; then
return 1
fi
out="$(cat "$tmp/state.out")"
Prompt To Fix With AI
This is a comment left during a code review.
Path: bin/baudbot.test.sh
Line: 154-159

Comment:
**Hardcoded temp file path causes test isolation failure**

The test declares `local out` (line 136) but then redirects command output to the hardcoded global path `/tmp/baudbot-state.out` instead of using the already-available `$tmp` directory. If two test processes run concurrently (or a previous run left the file behind), they will clobber each other's output and the grep on line 160 could read stale data from a prior run.

```suggestion
    if PATH="$fakebin:$PATH" BAUDBOT_ROOT="$REPO_ROOT" bash "$CLI" state backup >"$tmp/state.out" 2>&1; then
      return 1
    fi

    out="$(cat "$tmp/state.out")"
```

How can I resolve this? If you propose a fix, please make it concise.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in commit c0ccf59. I changed the test to write/read output via the per-test temp directory instead of a shared /tmp file. I applied the same isolation cleanup pattern to the nearby debug/broker root-requirement tests as well.

Responded by baudbot-dev-agent using openai/gpt-5.

printf '%s\n' "$out" | grep -q "requires root"
)
}

test_restart_restarts_systemd() {
(
set -euo pipefail
Expand Down Expand Up @@ -191,6 +222,7 @@ run_test "version reads package.json" test_version_uses_package_json
run_test "status dispatches via runtime module" test_status_dispatches_via_runtime_module
run_test "debug requires root" test_debug_requires_root
run_test "broker register requires root" test_broker_register_requires_root
run_test "state command requires root" test_state_requires_root
run_test "restart restarts systemd" test_restart_restarts_systemd

echo ""
Expand Down
Loading
Loading