File size: 6,676 Bytes
fd357f4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
# Multi-Server Agent Workflow

## The Problem
Agents work across multiple servers (vast1, vast2, laptop, etc.) in their domain. How do we prevent branch chaos while enabling parallel development?

## The Solution: Domain Branches + Host Overlays

### 1. Default: Domain-Scoped Branches
```bash
# One branch per logical change, regardless of where you work on it
git checkout -b dataops/redis-cluster-optimization

# Work from laptop
vim cache/redis_config.py
git commit -m "Optimize Redis connection pooling"

# Continue from vast1 (git worktree or fresh clone)
git checkout dataops/redis-cluster-optimization
vim cache/performance_tuning.py  
git commit -m "Add memory-mapped config loading"

# Push from anywhere
git push origin dataops/redis-cluster-optimization
```

### 2. Host-Specific Changes: Separate Overlay Branches
```bash
# If you need different config per server
git checkout -b env/host/vast1/redis-memory-limits
# Only touch: overlays/production/vast1/cache_config.yaml

git checkout -b env/host/vast2/redis-memory-limits  
# Only touch: overlays/production/vast2/cache_config.yaml
```

### 3. Coordinated Multi-Host Rollouts
```bash
# Create tracking issue first
gh issue create --title "DTO Cache Upgrade Rollout" --body "..."

# Stack small PRs per host
git checkout -b env/host/vast1/dto-cache-upgrade
git checkout -b env/host/vast2/dto-cache-upgrade
git checkout -b env/host/laptop/dto-cache-upgrade

# Merge queue ensures ordered deployment
```

## Merge Queue Behavior

### Class-A (Serialized): Host Overlays
```
env/host/* → batch_size: 1, strict_order: true
deployment/environments/* → batch_size: 1
```

### Class-B/C (Parallel): Domain Logic  
```
dataops/* → batch_size: 3, if CI green
aiml/* → batch_size: 3, if CI green
signalcore/* → batch_size: 2, if CI green
```

## Branch Lifecycle

### 1. Create Domain Branch
```bash
# Working on DTO lineage improvements
git checkout -b dataops/lineage-performance-v2

# Commit from laptop
git commit -m "Add caching layer to lineage queries"

# Continue from vast1
git worktree add ../dto-vast1 dataops/lineage-performance-v2
cd ../dto-vast1
git commit -m "Add production-scale test data"
```

### 2. Extract Host-Specific Needs
```bash
# Realize vast1 needs different memory limits
git checkout -b env/host/vast1/lineage-memory-boost
# Edit: overlays/production/vast1/lineage_config.yaml

# Keep domain branch clean of host specifics
git checkout dataops/lineage-performance-v2
# Continue with logic changes only
```

### 3. Coordinate PRs
```bash
# Domain change PR (can be parallel)
gh pr create --title "DTO Lineage Performance V2" \
  --head dataops/lineage-performance-v2

# Host overlay PR (will be serialized)  
gh pr create --title "Vast1: Lineage Memory Limits" \
  --head env/host/vast1/lineage-memory-boost \
  --label "class-a,overlay-change,host:vast1"
```

## Labels Drive Behavior

### Required Labels
```yaml
# Domain changes
- domain:dataops
- scope:performance
- class-b

# Host changes  
- class-a
- overlay-change
- host:vast1
- needs-pause  # Until owner approves
```

### CI Gate Rules
```python
# Path-based routing
if path.startswith('overlays/') or path.startswith('deployment/environments/'):
    queue_class = 'A'  # Serialized
    require_labels = ['host:*', 'overlay-change']
    
if path.startswith('dataops/') and not overlay_path:
    queue_class = 'B'  # Can batch
    require_validation = ['dto-schema', 'port-conflicts']
```

## Anti-Patterns to Avoid

### ❌ Server Names in Domain Branches
```bash
# DON'T DO THIS
vast1-dataops-fixes
laptop-testing-branch  
vast2-maybe-works
```

### ❌ Mixed Scope PRs
```bash
# DON'T: Domain logic + host config in one PR
dataops/cache-upgrade-plus-vast1-config

# DO: Split into separate PRs
dataops/cache-upgrade
env/host/vast1/cache-config-update
```

### ❌ Multi-Host Overlay PRs
```bash
# DON'T: Touch multiple hosts in one PR
env/host/all-hosts/memory-increase

# DO: One host per PR  
env/host/vast1/memory-increase
env/host/vast2/memory-increase
```

## Real Example: Syncthing Bandwidth Limits

### Scenario
You're on laptop, need to update Syncthing config across vast1 and vast2 with different bandwidth limits.

### Execution
```bash
# 1. Create domain branch for the feature
git checkout -b dataops/syncthing-adaptive-bandwidth

# 2. Work on core logic (from laptop)
vim integrations/syncthing_client.py
git commit -m "Add adaptive bandwidth calculation"

# 3. Test on vast1 
git worktree add ../dto-vast1 dataops/syncthing-adaptive-bandwidth
cd ../dto-vast1
# Test, iterate, commit improvements

# 4. Create host-specific overlays
git checkout -b env/host/vast1/syncthing-bandwidth-100mb
vim overlays/production/vast1/syncthing_config.yaml
git commit -m "Set vast1 bandwidth limit to 100MB/s"

git checkout -b env/host/vast2/syncthing-bandwidth-50mb  
vim overlays/production/vast2/syncthing_config.yaml
git commit -m "Set vast2 bandwidth limit to 50MB/s"

# 5. Create coordinated PRs
gh pr create --head dataops/syncthing-adaptive-bandwidth \
  --title "Syncthing Adaptive Bandwidth Algorithm"

gh pr create --head env/host/vast1/syncthing-bandwidth-100mb \
  --title "Vast1: Syncthing 100MB/s limit" \
  --label "class-a,overlay-change,host:vast1"

gh pr create --head env/host/vast2/syncthing-bandwidth-50mb \
  --title "Vast2: Syncthing 50MB/s limit" \
  --label "class-a,overlay-change,host:vast2"
```

### Merge Order
1. Domain PR merges first (or in parallel with others)
2. Host overlays merge one at a time via Class-A queue
3. Deployment happens in controlled sequence

## Tool Support

### Git Worktree for Multi-Server
```bash
# Set up parallel workspaces
git worktree add ../dto-laptop main
git worktree add ../dto-vast1 main  
git worktree add ../dto-vast2 main

# Work on same branch from different servers
cd ../dto-vast1 && git checkout dataops/my-feature
cd ../dto-vast2 && git checkout dataops/my-feature
```

### Branch Cleanup Automation
```bash
# Auto-delete merged branches
git config --global branch.autosetupmerge always
git config --global branch.autosetuprebase always

# Cleanup script
./scripts/cleanup-merged-branches.sh
```

## Summary

- **Branch by domain/feature, not by server**
- **Use overlays for host-specific configuration** 
- **Labels and paths drive merge queue behavior**
- **One logical change = one branch, regardless of where you work**
- **Host overlays get serialized; domain logic can be parallel**
- **Git worktree lets you work the same branch from multiple servers**

This keeps the history clean, enables parallel work, and ensures safe deployment across your infrastructure.

---
*Generated by DTO Platform Team - Multi-Server Workflow Standards*