Skip to content

Commit 699b80f

Browse files
authored
docs: refresh README and align documentation with current runtime (#112)
1 parent 93bbcd6 commit 699b80f

6 files changed

Lines changed: 70 additions & 71 deletions

File tree

AGENTS.md

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ bin/ security & operations scripts
1818
scan-extensions.mjs extension static analysis
1919
redact-logs.sh secret scrubber for session logs
2020
prune-session-logs.sh retention cleanup for old pi session logs
21-
config.sh env var validation helper
21+
config.sh interactive secrets/config setup
2222
broker-register.mjs Slack broker workspace registration CLI
2323
doctor.sh system health checks
2424
uninstall.sh clean removal of baudbot
@@ -30,9 +30,12 @@ bin/ security & operations scripts
3030
setup-ubuntu.sh Ubuntu droplet: prereqs + setup + tests
3131
setup-arch.sh Arch Linux droplet: prereqs + setup + tests
3232
lib/ shared shell helpers sourced by CLI/release scripts
33-
baudbot-runtime.sh runtime/status/session/attach helper module for bin/baudbot
33+
shell-common.sh strict mode + shared logging/error/root-check helpers
3434
release-common.sh shared update/rollback helpers
35+
deploy-common.sh deploy/runtime helper functions
36+
doctor-common.sh doctor status/check formatting helpers
3537
json-common.sh shared JSON field extraction helper (jq)
38+
baudbot-runtime.sh runtime/status/session/attach helper module for bin/baudbot
3639
hooks/
3740
pre-commit blocks agent from modifying security files in git
3841
pi/
@@ -42,7 +45,7 @@ pi/
4245
heartbeat.ts periodic health check loop
4346
auto-name.ts session naming
4447
control.ts inter-session communication
45-
idle-compact.ts compact context during idle periods (40% threshold)
48+
idle-compact.ts compact context during idle periods (default 25% threshold)
4649
...
4750
skills/ source of truth for agent skill templates
4851
control-agent/ orchestration agent
@@ -66,7 +69,7 @@ See [CONFIGURATION.md](CONFIGURATION.md) for all env vars and how to obtain them
6669

6770
## Architecture: Source / Runtime Separation
6871

69-
The admin owns source checkouts (for example `~/baudbot/`). The agent (`baudbot_agent` user) owns runtime state. The agent **cannot read the source repo** — admin home is `700`.
72+
Live execution is release/runtime-based (`/opt/baudbot` + `baudbot_agent` runtime).
7073

7174
Live operations are now release-based under `/opt/baudbot` (git-free):
7275

@@ -109,12 +112,12 @@ Agent runtime layout:
109112

110113
```bash
111114
# First-time install (interactive — handles everything)
112-
sudo ~/baudbot/install.sh
115+
sudo ./install.sh
113116

114-
# Edit source files directly in ~/baudbot/
117+
# Edit source files in this repository checkout
115118

116119
# For source-only changes (extensions/skills/bridge), deploy directly:
117-
~/baudbot/bin/deploy.sh
120+
./bin/deploy.sh
118121

119122
# For operational updates from git (recommended for live bot):
120123
sudo baudbot update

SECURITY.md

Lines changed: 39 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -2,31 +2,24 @@
22

33
For product overview and team workflow context, start with [README.md](README.md). For architecture and operations docs, see [`docs/architecture.md`](docs/architecture.md) and [`docs/operations.md`](docs/operations.md).
44

5-
## Architecture: Source / Runtime Separation
6-
7-
```
8-
~/baudbot/ ← READ-ONLY source repo (admin-managed)
9-
├── pi/extensions/ ← source of truth for extensions
10-
├── pi/skills/ ← source of truth for skill templates
11-
├── bin/ ← admin scripts (deploy.sh, audit, firewall)
12-
└── slack-bridge/ ← source of truth for bridge
13-
14-
~/.pi/agent/
15-
├── extensions/ ← DEPLOYED copies (real dir, not symlink)
16-
│ ├── tool-guard.ts ← security-critical (deployed by admin)
17-
│ ├── auto-name.ts ← agent-modifiable
18-
│ └── ...
19-
└── skills/ ← agent-owned (agent updates freely)
20-
21-
~/runtime/
22-
└── slack-bridge/ ← DEPLOYED copy (bridge runs from here)
23-
├── bridge.mjs ← agent-modifiable
24-
├── security.mjs ← security-critical (deployed by admin)
25-
└── node_modules/
5+
## Architecture: Release / Runtime Separation
6+
7+
```text
8+
root-managed releases
9+
├── /opt/baudbot/releases/<sha>/ # immutable, git-free snapshots
10+
├── /opt/baudbot/current -> <sha>
11+
└── /opt/baudbot/previous -> <sha>
12+
13+
agent runtime (baudbot_agent)
14+
├── ~/runtime/ # launcher + bridge + runtime scripts
15+
├── ~/.pi/agent/ # deployed extensions/skills + memory + manifests
16+
└── ~/workspace/ # repos + task worktrees
2617
```
2718

28-
The agent runs from deployed copies, never from the source repo directly.
29-
Admin edits source → runs `bin/deploy.sh` → copies to runtime with correct permissions.
19+
Live execution runs from deployed/runtime copies.
20+
`baudbot update` publishes a snapshot, deploys runtime files, validates health, then atomically flips `current`.
21+
22+
Live execution runs from release snapshots under `/opt/baudbot`.
3023

3124
## Trust Boundaries
3225

@@ -48,8 +41,8 @@ Admin edits source → runs `bin/deploy.sh` → copies to runtime with correct p
4841
┌─────────────────────────────────────────────────────────────────┐
4942
│ BOUNDARY 2: OS User Isolation │
5043
│ baudbot_agent (uid 1001) — separate home, no sudo │
51-
Cannot read admin home directory (admin home is 700)
52-
Source repo ~/baudbot/ is read-only (permissions first, tool-guard backup)
44+
In default hardened installs, admin home is not readable by agent (typically mode 700)
45+
Runtime executes from release snapshots under /opt/baudbot
5346
│ Docker only via wrapper (blocks --privileged, host mounts) │
5447
└──────────────────────────────┬──────────────────────────────────┘
5548
@@ -66,14 +59,13 @@ Admin edits source → runs `bin/deploy.sh` → copies to runtime with correct p
6659

6760
| Layer | What | Bypassed by |
6861
|-------|------|-------------|
69-
| **Read-only source** | ~/baudbot/ lives under admin home (700 perms) — agent has zero access. Optional bind mount for defense-in-depth (not applied by default). | Root access |
62+
| **Immutable releases** | Runtime deploys from git-free snapshots under `/opt/baudbot/releases/<sha>`, reducing direct source-tampering risk during live execution. | Root access |
7063
| **File permissions** | Security-critical runtime files deployed `chmod a-w` by deploy.sh. Hard OS-level boundary — blocks `sed`, `python`, any write mechanism. | Root access or `chmod u+w` (which tool-guard blocks) |
7164
| **Tool-guard rules** | Policy/guidance layer: blocks many high-risk Edit/Write/bash patterns and returns safety-interruption reasoning. Not a hard sandbox; novel command patterns may bypass it. | Novel bypass patterns; rely on OS file perms + runtime hardening for hard boundaries |
7265
| **Integrity checks** | security-audit.sh compares runtime file hashes against deploy manifest | None (detection, not prevention) |
73-
| **Pre-commit hook** | Blocks git commit of protected files in source repo | --no-verify (root-owned hook) |
66+
| **Pre-commit hook** | Blocks git commit of protected files in the repository | --no-verify (root-owned hook) |
7467

75-
The read-only source repo is the primary defense. Even if the agent modifies runtime copies,
76-
the admin can re-deploy from the untampered source at any time.
68+
Primary hard boundaries are runtime permissions, user isolation, and release-based deployment. If local source isolation is also enforced, admin can re-deploy from source to restore expected state.
7769

7870
## User Model
7971

@@ -84,21 +76,18 @@ the admin can re-deploy from the untampered source at any time.
8476

8577
**Admin → baudbot_agent access**: The admin user is in the `baudbot_agent` group and has `NOPASSWD: ALL` as baudbot_agent via sudo. This is intentional for management. Run `bin/harden-permissions.sh` to ensure pi state files are owner-only (prevents passive group-level reads).
8678

87-
**baudbot_agent → admin access**: None. Admin home is `700`, baudbot_agent is not in the admin user's group.
79+
**baudbot_agent → admin access**: Expected to be none in default installs. This depends on host permissions (for example, admin home mode and group membership) remaining hardened.
8880

8981
## Data Flows
9082

91-
```
92-
Slack @mention
93-
slack-bridge (Socket Mode, admin user)
83+
```text
84+
Slack message (Socket Mode or broker pull mode)
85+
→ bridge process (runs in baudbot_agent runtime)
9486
→ content wrapping (security boundaries added)
95-
→ Unix socket (~/.pi/session-control/*.sock)
96-
→ control-agent (pi session, baudbot_agent user)
97-
→ creates todo
98-
→ delegates to dev-agent (pi session, baudbot_agent user)
99-
→ git worktree → code changes → git push
100-
→ dev-agent reports back
101-
→ control-agent replies via curl → bridge HTTP API (127.0.0.1:7890)
87+
→ control-agent (pi session)
88+
→ creates todo + delegates to dev-agent in worktree
89+
→ code/test/PR/CI loop
90+
→ control-agent posts status via bridge local API (127.0.0.1:7890)
10291
→ Slack thread reply
10392
```
10493

@@ -112,18 +101,21 @@ Slack @mention
112101
| `KERNEL_API_KEY` | `~/.config/.env` | `600` | Kernel cloud browsers |
113102
| `BAUDBOT_SECRET` | `~/.config/.env` | `600` | Email authentication shared secret |
114103
| SSH key | `~/.ssh/id_ed25519` | `600` | Git push (agent GitHub account) |
115-
| `SLACK_BOT_TOKEN` | Bridge `.env` | `600` | Slack bot OAuth token |
116-
| `SLACK_APP_TOKEN` | Bridge `.env` | `600` | Slack Socket Mode token |
104+
| `SLACK_BOT_TOKEN` | `~/.config/.env` | `600` | Slack bot OAuth token |
105+
| `SLACK_APP_TOKEN` | `~/.config/.env` | `600` | Slack Socket Mode token |
106+
| `SLACK_BROKER_*` keys | `~/.config/.env` | `600` | Broker pull-mode encryption/signing + workspace linkage |
117107

118108
## Deploy Workflow
119109

120110
```bash
121-
# Admin edits source files in ~/baudbot/
122-
# Then deploys to runtime:
123-
~/baudbot/bin/deploy.sh
111+
# Source-only changes from local checkout
112+
sudo baudbot deploy
113+
114+
# Operational update from git (recommended for live bot)
115+
sudo baudbot update
124116

125-
# If bridge is running, restart it:
126-
sudo -u baudbot_agent bash -c 'cd ~/runtime/slack-bridge && node bridge.mjs'
117+
# Roll back if needed
118+
sudo baudbot rollback previous
127119
```
128120

129121
## Known Risks

bin/deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
# ~/baudbot/bin/deploy.sh
66
# ~/baudbot/bin/deploy.sh --dry-run
77
#
8-
# The source repo lives in the admin's home (agent can't read it).
8+
# In default hardened installs, source lives in admin-owned paths not readable by the agent.
99
# This script stages files to a temp dir, then uses sudo -u baudbot_agent
1010
# to install them into the agent's runtime directories. It also stamps
1111
# a version file + hash manifest so the agent can verify integrity

docs/architecture.md

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
# Architecture
22

3-
Baudbot separates admin-owned source from agent-owned runtime to reduce blast radius while still enabling always-on autonomous execution.
3+
Baudbot runs live operations from release snapshots under `/opt/baudbot`, with an agent-owned runtime under `/home/baudbot_agent`.
44

5-
## Source / release / runtime layout
5+
## Release / runtime layout (production)
66

77
```text
8-
admin user
9-
├── ~/baudbot/ # source repo (admin-owned)
10-
│ ├── bin/
11-
│ ├── pi/extensions/
12-
│ ├── pi/skills/
13-
│ └── slack-bridge/ # Slack integration (Socket Mode + broker pull mode)
14-
158
root-managed releases
169
├── /opt/baudbot/
1710
│ ├── releases/<sha>/ # immutable, git-free snapshots
@@ -24,9 +17,13 @@ baudbot_agent user
2417
└── ~/workspace/ # project repos + task worktrees
2518
```
2619

20+
## Deployment source vs live runtime
21+
22+
`baudbot update` publishes a git-free snapshot into `/opt/baudbot/releases/<sha>` and runs live execution from that release path.
23+
2724
## Deployment flow
2825

29-
1. Admin updates source repo.
26+
1. Update is initiated from a target ref/repo.
3027
2. Deploy/update scripts build a staged snapshot.
3128
3. Snapshot is published to `/opt/baudbot/releases/<sha>`.
3229
4. Runtime files are deployed for `baudbot_agent`.

docs/operations.md

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,27 @@ sudo baudbot doctor
7878
sudo baudbot audit
7979

8080
# Deep audit (extension scanner + extra checks)
81-
~/baudbot/bin/security-audit.sh --deep
81+
sudo baudbot audit --deep
8282
```
8383

8484
## Test commands
8585

8686
```bash
8787
# Full test suite
88-
bin/test.sh
88+
npm test
8989

9090
# JS/TS only
91-
bin/test.sh js
91+
npm run test:js
9292

93-
# Shell only
94-
bin/test.sh shell
93+
# Shell/security-script suites
94+
npm run test:shell
95+
96+
# Coverage
97+
npm run test:coverage
98+
99+
# Lint + typecheck
100+
npm run lint
101+
npm run typecheck
95102
```
96103

97104
## Common runbook actions

setup.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ fi
218218

219219
echo "=== Setting up runtime directories ==="
220220
# The agent runs from deployed copies, not from the source repo directly.
221-
# Source: ~/baudbot/ (read-only to agent)
221+
# Source: ~/baudbot/ (typically not readable by agent in hardened default installs)
222222
# Runtime: ~/.pi/agent/extensions/, ~/.pi/agent/skills/, ~/runtime/slack-bridge/
223223
sudo -u baudbot_agent bash -c '
224224
mkdir -p ~/.pi/agent/extensions

0 commit comments

Comments
 (0)