Skip to content

Commit 1d270eb

Browse files
docs(acfs): add swarm coordination lesson
1 parent cdf5fdc commit 1d270eb

6 files changed

Lines changed: 562 additions & 141 deletions

File tree

.beads/issues.jsonl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@
301301
{"id":"bd-39ye","title":"NO_COLOR environment variable support","description":"## Overview\nRespect the NO_COLOR environment variable across all ACFS scripts per https://no-color.org/ standard.\n\n## Current Problem\n- Scripts use colors unconditionally\n- Users with accessibility needs can't disable colors\n- Piped output includes ANSI codes\n- Some terminals render colors poorly\n\n## NO_COLOR Standard\n- If NO_COLOR env var is set (any value), disable colors\n- Also disable for non-TTY output (pipes, redirects)\n- Simple, widely adopted convention\n\n## Implementation Details\n1. Create color helper functions in logging.sh\n2. Check NO_COLOR and TTY status once at startup\n3. All color output goes through these helpers\n\n## Color Helper Functions\n```bash\n# scripts/lib/colors.sh\n_init_colors() {\n if [[ -n \"${NO_COLOR:-}\" ]] || [[ ! -t 1 ]]; then\n RED='' GREEN='' YELLOW='' BLUE='' RESET=''\n else\n RED='\\033[0;31m' GREEN='\\033[0;32m'\n YELLOW='\\033[0;33m' BLUE='\\033[0;34m' RESET='\\033[0m'\n fi\n}\n\ncolor_print() {\n local color=\"$1\" msg=\"$2\"\n printf '%b%s%b\\n' \"${!color}\" \"$msg\" \"$RESET\"\n}\n```\n\n## Files to Audit\n- scripts/lib/logging.sh (main color usage)\n- scripts/lib/tui.sh (interactive elements)\n- scripts/install.sh (progress output)\n- All scripts that use printf with ANSI codes\n\n## Test Plan\n- [ ] Test NO_COLOR=1 disables all colors\n- [ ] Test piped output has no ANSI codes\n- [ ] Test colors work normally when NO_COLOR unset\n- [ ] Grep for raw ANSI codes to ensure none slip through\n\n## Files to Modify\n- scripts/lib/logging.sh (add color helpers)\n- All files using hardcoded ANSI codes","status":"closed","priority":3,"issue_type":"task","created_at":"2026-01-25T23:01:49.345301724Z","created_by":"ubuntu","updated_at":"2026-01-27T04:01:25.739562837Z","closed_at":"2026-01-27T04:01:25.739539473Z","close_reason":"done","source_repo":".","compaction_level":0,"original_size":0,"dependencies":[{"issue_id":"bd-39ye","depends_on_id":"bd-3y1n","type":"blocks","created_at":"2026-01-25T23:04:01.194662910Z","created_by":"ubuntu","metadata":"{}","thread_id":""}]}
302302
{"id":"bd-3a81","title":"Add nightly strict installer canary + alert on checksum mismatch","status":"closed","priority":1,"issue_type":"task","owner":"jeff141421@gmail.com","created_at":"2026-01-15T15:21:29.878094357Z","created_by":"Dicklesworthstone","updated_at":"2026-01-15T15:38:29.528321876Z","closed_at":"2026-01-15T15:38:29.528321876Z","close_reason":"Added strict nightly canary workflow with checksum-mismatch alerting + log artifact","source_repo":".","compaction_level":0,"original_size":0}
303303
{"id":"bd-3aa6","title":"Prevent gcloud 'bv' from ever shadowing beads_viewer","description":"Summary\n- gcloud SDK installs a `bv` binary in `/home/ubuntu/google-cloud-sdk/bin`.\n- The SDK’s `path.zsh.inc` is sourced in `~/.zshrc.local`, so PATH can include gcloud’s `bv`.\n- User requirement: **gcloud’s `bv` must never, under any circumstances, intercept/be invoked instead of beads_viewer `bv`.**\n\nImpact\n- High risk of running the wrong `bv` in interactive shells, non-interactive shells, CI, or cron jobs.\n- Mis-executed `bv` can break bead workflows and cause confusion during incident response.\n\nEvidence (current environment)\n- `which -a bv` shows multiple `bv` binaries including gcloud’s:\n - `/home/ubuntu/google-cloud-sdk/bin/bv`\n - `/home/ubuntu/.local/bin/bv`\n - `/home/ubuntu/.bun/bin/bv`\n - `/home/ubuntu/go/bin/bv`\n- PATH is mutated by gcloud SDK via `path.zsh.inc` (sourced in `~/.zshrc.local`).\n\nRoot Cause\n- gcloud SDK ships a `bv` command (BigQuery-related) that collides with beads_viewer’s `bv`.\n- PATH ordering is not explicitly pinned to prefer user `bv` binaries.\n\nProposed Remediation (must enforce precedence)\n1) Prepend user bins ahead of gcloud in shell init:\n - `~/bin`, `~/.local/bin`, `~/.bun/bin`, `~/go/bin` must come before the SDK.\n2) Add an explicit `bv` shim at `~/bin/bv` that delegates to the preferred beads_viewer binary.\n3) Add a hard alias in shell init to force `bv` -> `~/.local/bin/bv` (or preferred).\n4) Add a health check command (or script) that fails if `command -v bv` resolves to gcloud.\n\nAcceptance Criteria\n- `command -v bv` resolves to user beads_viewer (not gcloud) in:\n - interactive shells\n - non-interactive shells (`zsh -lc`, cron)\n- `which -a bv` shows gcloud’s `bv` only after user paths.\n- Running `bv --version` matches beads_viewer’s version, not gcloud’s.\n\nNotes\n- The collision warning appears after `gcloud components update`.\n- This is a safety/operations issue, not a GA4 issue.","status":"closed","priority":1,"issue_type":"bug","created_at":"2026-01-25T00:42:06.371685930Z","created_by":"ubuntu","updated_at":"2026-01-26T23:22:24.883957326Z","closed_at":"2026-01-26T23:22:24.883935966Z","close_reason":"Implemented bv() protection function in acfs.zshrc that bypasses gcloud bv, added ~/bin to PATH, and enhanced doctor.sh to detect gcloud shadowing. Shellcheck passes.","source_repo":".","compaction_level":0,"original_size":0}
304-
{"id":"bd-3b1l8","title":"Write hands-on swarm coordination lesson and landing-plane workflow","description":"## Parent program\n`bd-nlb8w`; depends on coordinate doctor `bd-p3nxh` so the lesson can teach the actual command surface.\n\n## What\nAdd an onboarding/Learning Hub lesson that walks users through a realistic multi-agent loop: run coordination preflight, check Beads with robot commands, register Agent Mail identity, reserve files, send a start message, use RCH for builds, run UBS before commit, close/sync Beads, release reservations, and post a final handoff.\n\n## Why\nACFS installs powerful coordination tools, but users still need a muscle-memory workflow. Teaching the end-to-end loop reduces collisions and makes the flywheel feel intentional.\n\n## How\nReuse existing Learning Hub/onboard patterns. Include copyable commands, expected outputs, common mistakes, and a no-network/local simulation path. Keep the language beginner-friendly while preserving the exact agent rules from AGENTS.md.\n\n## Risks\nDo not teach bare `bv`, stale `bd` commands, or local CPU-heavy cargo builds. Do not imply force-release or destructive cleanup is normal.\n\n## Success criteria\n- Lesson includes a complete start-to-finish coordination scenario.\n- Commands use `br`, `bv --robot-*`, Agent Mail, `rch exec --`, and UBS correctly.\n- Unit/E2E or content tests verify no stale command forms or destructive cleanup guidance.","status":"open","priority":3,"issue_type":"task","created_at":"2026-05-08T04:33:46.043179599Z","created_by":"ubuntu","updated_at":"2026-05-08T04:41:29.985118209Z","source_repo":".","compaction_level":0,"original_size":0,"labels":["docs","idea-wizard","onboarding","swarm"],"dependencies":[{"issue_id":"bd-3b1l8","depends_on_id":"bd-oky34","type":"blocks","created_at":"2026-05-08T04:37:14.117747421Z","created_by":"ubuntu","metadata":"{}","thread_id":""},{"issue_id":"bd-3b1l8","depends_on_id":"bd-p3nxh","type":"blocks","created_at":"2026-05-08T04:37:05.995848437Z","created_by":"ubuntu","metadata":"{}","thread_id":""},{"issue_id":"bd-3b1l8","depends_on_id":"bd-r86ef","type":"blocks","created_at":"2026-05-08T04:41:29.984635054Z","created_by":"ubuntu","metadata":"{}","thread_id":""}]}
304+
{"id":"bd-3b1l8","title":"Write hands-on swarm coordination lesson and landing-plane workflow","description":"## Parent program\n`bd-nlb8w`; depends on coordinate doctor `bd-p3nxh` so the lesson can teach the actual command surface.\n\n## What\nAdd an onboarding/Learning Hub lesson that walks users through a realistic multi-agent loop: run coordination preflight, check Beads with robot commands, register Agent Mail identity, reserve files, send a start message, use RCH for builds, run UBS before commit, close/sync Beads, release reservations, and post a final handoff.\n\n## Why\nACFS installs powerful coordination tools, but users still need a muscle-memory workflow. Teaching the end-to-end loop reduces collisions and makes the flywheel feel intentional.\n\n## How\nReuse existing Learning Hub/onboard patterns. Include copyable commands, expected outputs, common mistakes, and a no-network/local simulation path. Keep the language beginner-friendly while preserving the exact agent rules from AGENTS.md.\n\n## Risks\nDo not teach bare `bv`, stale `bd` commands, or local CPU-heavy cargo builds. Do not imply force-release or destructive cleanup is normal.\n\n## Success criteria\n- Lesson includes a complete start-to-finish coordination scenario.\n- Commands use `br`, `bv --robot-*`, Agent Mail, `rch exec --`, and UBS correctly.\n- Unit/E2E or content tests verify no stale command forms or destructive cleanup guidance.","status":"closed","priority":3,"issue_type":"task","created_at":"2026-05-08T04:33:46.043179599Z","created_by":"ubuntu","updated_at":"2026-05-08T09:33:37.923284688Z","closed_at":"2026-05-08T09:33:37.923012007Z","close_reason":"Added hands-on swarm coordination lesson and command-policy lint","source_repo":".","compaction_level":0,"original_size":0,"labels":["docs","idea-wizard","onboarding","swarm"],"dependencies":[{"issue_id":"bd-3b1l8","depends_on_id":"bd-oky34","type":"blocks","created_at":"2026-05-08T04:37:14.117747421Z","created_by":"ubuntu","metadata":"{}","thread_id":""},{"issue_id":"bd-3b1l8","depends_on_id":"bd-p3nxh","type":"blocks","created_at":"2026-05-08T04:37:05.995848437Z","created_by":"ubuntu","metadata":"{}","thread_id":""},{"issue_id":"bd-3b1l8","depends_on_id":"bd-r86ef","type":"blocks","created_at":"2026-05-08T04:41:29.984635054Z","created_by":"ubuntu","metadata":"{}","thread_id":""}]}
305305
{"id":"bd-3bll","title":"Fix Ubuntu upgrade pre-reboot resume stage + target version handling","description":"Bug: pre-upgrade reboot flow stored .ubuntu_upgrade.stage (wrong key) without enabled/target info, so upgrade_resume.sh could not detect the reboot marker and could crash when state lacked upgrade_path. Also upgrade_resume.sh and ubuntu_upgrade.sh hardcoded target 25.10, ignoring --target-ubuntu.\\n\\nFix: write .ubuntu_upgrade.current_stage=pre_upgrade_reboot + enabled/target_version in install.sh; have upgrade_resume.sh read target_version from state and short-circuit on pre_upgrade_reboot to launch continue_install.sh; make ubuntu_upgrade.sh default target overridable.","status":"closed","priority":2,"issue_type":"bug","created_at":"2025-12-25T06:56:10.854463Z","updated_at":"2025-12-25T06:57:38.519714Z","closed_at":"2025-12-25T06:57:38.519714Z","close_reason":"Fixed pre-upgrade reboot marker + target version propagation across install.sh, ubuntu_upgrade.sh, and upgrade_resume.sh; added safe short-circuit in resume script.","source_repo":".","compaction_level":0,"original_size":0}
306306
{"id":"bd-3bx4v","title":"Fix onboarding CLI aliases and info zero-lessons edge case","status":"closed","priority":2,"issue_type":"bug","created_at":"2026-03-12T20:16:29.520886601Z","created_by":"ubuntu","updated_at":"2026-03-13T00:43:59Z","closed_at":"2026-03-13T00:43:59Z","close_reason":"Fixed onboard noun-style aliases (help/list/version) and made acfs info render a no-lessons state without misleading onboarding prompts; added regression coverage.","source_repo":".","compaction_level":0,"original_size":0}
307307
{"id":"bd-3ci","title":"Fix acfs doctor --json output (pure JSON + correct counts)","description":"scripts/lib/doctor.sh --json currently prints section headings before JSON, doesn’t increment pass/warn/fail counters in JSON mode, and doesn’t escape strings. Make --json emit only valid JSON on stdout with correct summary counts (and handle missing /etc/os-release).","status":"closed","priority":1,"issue_type":"bug","assignee":"FuchsiaCreek","created_at":"2025-12-20T18:44:19.646755Z","updated_at":"2025-12-20T18:49:30.854595Z","closed_at":"2025-12-20T18:49:30.854595Z","close_reason":"Fixed scripts/lib/doctor.sh --json to emit pure valid JSON (no headings), increment counters in JSON mode, and JSON-escape strings; also handles missing /etc/os-release.","source_repo":".","compaction_level":0,"original_size":0}

