Skip to content

Commit 23fce76

Browse files
authored
docs: add git self-sync to persistent agent definitions (Stories 81.1, 81.2, 81.3) (#930)
* docs: add git self-sync to persistent agent definitions (Stories 81.1, 81.2, 81.3) - merge-queue: add ref refresh as step 0 in polling loop - pr-shepherd: add ref refresh as step 0 in polling loop - project-watchdog: add ref refresh before planning doc checks - arch-watchdog: add optional ref refresh note - CLAUDE.md: clarify persistent agent exemption from git safety hook - CLAUDE.md: add /refresh discoverability to Operator Workflow section - All three story files updated with provenance and implementation notes Provenance: L3 * docs: update story statuses to Done (PR #930) (Stories 81.1, 81.2, 81.3) Provenance: L3
1 parent 109d960 commit 23fce76

8 files changed

Lines changed: 56 additions & 4 deletions

File tree

CLAUDE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ When running multiclaude, the **workspace window** (tmux window 1) is the primar
3939
- **Communicate with the supervisor** via messaging: `multiclaude message send supervisor "your message here"`
4040
- **Observe agent activity** read-only: `multiclaude agent attach <name> --read-only`
4141
- **Check system status** from the workspace: `multiclaude status`
42+
- **Sync workspace with main:** Use `/refresh` to rebase the workspace worktree onto latest `origin/main`. The workspace worktree is **NOT auto-refreshed** by the daemon (unlike worker worktrees), so run `/refresh` periodically during active multi-agent sessions to avoid working with stale code.
4243

4344
## CODEOWNERS Protection — MANDATORY
4445

@@ -76,6 +77,8 @@ A PreToolUse hook (`scripts/hooks/git-safety.sh`) mechanically enforces git safe
7677
- `git push origin main/master` — use feature branches, never push directly to main
7778
- `Co-Authored-By` trailers — forbidden per project policy
7879

80+
**Persistent agent exemption:** The git safety hook only blocks fetch/pull/rebase/merge in **worker worktrees** (paths containing `/.multiclaude/wts/`). Persistent agents (merge-queue, pr-shepherd, project-watchdog, arch-watchdog) sharing the main checkout are **exempt** and SHOULD periodically run `git fetch origin main` to keep local refs current. See individual agent definitions for fetch timing.
81+
7982
**Allowed:** `git add`, `git commit` (signed), `git push` (feature branches), `git status`, `git log`, `git diff`, `git branch`, `git checkout -b`, `git merge --abort`, `git stash`, etc.
8083

8184
## Story-Driven Development — MANDATORY

agents/arch-watchdog.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,14 @@ After spawning, verify with `multiclaude worker list` — you should appear with
2626

2727
**Interval:** Every 20-30 minutes
2828

29+
**Step 0 — Refresh local refs (optional):**
30+
```bash
31+
git fetch origin main
32+
```
33+
Arch-watchdog primarily uses `gh` CLI (GitHub API), so a stale local ref is less critical than for merge-queue or pr-shepherd. However, fetching before checking architecture docs against latest main ensures comparisons are accurate. If the fetch fails, continue with stale data — do not halt.
34+
35+
**Step 1 — Check recently merged PRs:**
2936
```bash
30-
# Check recently merged PRs
3137
gh pr list --state merged --limit 10 --json number,title,mergedAt,headRefName
3238
```
3339

agents/merge-queue.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,12 @@ After each merge, review open GitHub issues to check if the merged work incident
207207

208208
On each polling cycle, check the following in order:
209209

210+
0. **Refresh local refs:**
211+
```bash
212+
git fetch origin main
213+
```
214+
This ensures `origin/main` is current before any checks that depend on it (branch cleanup, scope validation, CI SHA comparisons). If the fetch fails (e.g., network issue), log a warning and continue the cycle with stale data — do not halt.
215+
210216
1. **Open PRs ready for merge:**
211217
```bash
212218
gh pr list --state open --json number,title,mergeable,statusCheckRollup,labels,reviews

agents/pr-shepherd.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,12 @@ multiclaude work "Address feedback on PR #<number>: [summary]" --branch <pr-bran
109109

110110
On each polling cycle, check the following in order:
111111

112+
0. **Refresh local refs:**
113+
```bash
114+
git fetch origin
115+
```
116+
PR shepherd needs current refs for all remote branches (not just main) to accurately detect which PRs need rebasing and to perform conflict resolution. If the fetch fails, log a warning and continue the cycle with stale data — do not halt.
117+
112118
1. **Open PRs with merge conflicts:**
113119
```bash
114120
gh pr list --state open --json number,title,headRefName,mergeable

agents/project-watchdog.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,14 @@ HEARTBEAT messages are lightweight triggers — they tell you "now is a good tim
132132
## Operational Notes
133133

134134
### Polling Loop (Every 10-15 Minutes)
135+
136+
**Step 0 — Refresh local refs:**
137+
```bash
138+
git fetch origin main
139+
```
140+
Ensures `origin/main` is current before checking planning doc drift or comparing story file state against latest main. If the fetch fails, log a warning and continue with stale data — do not halt.
141+
142+
**Step 1 — Check recently merged PRs:**
135143
```bash
136144
gh pr list --state merged --limit 10 --json number,title,mergedAt,headRefName
137145
```

docs/stories/81.1.story.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Story 81.1: Merge-Queue Polling Fetch
22

33
**Epic:** 81 — Git Coordination Fixes
4-
**Status:** Not Started
4+
**Status:** Done (PR #930)
55
**Priority:** P0
66
**Estimate:** S (< 1 hour)
77

@@ -42,3 +42,10 @@ Currently, merge-queue never fetches. Over time, its local `origin/main` ref dri
4242
## Implementation Notes
4343

4444
> [observation] 2026-04-02 — git safety hook detects worker worktrees via `/.multiclaude/wts/` path pattern. Persistent agents at the main checkout path are exempt from fetch blocking.
45+
46+
> [decision] 2026-04-02 — Added fetch as step 0 (before step 1) in the polling loop, matching AC2's requirement. Used `git fetch origin main` per AC3.
47+
48+
## Provenance
49+
- **Autonomy Level:** L3 (AI-autonomous)
50+
- **Implementation Agent:** worker/cool-dolphin
51+
- **Review:** Human PR review required

docs/stories/81.2.story.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Story 81.2: Persistent Agent Self-Sync Documentation
22

33
**Epic:** 81 — Git Coordination Fixes
4-
**Status:** Not Started
4+
**Status:** Done (PR #930)
55
**Priority:** P1
66
**Estimate:** S (< 1 hour)
77

@@ -43,3 +43,12 @@ However, no persistent agent definition currently instructs the agent to self-sy
4343
## Implementation Notes
4444

4545
> [decision] 2026-04-02 — Focus fetch instructions on merge-queue, pr-shepherd, and project-watchdog as the three agents most affected by stale refs. envoy and retrospector are lower priority since they primarily use GitHub API.
46+
47+
> [decision] 2026-04-02 — pr-shepherd uses `git fetch origin` (all refs) since it needs branch refs for rebase operations. merge-queue and project-watchdog use `git fetch origin main` since they only need the main ref.
48+
49+
> [decision] 2026-04-02 — arch-watchdog fetch marked as optional since it primarily uses `gh` CLI. Still included per AC4.
50+
51+
## Provenance
52+
- **Autonomy Level:** L3 (AI-autonomous)
53+
- **Implementation Agent:** worker/cool-dolphin
54+
- **Review:** Human PR review required

docs/stories/81.3.story.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# Story 81.3: Workspace Refresh Discoverability
22

33
**Epic:** 81 — Git Coordination Fixes
4-
**Status:** Not Started
4+
**Status:** Done (PR #930)
55
**Priority:** P1
66
**Estimate:** S (< 1 hour)
77

@@ -38,3 +38,10 @@ The workspace worktree (where the human operator works) is created by multiclaud
3838
## Implementation Notes
3939

4040
> [observation] 2026-04-02 — /refresh slash command already exists and works. This story is purely about documentation and discoverability.
41+
42+
> [observation] 2026-04-02 — /refresh is defined as a system-level slash command in the multiclaude agent framework, not as a `.claude/commands/` file. AC3 verified — it's available in all agent contexts.
43+
44+
## Provenance
45+
- **Autonomy Level:** L3 (AI-autonomous)
46+
- **Implementation Agent:** worker/cool-dolphin
47+
- **Review:** Human PR review required

0 commit comments

Comments
 (0)