acfs/onboard/lessons/21_git_strategy.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -148,10 +148,10 @@ When you create a project with `acfs newproj`, this is set up automatically.
148148

149149
## Next
150150

151-
Learn about SRPS (Structured Repository Problem Solving):
151+
Learn the hands-on coordination loop for a real multi-agent task:
152152

153153
```bash
154-
onboard 23
154+
onboard 22
155155
```
156156

157157
---
Lines changed: 228 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,228 @@
1+
# Swarm Coordination: From Claim to Handoff
2+
3+
**Goal:** Run one realistic multi-agent task loop without stale commands, local build storms, or file conflicts.
4+
5+
---
6+
7+
## The Shape of a Safe Swarm Session
8+
9+
A good swarm session is boring in the best way:
10+
11+
1. Pick ready work from Beads.
12+
2. Register with Agent Mail.
13+
3. Reserve the exact files you will edit.
14+
4. Announce the start in the Beads thread.
15+
5. Work in a narrow slice.
16+
6. Run quality gates with the right offload wrapper.
17+
7. Scan changed files with UBS.
18+
8. Close and sync the Bead.
19+
9. Release reservations and hand off the result.
20+
21+
The commands below use `br` for issue state and `bv --robot-*` for graph-aware recommendations. Agents should not launch the interactive Beads viewer during automated work.
22+
23+
---
24+
25+
## 1. Pick the Next Ready Task
26+
27+
Start from robot output so an agent can parse it deterministically:
28+
29+
```bash
30+
bv --robot-next
31+
bv --robot-triage
32+
br ready --json
33+
```
34+
35+
Pick one unblocked Bead, then inspect it:
36+
37+
```bash
38+
br show bd-1234 --json
39+
br update bd-1234 --status in_progress
40+
```
41+
42+
Use the Bead ID everywhere else in the session: Agent Mail thread ID, reservation reason, commit message, and closeout note.
43+
44+
---
45+
46+
## 2. Register With Agent Mail
47+
48+
Agent Mail is exposed to agents as MCP tools. Register a unique identity in the project before reserving files or sending messages:
49+
50+
```text
51+
ensure_project(human_key="/data/projects/my-app")
52+
53+
register_agent(
54+
project_key="/data/projects/my-app",
55+
program="codex-cli",
56+
model="gpt-5",
57+
task_description="bd-1234 checkout validation"
58+
)
59+
```
60+
61+
Agent names are generated adjective+noun identifiers such as `BlueLake` or `GreenCastle`. Use the actual registered name in every later Agent Mail call.
62+
63+
---
64+
65+
## 3. Reserve the Edit Surface
66+
67+
Reserve only the files or tight globs you expect to touch:
68+
69+
```text
70+
file_reservation_paths(
71+
project_key="/data/projects/my-app",
72+
agent_name="BlueLake",
73+
paths=[
74+
"src/checkout/session.ts",
75+
"tests/checkout/session.test.ts"
76+
],
77+
ttl_seconds=3600,
78+
exclusive=true,
79+
reason="bd-1234: checkout validation"
80+
)
81+
```
82+
83+
If the reservation conflicts, choose a different ready Bead or narrow the path set. Do not edit files held by another active agent.
84+
85+
---
86+
87+
## 4. Announce the Start
88+
89+
Use the Bead ID as the Agent Mail thread ID:
90+
91+
```text
92+
send_message(
93+
project_key="/data/projects/my-app",
94+
sender_name="BlueLake",
95+
to=["GreenCastle"],
96+
thread_id="bd-1234",
97+
subject="[bd-1234] Start: checkout validation",
98+
body_md="Claimed bd-1234. Reserved src/checkout/session.ts and tests/checkout/session.test.ts. Plan: add server-side validation and focused tests."
99+
)
100+
```
101+
102+
For solo work, a self-addressed start note is still useful because it leaves an auditable trail.
103+
104+
---
105+
106+
## 5. Work in One Narrow Slice
107+
108+
Keep the slice small enough that another agent can understand it from the Bead, the reservation, and the final diff.
109+
110+
Good swarm slices:
111+
112+
- One failing test plus the production fix.
113+
- One docs page plus its static lint.
114+
- One installer phase hardening change plus a fixture.
115+
116+
Risky swarm slices:
117+
118+
- Broad refactors across unrelated modules.
119+
- Generated files edited by hand.
120+
- Cleanups mixed into feature work.
121+
122+
---
123+
124+
## 6. Run Quality Gates Without Local Build Storms
125+
126+
For Rust-heavy checks, use RCH so swarms do not overload the local machine:
127+
128+
```bash
129+
rch exec -- cargo test
130+
rch exec -- cargo clippy
131+
```
132+
133+
For Bash and web work, use the repo's local gates:
134+
135+
```bash
136+
shellcheck install.sh scripts/**/*.sh
137+
138+
cd apps/web
139+
bun run type-check
140+
bun run lint
141+
bun run build
142+
```
143+
144+
Run the smallest useful gate first, then widen when the change touches shared behavior.
145+
146+
---
147+
148+
## 7. Scan Changed Files With UBS
149+
150+
UBS is the last bug-focused check before commit:
151+
152+
```bash
153+
ubs src/checkout/session.ts tests/checkout/session.test.ts
154+
```
155+
156+
If UBS reports a real issue, fix the cause and rerun it on the changed files.
157+
158+
---
159+
160+
## 8. Close and Sync the Bead
161+
162+
Close the Bead only after the change is implemented and verified:
163+
164+
```bash
165+
br close bd-1234 --reason "Implemented checkout validation and focused tests"
166+
br sync --flush-only
167+
```
168+
169+
`br sync --flush-only` only exports Beads data. You still stage and commit the `.beads/` changes yourself.
170+
171+
---
172+
173+
## 9. Commit, Push, Release, and Handoff
174+
175+
Keep the commit focused and include the Bead ID:
176+
177+
```bash
178+
git status
179+
git add src/checkout/session.ts tests/checkout/session.test.ts .beads/
180+
git commit -m "fix(checkout): validate checkout sessions"
181+
git push origin main
182+
```
183+
184+
Then release reservations and post the final note:
185+
186+
```text
187+
release_file_reservations(
188+
project_key="/data/projects/my-app",
189+
agent_name="BlueLake"
190+
)
191+
192+
send_message(
193+
project_key="/data/projects/my-app",
194+
sender_name="BlueLake",
195+
to=["GreenCastle"],
196+
thread_id="bd-1234",
197+
subject="[bd-1234] Completed: checkout validation",
198+
body_md="Landed commit abc123. Gates: type-check, lint, build, UBS. Reservations released."
199+
)
200+
```
201+
202+
Your final handoff should say what changed, which gates ran, what was not run, and whether any follow-up Beads remain.
203+
204+
---
205+
206+
## Quick Reference
207+
208+
| Step | Command or Tool |
209+
|------|-----------------|
210+
| Find work | `bv --robot-next`, `bv --robot-triage`, `br ready --json` |
211+
| Claim | `br update bd-1234 --status in_progress` |
212+
| Reserve | `file_reservation_paths(...)` |
213+
| Announce | `send_message(..., thread_id="bd-1234")` |
214+
| Rust gates | `rch exec -- cargo test` |
215+
| Scan | `ubs <changed-files>` |
216+
| Close | `br close bd-1234 --reason "..."` |
217+
| Sync | `br sync --flush-only` |
218+
| Release | `release_file_reservations(...)` |
219+
220+
---
221+
222+
## Next
223+
224+
Learn how ACFS keeps the machine responsive under heavy agent load:
225+
226+
```bash
227+
onboard 23
228+
```

0 commit comments

Comments
 (0)