s9n-devops-agent 2.0.14 → 2.0.18-dev.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/House_Rules_Contracts/API_CONTRACT.md +612 -0
- package/House_Rules_Contracts/DATABASE_SCHEMA_CONTRACT.md +373 -0
- package/House_Rules_Contracts/DEVOPS_AGENT_INSTRUCTIONS.md +743 -0
- package/House_Rules_Contracts/FEATURES_CONTRACT.md +655 -0
- package/House_Rules_Contracts/INFRA_CONTRACT.md +638 -0
- package/House_Rules_Contracts/README.md +671 -0
- package/House_Rules_Contracts/SQL_CONTRACT.json +346 -0
- package/House_Rules_Contracts/THIRD_PARTY_INTEGRATIONS.md +604 -0
- package/README.md +93 -143
- package/bin/cs-devops-agent +20 -2
- package/houserules.md +1412 -0
- package/houserules_structured.md +1442 -0
- package/package.json +6 -2
- package/scripts/generate-ai-commit.js +135 -0
- package/scripts/local-install.sh +42 -0
- package/src/agent-chat.js +457 -0
- package/src/credentials-manager.js +1 -1
- package/src/cs-devops-agent-worker.js +84 -4
- package/src/house-rules-manager.js +4 -14
- package/src/session-coordinator.js +165 -15
- package/src/setup-cs-devops-agent.js +218 -242
- package/src/worktree-manager.js +2 -1
- package/start-devops-session.sh +9 -2
|
@@ -0,0 +1,1442 @@
|
|
|
1
|
+
# House Rules for DevOps Agent (Structured Organization)
|
|
2
|
+
|
|
3
|
+
**IMPORTANT: This project uses structured folder organization for NEW code only.**
|
|
4
|
+
- **Existing files**: Stay in their current locations - DO NOT move them
|
|
5
|
+
- **New features/modules**: Follow the structure below
|
|
6
|
+
- **Rationale**: Structured organization improves discoverability and consistency for new development
|
|
7
|
+
|
|
8
|
+
## 🚨 CRITICAL: File Coordination & Infrastructure Protocol (MUST FOLLOW)
|
|
9
|
+
|
|
10
|
+
**To prevent conflicts with other agents and maintain infrastructure integrity, you MUST follow this protocol:**
|
|
11
|
+
|
|
12
|
+
### Before Editing ANY Files or Creating Infrastructure:
|
|
13
|
+
|
|
14
|
+
1. **DECLARE YOUR INTENT FIRST**
|
|
15
|
+
Create a file at `.file-coordination/active-edits/<your-name>-<session>.json` with:
|
|
16
|
+
```json
|
|
17
|
+
{
|
|
18
|
+
"agent": "<your-name>",
|
|
19
|
+
"session": "<session-id>",
|
|
20
|
+
"files": ["list", "of", "files", "you", "will", "edit"],
|
|
21
|
+
"operation": "edit",
|
|
22
|
+
"reason": "Brief description of what you're doing",
|
|
23
|
+
"declaredAt": "<current-ISO-8601-timestamp>",
|
|
24
|
+
"estimatedDuration": 300
|
|
25
|
+
}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
2. **READ INFRASTRUCTURE DOCUMENTATION**
|
|
29
|
+
- **MUST** read `/infrastructure/infrastructure.md` before creating any servers, instances, or Docker containers
|
|
30
|
+
- This file contains all existing infrastructure details and prevents conflicts
|
|
31
|
+
- Update this file when you create new infrastructure resources
|
|
32
|
+
|
|
33
|
+
3. **CHECK FOR CONFLICTS**
|
|
34
|
+
- Read ALL files in `.file-coordination/active-edits/`
|
|
35
|
+
- If ANY other agent has declared the same files, you must:
|
|
36
|
+
- **STOP IMMEDIATELY** - DO NOT proceed with any edits
|
|
37
|
+
- **ASK THE USER** for explicit permission before editing those files
|
|
38
|
+
- Inform the user which agent has declared the files and for what purpose
|
|
39
|
+
- WAIT for the other agent to finish, OR
|
|
40
|
+
- Choose different files to edit
|
|
41
|
+
- **CRITICAL**: Never edit files another agent has declared without explicit user confirmation
|
|
42
|
+
|
|
43
|
+
4. **ONLY EDIT DECLARED FILES**
|
|
44
|
+
- Never edit files you haven't declared
|
|
45
|
+
- Stay within your declared scope
|
|
46
|
+
|
|
47
|
+
5. **HOLD LOCKS FOR ENTIRE SESSION**
|
|
48
|
+
- Keep your declaration active for the ENTIRE session
|
|
49
|
+
- DO NOT release locks after committing - keep them until session closes
|
|
50
|
+
- Locks protect files from other agents until your changes are merged
|
|
51
|
+
|
|
52
|
+
6. **RELEASE ONLY WHEN SESSION CLOSES**
|
|
53
|
+
- Delete your declaration file ONLY when:
|
|
54
|
+
- Session is being closed/merged, OR
|
|
55
|
+
- Worktree is being removed
|
|
56
|
+
- Move it to `.file-coordination/completed-edits/` during session closure
|
|
57
|
+
- Update `/infrastructure/infrastructure.md` if you created infrastructure
|
|
58
|
+
- **CRITICAL**: Never release locks while session is still active!
|
|
59
|
+
|
|
60
|
+
### If You Detect a Conflict:
|
|
61
|
+
- **STOP IMMEDIATELY** - DO NOT proceed with any edits
|
|
62
|
+
- **ASK THE USER** for explicit permission before editing conflicting files
|
|
63
|
+
- Report the conflict to the user with details:
|
|
64
|
+
- Which files are in conflict
|
|
65
|
+
- Which agent has declared them
|
|
66
|
+
- What that agent is working on (from their declaration)
|
|
67
|
+
- Wait for user decision: override, wait, or choose alternative files
|
|
68
|
+
- **NEVER edit conflicting files without explicit user approval**
|
|
69
|
+
|
|
70
|
+
### Example Workflow:
|
|
71
|
+
```bash
|
|
72
|
+
# 1. Check if files are available (no other agent editing them)
|
|
73
|
+
# 2. Create your declaration in .file-coordination/active-edits/
|
|
74
|
+
# 3. Make your edits
|
|
75
|
+
# 4. Write commit message to the session-specific file
|
|
76
|
+
# 5. Continue working (locks stay active!)
|
|
77
|
+
# 6. When session closes: merge changes THEN remove declaration
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
### Why Locks Must Stay Active:
|
|
81
|
+
- **Problem**: If you release locks after committing, another agent can declare and edit the same files
|
|
82
|
+
- **Result**: Both sessions will conflict when merging
|
|
83
|
+
- **Solution**: Hold locks until session is merged and worktree removed
|
|
84
|
+
- **Benefit**: Prevents duplicate work and merge conflicts
|
|
85
|
+
|
|
86
|
+
**This coordination prevents wasted work and merge conflicts!**
|
|
87
|
+
|
|
88
|
+
---
|
|
89
|
+
|
|
90
|
+
## Architecture Decision Records (ADRs)
|
|
91
|
+
|
|
92
|
+
**We treat architectural decisions as code.**
|
|
93
|
+
Any "Architecturally Significant" change MUST be documented in an ADR.
|
|
94
|
+
|
|
95
|
+
**What is Architecturally Significant?**
|
|
96
|
+
- Adding a new persistence layer (e.g., adding Redis)
|
|
97
|
+
- Changing the multi-agent coordination protocol
|
|
98
|
+
- Adding a new major component or service
|
|
99
|
+
- Changing the testing strategy
|
|
100
|
+
- Introducing the Contract System itself
|
|
101
|
+
|
|
102
|
+
**Workflow:**
|
|
103
|
+
1. **Create:** Create a new file in `adr/` named `XXXX-title-of-decision.md` (e.g., `0002-switch-to-postgres.md`).
|
|
104
|
+
2. **Format:** Use the standard ADR template (Context, Decision, Consequences).
|
|
105
|
+
3. **Review:** Submit as part of your PR.
|
|
106
|
+
|
|
107
|
+
## 🚨 CRITICAL: Contract System (MUST FOLLOW)
|
|
108
|
+
|
|
109
|
+
**ADDED: 2024-12-02**
|
|
110
|
+
|
|
111
|
+
**To prevent duplicate features, conflicting changes, and wasted work, ALL coding agents MUST follow the Contract System.**
|
|
112
|
+
|
|
113
|
+
### What is the Contract System?
|
|
114
|
+
|
|
115
|
+
The Contract System is a **single source of truth** for all project components. Before making ANY changes to:
|
|
116
|
+
- Database schema
|
|
117
|
+
- SQL queries
|
|
118
|
+
- API endpoints
|
|
119
|
+
- Third-party integrations
|
|
120
|
+
- Features
|
|
121
|
+
- Infrastructure/environment variables
|
|
122
|
+
|
|
123
|
+
**You MUST check the relevant contract file first.**
|
|
124
|
+
|
|
125
|
+
### Contract Files Location
|
|
126
|
+
|
|
127
|
+
**All contract files are stored in:** `House_Rules_Contracts/`
|
|
128
|
+
|
|
129
|
+
| Contract File | Purpose | Check Before... |
|
|
130
|
+
|---------------|---------|----------------|
|
|
131
|
+
| `DATABASE_SCHEMA_CONTRACT.md` | Database tables, columns, indexes, migrations | Creating/modifying database schema |
|
|
132
|
+
| `SQL_CONTRACT.json` | Reusable SQL queries with parameters | Writing any SQL query |
|
|
133
|
+
| `API_CONTRACT.md` | All API endpoints and specifications | Creating/modifying API endpoints |
|
|
134
|
+
| `THIRD_PARTY_INTEGRATIONS.md` | External service integrations | Integrating third-party services |
|
|
135
|
+
| `FEATURES_CONTRACT.md` | All features and specifications | Implementing any feature |
|
|
136
|
+
| `INFRA_CONTRACT.md` | Environment variables and infrastructure | Adding configuration/env vars |
|
|
137
|
+
|
|
138
|
+
### 🚨 MANDATORY Workflow for ALL Coding Agents
|
|
139
|
+
|
|
140
|
+
**BEFORE making ANY changes, you MUST:**
|
|
141
|
+
|
|
142
|
+
```
|
|
143
|
+
1. IDENTIFY what you're about to change:
|
|
144
|
+
- Database? → Read DATABASE_SCHEMA_CONTRACT.md
|
|
145
|
+
- SQL query? → Read SQL_CONTRACT.json
|
|
146
|
+
- API endpoint? → Read API_CONTRACT.md
|
|
147
|
+
- Third-party service? → Read THIRD_PARTY_INTEGRATIONS.md
|
|
148
|
+
- Feature? → Read FEATURES_CONTRACT.md
|
|
149
|
+
- Config/env var? → Read INFRA_CONTRACT.md
|
|
150
|
+
|
|
151
|
+
2. SEARCH the contract for existing implementation:
|
|
152
|
+
- Does this table/query/endpoint/feature already exist?
|
|
153
|
+
- Can I reuse existing code instead of creating new?
|
|
154
|
+
- Will my change conflict with existing code?
|
|
155
|
+
|
|
156
|
+
3. DECIDE based on what you found:
|
|
157
|
+
|
|
158
|
+
IF existing implementation found:
|
|
159
|
+
✅ REUSE it - Add your module to "Used By" section
|
|
160
|
+
✅ EXTEND it - If it needs enhancement
|
|
161
|
+
❌ DO NOT duplicate it
|
|
162
|
+
❌ DO NOT create a new version
|
|
163
|
+
|
|
164
|
+
IF no existing implementation:
|
|
165
|
+
✅ CREATE new following contract template
|
|
166
|
+
✅ DOCUMENT thoroughly in contract
|
|
167
|
+
✅ CROSS-REFERENCE other contracts
|
|
168
|
+
✅ UPDATE version number and changelog
|
|
169
|
+
|
|
170
|
+
4. AFTER making changes:
|
|
171
|
+
✅ UPDATE the relevant contract file immediately
|
|
172
|
+
✅ ADD changelog entry with date
|
|
173
|
+
✅ INCREMENT version number
|
|
174
|
+
✅ CROSS-REFERENCE related contracts
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
### Why This Prevents Chaos
|
|
178
|
+
|
|
179
|
+
**Without contracts, multiple agents will:**
|
|
180
|
+
❌ Create duplicate features with different names
|
|
181
|
+
❌ Create duplicate API endpoints for same functionality
|
|
182
|
+
❌ Create duplicate SQL queries doing the same thing
|
|
183
|
+
❌ Integrate the same third-party service multiple times
|
|
184
|
+
❌ Create conflicting database schema changes
|
|
185
|
+
❌ Create duplicate environment variables
|
|
186
|
+
❌ Overwrite each other's code
|
|
187
|
+
❌ Break existing functionality unknowingly
|
|
188
|
+
|
|
189
|
+
**With contracts, agents will:**
|
|
190
|
+
✅ Discover existing functionality before building
|
|
191
|
+
✅ Reuse existing code instead of duplicating
|
|
192
|
+
✅ Know exactly what exists and how to use it
|
|
193
|
+
✅ Avoid conflicts and breaking changes
|
|
194
|
+
✅ Coordinate changes across the codebase
|
|
195
|
+
✅ Maintain consistency and quality
|
|
196
|
+
✅ Save time by not rebuilding what exists
|
|
197
|
+
|
|
198
|
+
### Contract Update Requirements
|
|
199
|
+
|
|
200
|
+
**Every contract update MUST include:**
|
|
201
|
+
|
|
202
|
+
1. **Date stamp:** When the change was made (YYYY-MM-DD)
|
|
203
|
+
2. **Version increment:** Following semver (1.0.0 → 1.0.1 or 1.1.0)
|
|
204
|
+
3. **Changelog entry:** What changed and why
|
|
205
|
+
4. **Impact assessment:** Breaking change? Which modules affected?
|
|
206
|
+
5. **Cross-references:** Links to related contracts
|
|
207
|
+
|
|
208
|
+
**Example changelog entry:**
|
|
209
|
+
```markdown
|
|
210
|
+
| Date | Version | Agent/Author | Changes | Impact |
|
|
211
|
+
|------|---------|--------------|---------|--------|
|
|
212
|
+
| 2024-12-02 | 1.1.0 | Coding Agent Alpha | Added user_preferences table | Non-breaking, new feature |
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Cross-Referencing Contracts
|
|
216
|
+
|
|
217
|
+
**Contracts are interconnected. Always check related contracts:**
|
|
218
|
+
|
|
219
|
+
- **DATABASE_SCHEMA_CONTRACT.md** ↔️ **SQL_CONTRACT.json**
|
|
220
|
+
(Tables ↔️ Queries that use them)
|
|
221
|
+
|
|
222
|
+
- **SQL_CONTRACT.json** ↔️ **API_CONTRACT.md**
|
|
223
|
+
(Queries ↔️ Endpoints that call them)
|
|
224
|
+
|
|
225
|
+
- **API_CONTRACT.md** ↔️ **FEATURES_CONTRACT.md**
|
|
226
|
+
(Endpoints ↔️ Features that use them)
|
|
227
|
+
|
|
228
|
+
- **THIRD_PARTY_INTEGRATIONS.md** ↔️ **INFRA_CONTRACT.md**
|
|
229
|
+
(Services ↔️ API keys/config)
|
|
230
|
+
|
|
231
|
+
- **FEATURES_CONTRACT.md** ↔️ **ALL CONTRACTS**
|
|
232
|
+
(Features use everything)
|
|
233
|
+
|
|
234
|
+
**When updating one contract, check if related contracts need updates too.**
|
|
235
|
+
|
|
236
|
+
### Initial Contract Population
|
|
237
|
+
|
|
238
|
+
**If contracts are empty/incomplete, the DevOps Agent can generate them:**
|
|
239
|
+
|
|
240
|
+
See the "Initial Population Instructions" section in each contract file for:
|
|
241
|
+
- Search patterns to find existing code
|
|
242
|
+
- File locations to check
|
|
243
|
+
- How to extract and document information
|
|
244
|
+
- Automated script approaches
|
|
245
|
+
|
|
246
|
+
**DevOps Agent can execute coding agent scripts to:**
|
|
247
|
+
1. Scan the entire codebase
|
|
248
|
+
2. Identify all features, APIs, database tables, etc.
|
|
249
|
+
3. Generate contract files automatically
|
|
250
|
+
4. Iteratively improve contracts
|
|
251
|
+
|
|
252
|
+
### Enforcement & Quality Gates
|
|
253
|
+
|
|
254
|
+
**1. Automated Validation (Coming Soon)**
|
|
255
|
+
We are moving towards "Executable Specifications". Soon, build scripts will validate that contracts match the codebase.
|
|
256
|
+
* **Drift Check:** `npm run validate-contracts` will fail if code and contracts diverge.
|
|
257
|
+
* **Pre-commit Hook:** Will prevent commits that violate contracts.
|
|
258
|
+
|
|
259
|
+
**2. TDD is Paramount**
|
|
260
|
+
**Contracts do NOT replace Test-Driven Development (TDD).**
|
|
261
|
+
* **Tests** are the executable specification of *behavior*.
|
|
262
|
+
* **Contracts** are the executable specification of *architecture/schema*.
|
|
263
|
+
* **Rule:** You must write tests AND update contracts. One does not substitute for the other.
|
|
264
|
+
|
|
265
|
+
**3. Manual Rejection (Temporary)**
|
|
266
|
+
Until automation is fully in place, the user should reject your changes if you:
|
|
267
|
+
- Create a feature without checking FEATURES_CONTRACT.md first
|
|
268
|
+
- Write SQL without checking SQL_CONTRACT.json first
|
|
269
|
+
- Create an API endpoint without checking API_CONTRACT.md first
|
|
270
|
+
- Integrate a service without checking THIRD_PARTY_INTEGRATIONS.md first
|
|
271
|
+
- Modify database without checking DATABASE_SCHEMA_CONTRACT.md first
|
|
272
|
+
- Add env vars without checking INFRA_CONTRACT.md first
|
|
273
|
+
|
|
274
|
+
**You are violating house rules and creating technical debt.**
|
|
275
|
+
|
|
276
|
+
**The user should reject your changes and require you to:**
|
|
277
|
+
1. Read the relevant contract(s)
|
|
278
|
+
2. Check for existing implementation
|
|
279
|
+
3. Reuse or properly document your changes
|
|
280
|
+
4. Update contracts appropriately
|
|
281
|
+
|
|
282
|
+
### Quick Reference
|
|
283
|
+
|
|
284
|
+
**Before you code, ask yourself:**
|
|
285
|
+
|
|
286
|
+
- 📋 "Does this feature already exist?" → Check `FEATURES_CONTRACT.md`
|
|
287
|
+
- 🔌 "Does this API endpoint already exist?" → Check `API_CONTRACT.md`
|
|
288
|
+
- 🗄️ "Does this database table already exist?" → Check `DATABASE_SCHEMA_CONTRACT.md`
|
|
289
|
+
- 📝 "Does this SQL query already exist?" → Check `SQL_CONTRACT.json`
|
|
290
|
+
- 🌐 "Is this service already integrated?" → Check `THIRD_PARTY_INTEGRATIONS.md`
|
|
291
|
+
- ⚙️ "Does this env variable already exist?" → Check `INFRA_CONTRACT.md`
|
|
292
|
+
|
|
293
|
+
**If the answer is YES → REUSE IT**
|
|
294
|
+
**If the answer is NO → CREATE IT and DOCUMENT IT**
|
|
295
|
+
|
|
296
|
+
---
|
|
297
|
+
|
|
298
|
+
## Project Structure & Folder Guidelines
|
|
299
|
+
|
|
300
|
+
**CRITICAL: Structured organization applies to NEW code only. Existing files remain where they are.**
|
|
301
|
+
|
|
302
|
+
**Refer to `folders.md` (if it exists) for complete folder descriptions. You may create new module and feature subfolders following the patterns below, and MUST update `folders.md` when doing so.**
|
|
303
|
+
|
|
304
|
+
**Structure for NEW Development:**
|
|
305
|
+
```
|
|
306
|
+
ProjectName/
|
|
307
|
+
├── ModuleName/ # Module-specific folders (for NEW modules)
|
|
308
|
+
│ ├── src/ # Source code for this module
|
|
309
|
+
│ │ └── featurename/ # Feature-specific code
|
|
310
|
+
│ └── test/ # Tests for this module
|
|
311
|
+
│ └── featurename/ # Feature-specific tests
|
|
312
|
+
├── src/ # Existing source code (if already present)
|
|
313
|
+
├── test_cases/ # Existing test files (if already present)
|
|
314
|
+
├── test_scripts/ # Test execution scripts
|
|
315
|
+
├── docs/ # Documentation
|
|
316
|
+
├── deploy_test/ # Deployment test scripts
|
|
317
|
+
├── infrastructure/ # Infrastructure docs (READ BEFORE CREATING RESOURCES)
|
|
318
|
+
│ └── infrastructure.md # Server, instance, Docker information
|
|
319
|
+
├── House_Rules_Contracts/ # Contract system files
|
|
320
|
+
├── local_deploy/ # Local-only files (gitignored) - ALL DEBUG/TEMP FILES GO HERE
|
|
321
|
+
└── product_requirement_docs/ # PRDs
|
|
322
|
+
```
|
|
323
|
+
|
|
324
|
+
**When Creating New Modules/Features:**
|
|
325
|
+
- Create a `ModuleName/` folder for the new module
|
|
326
|
+
- Within that, create `src/` and `test/` subdirectories
|
|
327
|
+
- Group related features within `src/featurename/` and `test/featurename/`
|
|
328
|
+
- Update commit messages to reference the module path (e.g., `ModuleName/src/featurename/file.js`)
|
|
329
|
+
|
|
330
|
+
**DO NOT:**
|
|
331
|
+
- Move existing files to fit the new structure
|
|
332
|
+
- Restructure existing modules that are already working
|
|
333
|
+
- Create module folders for one-off changes to existing code
|
|
334
|
+
|
|
335
|
+
### Infrastructure Folder Requirements
|
|
336
|
+
|
|
337
|
+
The `/infrastructure/` folder contains critical system information:
|
|
338
|
+
- **infrastructure.md**: Documents all servers, instances, Docker containers, and their configurations
|
|
339
|
+
- **MUST READ** this file before creating any new infrastructure
|
|
340
|
+
- **MUST UPDATE** this file when you create new resources
|
|
341
|
+
- Include resource names, purposes, ports, dependencies, and access information
|
|
342
|
+
|
|
343
|
+
### Important: Local-Only Files Policy
|
|
344
|
+
|
|
345
|
+
**ALL temporary, debug, and local-only files MUST be placed in `local_deploy/` folder**
|
|
346
|
+
|
|
347
|
+
This folder is gitignored and will never be uploaded to the repository. Use it for:
|
|
348
|
+
- Debug logs and output files
|
|
349
|
+
- Temporary test data
|
|
350
|
+
- Local configuration overrides
|
|
351
|
+
- Session logs and traces
|
|
352
|
+
- Performance profiling results
|
|
353
|
+
- Any files containing sensitive data
|
|
354
|
+
- Migration scripts for local use only
|
|
355
|
+
- Backup files before major changes
|
|
356
|
+
- **WORKTREES FOR DEVOPS AGENT'S OWN DEVELOPMENT**
|
|
357
|
+
- **SESSION DATA WHEN DOGFOODING THE AGENT**
|
|
358
|
+
- **ALL LOCKS AND COORDINATION FILES**
|
|
359
|
+
|
|
360
|
+
### Development vs Production Usage
|
|
361
|
+
|
|
362
|
+
**When developing DevOpsAgent itself (dogfooding):**
|
|
363
|
+
- All worktrees go in: `local_deploy/worktrees/`
|
|
364
|
+
- All session locks go in: `local_deploy/session-locks/`
|
|
365
|
+
- All instructions go in: `local_deploy/instructions/`
|
|
366
|
+
- All session data go in: `local_deploy/sessions/`
|
|
367
|
+
- This keeps the main repo clean while we develop
|
|
368
|
+
|
|
369
|
+
**When DevOpsAgent is used on OTHER projects (production):**
|
|
370
|
+
- It will create `.worktrees/` in the target project
|
|
371
|
+
- It will create `.session-locks/` in the target project
|
|
372
|
+
- Those folders should be added to the target project's .gitignore
|
|
373
|
+
|
|
374
|
+
**Examples:**
|
|
375
|
+
```bash
|
|
376
|
+
# Good - files in local_deploy/ won't be committed
|
|
377
|
+
local_deploy/debug.log
|
|
378
|
+
local_deploy/session-traces/
|
|
379
|
+
local_deploy/temp-test-data.json
|
|
380
|
+
local_deploy/performance-profile.txt
|
|
381
|
+
local_deploy/migration-backup/
|
|
382
|
+
|
|
383
|
+
# Bad - these would be tracked by git
|
|
384
|
+
./debug.log
|
|
385
|
+
./temp-data.json
|
|
386
|
+
./test-output.txt
|
|
387
|
+
```
|
|
388
|
+
|
|
389
|
+
## Commit Policy
|
|
390
|
+
|
|
391
|
+
### 1. Single Commit Message File (`.claude-commit-msg`)
|
|
392
|
+
|
|
393
|
+
**Location**: Project root `.claude-commit-msg`
|
|
394
|
+
**Action**: WRITE to this file (the DevOps agent will process it)
|
|
395
|
+
**Format**:
|
|
396
|
+
```
|
|
397
|
+
type(scope): subject line describing the change (max 72 characters)
|
|
398
|
+
|
|
399
|
+
[WHY - 2 lines explaining the motivation/reason for these changes]
|
|
400
|
+
This change was needed because [specific problem or requirement].
|
|
401
|
+
[Additional context about why this approach was chosen].
|
|
402
|
+
|
|
403
|
+
[WHAT - Each item identifies files changed and what was done]
|
|
404
|
+
- File(s): ModuleName/src/featurename/file.js - Specific change made to these files
|
|
405
|
+
- File(s): infrastructure/infrastructure.md - Updated with new server configuration
|
|
406
|
+
- File(s): docs/README.md - Related documentation updates
|
|
407
|
+
```
|
|
408
|
+
|
|
409
|
+
**Commit Types (REQUIRED - MUST use one of these)**:
|
|
410
|
+
- `feat:` - New feature or capability added
|
|
411
|
+
- `fix:` - Bug fix or error correction
|
|
412
|
+
- `refactor:` - Code restructuring without changing functionality
|
|
413
|
+
- `docs:` - Documentation updates (README, comments, PRDs)
|
|
414
|
+
- `test:` - Adding or modifying tests
|
|
415
|
+
- `chore:` - Maintenance tasks (configs, dependencies, cleanup)
|
|
416
|
+
- `style:` - Code formatting, no functional changes
|
|
417
|
+
- `infra:` - Infrastructure changes (servers, Docker, deployment)
|
|
418
|
+
|
|
419
|
+
**CRITICAL**: All commit messages MUST start with one of these prefixes followed by a colon.
|
|
420
|
+
The DevOps agent will reject commits that don't follow this format.
|
|
421
|
+
|
|
422
|
+
**Rules**:
|
|
423
|
+
- Always start with WHY (2 lines): Explain the problem/need that motivated these changes
|
|
424
|
+
- For each WHAT item: List the specific files changed, then describe what was done
|
|
425
|
+
- Format: "File(s): path/to/file.ext, other.ext - Description of changes"
|
|
426
|
+
- Group related file changes together in one bullet point
|
|
427
|
+
- Be specific about WHAT changed and WHERE (exact file paths)
|
|
428
|
+
- Describe the IMPACT of the change, not just what was done
|
|
429
|
+
- Never include bash commands or command-line syntax
|
|
430
|
+
- Never attempt to run git commands directly
|
|
431
|
+
- Keep the subject line under 72 characters
|
|
432
|
+
- Use present tense ("add" not "added", "fix" not "fixed")
|
|
433
|
+
|
|
434
|
+
### Infrastructure Change Requirements
|
|
435
|
+
|
|
436
|
+
When making infrastructure changes, your commit MUST:
|
|
437
|
+
- Use `infra` type in commit message
|
|
438
|
+
- Update `/infrastructure/infrastructure.md` with new resources
|
|
439
|
+
- Document resource purpose, configuration, and dependencies
|
|
440
|
+
- Include rollback instructions if applicable
|
|
441
|
+
|
|
442
|
+
**Example Infrastructure Commit Message**:
|
|
443
|
+
```
|
|
444
|
+
infra(docker): add PostgreSQL database container for user service
|
|
445
|
+
|
|
446
|
+
The user service needs a dedicated database instance with persistent storage.
|
|
447
|
+
This approach uses Docker Compose for easier local development and testing.
|
|
448
|
+
|
|
449
|
+
- File(s): docker-compose.yml - Add postgres service with volume and environment configuration
|
|
450
|
+
- File(s): infrastructure/infrastructure.md - Document new database container details and connection info
|
|
451
|
+
- File(s): .env.example - Add database credentials template
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
**Example Commit Message**:
|
|
455
|
+
```
|
|
456
|
+
fix(worktree): resolve push-behind error in multi-agent scenarios
|
|
457
|
+
|
|
458
|
+
The DevOps agent was failing when multiple agents pushed to the same branch simultaneously.
|
|
459
|
+
This fix adds retry logic with pull-merge to handle the common "behind remote" scenario.
|
|
460
|
+
|
|
461
|
+
- File(s): src/cs-devops-agent-worker.js - Add retry logic with git pull --no-rebase on push failures
|
|
462
|
+
- File(s): src/utils.js, src/git-helpers.js - Extract common git operations into reusable helper functions
|
|
463
|
+
- File(s): test_cases/worktree/20250929_push_behind_spec.js - Add test case for push-behind scenario
|
|
464
|
+
- File(s): docs/README.md - Document the new retry behavior and configuration options
|
|
465
|
+
```
|
|
466
|
+
|
|
467
|
+
### 2. Product Requirement Docs Updates
|
|
468
|
+
|
|
469
|
+
**When making code changes**: Also update relevant files in the `product_requirement_docs/` folder
|
|
470
|
+
- Keep PRDs in sync with implementation
|
|
471
|
+
- Document new features and their rationale
|
|
472
|
+
- Update affected system components
|
|
473
|
+
|
|
474
|
+
## Session Recovery and Context Persistence
|
|
475
|
+
|
|
476
|
+
### Crash Recovery System (temp_todo.md)
|
|
477
|
+
|
|
478
|
+
**Purpose**: Maintain session continuity across potential crashes or disconnections.
|
|
479
|
+
|
|
480
|
+
**Location**: `/temp_todo.md` (project root)
|
|
481
|
+
|
|
482
|
+
**When to Use**:
|
|
483
|
+
- Starting any multi-step task
|
|
484
|
+
- Before executing complex operations
|
|
485
|
+
- When debugging issues that may cause crashes
|
|
486
|
+
- Whenever working on tasks that modify multiple files
|
|
487
|
+
|
|
488
|
+
**Format**:
|
|
489
|
+
```markdown
|
|
490
|
+
# Current Session Context
|
|
491
|
+
Last Updated: YYYY-MM-DDTHH:MM:SSZ
|
|
492
|
+
|
|
493
|
+
## Task Overview
|
|
494
|
+
[Brief description of what the user asked for]
|
|
495
|
+
|
|
496
|
+
## Current Status
|
|
497
|
+
[What step we're on, what's completed, what's pending]
|
|
498
|
+
|
|
499
|
+
## Infrastructure Context
|
|
500
|
+
[Any infrastructure being created/modified]
|
|
501
|
+
|
|
502
|
+
## Execution Plan
|
|
503
|
+
- [ ] Step 1: Description
|
|
504
|
+
- [x] Step 2: Description (completed)
|
|
505
|
+
- [ ] Step 3: Description (in progress)
|
|
506
|
+
|
|
507
|
+
## Relevant Context
|
|
508
|
+
- Key files being modified:
|
|
509
|
+
- file1.js: [what changes]
|
|
510
|
+
- file2.sh: [what changes]
|
|
511
|
+
- Important findings:
|
|
512
|
+
- [Any discovered issues or insights]
|
|
513
|
+
- Dependencies/Requirements:
|
|
514
|
+
- [Libraries, services needed]
|
|
515
|
+
|
|
516
|
+
## Current Working State
|
|
517
|
+
[Any variables, partial results, or important data to preserve]
|
|
518
|
+
|
|
519
|
+
## Next Steps
|
|
520
|
+
[What should happen next if session resumes]
|
|
521
|
+
|
|
522
|
+
## Error Log (if any)
|
|
523
|
+
[Any errors encountered and their resolution status]
|
|
524
|
+
```
|
|
525
|
+
|
|
526
|
+
**Recovery Process**:
|
|
527
|
+
When starting a new session:
|
|
528
|
+
1. Always check `temp_todo.md` first
|
|
529
|
+
2. If it contains data, ask user: "I found a previous session context. Should I continue where we left off?"
|
|
530
|
+
3. If continuing, resume from "Next Steps"
|
|
531
|
+
4. If not continuing, clear the file and start fresh
|
|
532
|
+
|
|
533
|
+
## Code Quality & Documentation Standards
|
|
534
|
+
|
|
535
|
+
### Module/File Headers
|
|
536
|
+
Every JavaScript file should start with a comprehensive header:
|
|
537
|
+
```javascript
|
|
538
|
+
/**
|
|
539
|
+
* ============================================================================
|
|
540
|
+
* MODULE NAME - Brief Description
|
|
541
|
+
* ============================================================================
|
|
542
|
+
*
|
|
543
|
+
* This module handles [main purpose]. It provides [key functionality].
|
|
544
|
+
*
|
|
545
|
+
* Key Components:
|
|
546
|
+
* - ComponentA: Does X
|
|
547
|
+
* - ComponentB: Handles Y
|
|
548
|
+
*
|
|
549
|
+
* Dependencies:
|
|
550
|
+
* - External: library1, library2
|
|
551
|
+
* - Internal: module.submodule
|
|
552
|
+
*
|
|
553
|
+
* Usage Example:
|
|
554
|
+
* const { MainClass } = require('./this_module');
|
|
555
|
+
* const instance = new MainClass();
|
|
556
|
+
* const result = instance.process();
|
|
557
|
+
* ============================================================================
|
|
558
|
+
*/
|
|
559
|
+
```
|
|
560
|
+
|
|
561
|
+
### Function/Method Comments
|
|
562
|
+
```javascript
|
|
563
|
+
/**
|
|
564
|
+
* Execute a named operation with the provided input.
|
|
565
|
+
*
|
|
566
|
+
* @param {string} operationName - Name of the operation to execute
|
|
567
|
+
* @param {Object} input - Input data for the operation
|
|
568
|
+
* @param {Object} [context={}] - Optional context for execution
|
|
569
|
+
* @returns {Promise<Object>} Result object with status and output
|
|
570
|
+
* @throws {Error} If operation fails or times out
|
|
571
|
+
*
|
|
572
|
+
* @example
|
|
573
|
+
* const result = await execute('process', { data: 'test' });
|
|
574
|
+
* if (result.success) {
|
|
575
|
+
* console.log(result.output);
|
|
576
|
+
* }
|
|
577
|
+
*/
|
|
578
|
+
```
|
|
579
|
+
|
|
580
|
+
### Inline Comments
|
|
581
|
+
```javascript
|
|
582
|
+
// Good inline comments explain WHY, not WHAT
|
|
583
|
+
const DEBOUNCE_MS = 3000; // Longer delay for commit messages to ensure complete writes
|
|
584
|
+
|
|
585
|
+
// Document complex logic
|
|
586
|
+
if (retries > 0) {
|
|
587
|
+
// Pull failed due to behind remote, retry with merge
|
|
588
|
+
// This handles the common case where another agent pushed first
|
|
589
|
+
execSync('git pull --no-rebase origin main');
|
|
590
|
+
}
|
|
591
|
+
|
|
592
|
+
// TODO/FIXME format
|
|
593
|
+
// TODO(username, 2025-09-29): Implement parallel worktree creation
|
|
594
|
+
// FIXME(username, 2025-09-29): Handle edge case when worktree already exists
|
|
595
|
+
```
|
|
596
|
+
|
|
597
|
+
### Testing Policy
|
|
598
|
+
|
|
599
|
+
### Core Testing Principles
|
|
600
|
+
|
|
601
|
+
**Location for NEW tests**: Follow module structure
|
|
602
|
+
- New modules: `ModuleName/test/featurename/`
|
|
603
|
+
- Existing structure: `test_cases/<area>/<component>/`
|
|
604
|
+
- Example (new): `UserModule/test/authentication/`
|
|
605
|
+
- Example (existing): `test_cases/cs-devops-agent/worker/`
|
|
606
|
+
|
|
607
|
+
**Naming Convention**:
|
|
608
|
+
- Files: `YYYYMMDD_<short-slug>_spec.js`
|
|
609
|
+
- Example: `20250929_push_behind_spec.js`
|
|
610
|
+
|
|
611
|
+
**Test Structure**:
|
|
612
|
+
```javascript
|
|
613
|
+
/**
|
|
614
|
+
* Test Case: <human title>
|
|
615
|
+
* - Area: <domain area>
|
|
616
|
+
* - Component: <component/module>
|
|
617
|
+
* - Related Issue/PR: <#id or link>
|
|
618
|
+
* - Repro Summary: <1-3 lines on steps/inputs>
|
|
619
|
+
* - Expected Behavior: <what should happen>
|
|
620
|
+
* - Regression Guard: <what would break if this fails again>
|
|
621
|
+
*/
|
|
622
|
+
|
|
623
|
+
describe('Feature Name', () => {
|
|
624
|
+
beforeEach(() => {
|
|
625
|
+
// Setup
|
|
626
|
+
});
|
|
627
|
+
|
|
628
|
+
it('should handle specific scenario', () => {
|
|
629
|
+
// Arrange - set up test data
|
|
630
|
+
const testData = { /* ... */ };
|
|
631
|
+
|
|
632
|
+
// Act - perform the action
|
|
633
|
+
const result = performAction(testData);
|
|
634
|
+
|
|
635
|
+
// Assert - verify the result
|
|
636
|
+
expect(result).toBe(expected);
|
|
637
|
+
});
|
|
638
|
+
});
|
|
639
|
+
```
|
|
640
|
+
|
|
641
|
+
### Test Execution Strategy
|
|
642
|
+
|
|
643
|
+
**Run specific area tests**:
|
|
644
|
+
```bash
|
|
645
|
+
# Working on cs-devops-agent-worker.js?
|
|
646
|
+
npm test test_cases/cs-devops-agent/worker/
|
|
647
|
+
|
|
648
|
+
# Working on worktree management?
|
|
649
|
+
npm test test_cases/worktree/
|
|
650
|
+
|
|
651
|
+
# Just fixed a specific bug?
|
|
652
|
+
npm test test_cases/worktree/manager/20250929_detection_spec.js
|
|
653
|
+
```
|
|
654
|
+
|
|
655
|
+
### Bug Fix Test Process (MANDATORY)
|
|
656
|
+
|
|
657
|
+
1. **Create failing test FIRST (Red phase)**
|
|
658
|
+
2. **Fix the bug (Green phase)**
|
|
659
|
+
3. **Run area tests (Verification)**
|
|
660
|
+
4. **Run full suite only before commit**
|
|
661
|
+
|
|
662
|
+
## Multi-Agent Coordination
|
|
663
|
+
|
|
664
|
+
### Session Management
|
|
665
|
+
|
|
666
|
+
**Starting a new session**:
|
|
667
|
+
```bash
|
|
668
|
+
# Interactive session starter (recommended)
|
|
669
|
+
npm start
|
|
670
|
+
# or
|
|
671
|
+
./start-devops-session.sh
|
|
672
|
+
```
|
|
673
|
+
|
|
674
|
+
This will:
|
|
675
|
+
1. Ask if you want to use an existing session or create new
|
|
676
|
+
2. Generate instructions for your coding agent
|
|
677
|
+
3. Start the DevOps agent monitoring the appropriate worktree
|
|
678
|
+
|
|
679
|
+
### Worktree Organization
|
|
680
|
+
|
|
681
|
+
**Branch Naming**:
|
|
682
|
+
- Agent branches: `agent/<agent-name>/<task-name>`
|
|
683
|
+
- Daily branches: `dev_sdd_YYYY-MM-DD`
|
|
684
|
+
- Session branches: `<agent>/<session-id>/<task>`
|
|
685
|
+
|
|
686
|
+
**Session Files**:
|
|
687
|
+
- `.devops-session.json` - Session configuration
|
|
688
|
+
- `.devops-commit-<session-id>.msg` - Session-specific commit message file
|
|
689
|
+
- `SESSION_README.md` - Session documentation
|
|
690
|
+
|
|
691
|
+
### Multiple Coding Agent Sessions
|
|
692
|
+
|
|
693
|
+
**Each session gets**:
|
|
694
|
+
- Unique session ID
|
|
695
|
+
- Dedicated worktree
|
|
696
|
+
- Own commit message file
|
|
697
|
+
- Isolated branch
|
|
698
|
+
|
|
699
|
+
**Coordination Files**:
|
|
700
|
+
- `.session-locks/` - Active session locks
|
|
701
|
+
- `.agent-sessions.json` - Session registry
|
|
702
|
+
- `.worktrees/` - Agent worktrees
|
|
703
|
+
|
|
704
|
+
## Environment Variables
|
|
705
|
+
|
|
706
|
+
### Core CS_DevOpsAgent Settings
|
|
707
|
+
```bash
|
|
708
|
+
AC_MSG_FILE=".claude-commit-msg" # Commit message file
|
|
709
|
+
AC_BRANCH_PREFIX="dev_sdd_" # Branch naming prefix
|
|
710
|
+
AC_PUSH=true # Auto-push after commit
|
|
711
|
+
AC_CLEAR_MSG_WHEN="push" # When to clear message file
|
|
712
|
+
AC_MSG_DEBOUNCE_MS=3000 # Wait time after message change
|
|
713
|
+
```
|
|
714
|
+
|
|
715
|
+
### Session-Specific Variables
|
|
716
|
+
```bash
|
|
717
|
+
DEVOPS_SESSION_ID="abc-123" # Current session ID
|
|
718
|
+
AGENT_NAME="claude" # Agent identifier
|
|
719
|
+
AGENT_WORKTREE="claude-abc-123-task" # Worktree name
|
|
720
|
+
```
|
|
721
|
+
|
|
722
|
+
## File Paths and References
|
|
723
|
+
|
|
724
|
+
### Path Formatting Rules
|
|
725
|
+
- Use relative paths for files in same/sub/parent directories
|
|
726
|
+
- Use absolute paths for system files or files outside working tree
|
|
727
|
+
- Examples:
|
|
728
|
+
- Same directory: `main.js`, `config.yaml`
|
|
729
|
+
- Subdirectory (new modules): `ModuleName/src/featurename/worker.js`
|
|
730
|
+
- Subdirectory (existing): `src/components/Button.tsx`, `tests/unit/test_helper.go`
|
|
731
|
+
- Parent directory: `../package.json`, `../../Makefile`
|
|
732
|
+
- Absolute: `/etc/nginx/nginx.conf`, `/usr/local/bin/node`
|
|
733
|
+
|
|
734
|
+
### Code Block Formatting
|
|
735
|
+
```javascript path=/absolute/path/to/file.js start=10
|
|
736
|
+
// Real code from actual file
|
|
737
|
+
```
|
|
738
|
+
|
|
739
|
+
```javascript path=null start=null
|
|
740
|
+
// Example or hypothetical code
|
|
741
|
+
```
|
|
742
|
+
|
|
743
|
+
## Logging Policy
|
|
744
|
+
|
|
745
|
+
### Log File Location
|
|
746
|
+
**IMPORTANT: All log files MUST be written to `local_deploy/logs/` directory**
|
|
747
|
+
|
|
748
|
+
```javascript
|
|
749
|
+
const LOG_DIR = './local_deploy/logs';
|
|
750
|
+
const LOG_FILE = `${LOG_DIR}/devops-agent-${new Date().toISOString().split('T')[0]}.log`;
|
|
751
|
+
|
|
752
|
+
// Ensure log directory exists
|
|
753
|
+
if (!fs.existsSync(LOG_DIR)) {
|
|
754
|
+
fs.mkdirSync(LOG_DIR, { recursive: true });
|
|
755
|
+
}
|
|
756
|
+
```
|
|
757
|
+
|
|
758
|
+
### Log Levels
|
|
759
|
+
```javascript
|
|
760
|
+
const log = (...args) => {
|
|
761
|
+
const message = `[cs-devops-agent] ${args.join(' ')}`;
|
|
762
|
+
console.log(message);
|
|
763
|
+
// Also write to file in local_deploy
|
|
764
|
+
appendToLogFile(message);
|
|
765
|
+
};
|
|
766
|
+
|
|
767
|
+
const dlog = (...args) => {
|
|
768
|
+
if (DEBUG) {
|
|
769
|
+
const message = `[debug] ${args.join(' ')}`;
|
|
770
|
+
console.log(message);
|
|
771
|
+
appendToLogFile(message);
|
|
772
|
+
}
|
|
773
|
+
};
|
|
774
|
+
|
|
775
|
+
function appendToLogFile(message) {
|
|
776
|
+
const timestamp = new Date().toISOString();
|
|
777
|
+
fs.appendFileSync(LOG_FILE, `${timestamp} ${message}\n`);
|
|
778
|
+
}
|
|
779
|
+
```
|
|
780
|
+
|
|
781
|
+
### What to Log
|
|
782
|
+
- Session creation/destruction
|
|
783
|
+
- Worktree operations
|
|
784
|
+
- Git operations (commits, pushes, pulls)
|
|
785
|
+
- Infrastructure changes
|
|
786
|
+
- Error conditions and recovery attempts
|
|
787
|
+
- Agent coordination events
|
|
788
|
+
|
|
789
|
+
### Log Rotation
|
|
790
|
+
- Keep logs in `local_deploy/logs/` organized by date
|
|
791
|
+
- Format: `devops-agent-YYYY-MM-DD.log`
|
|
792
|
+
- Never commit log files to git
|
|
793
|
+
|
|
794
|
+
### Security - NEVER Log
|
|
795
|
+
- API keys or tokens
|
|
796
|
+
- Full file contents (use hashes or excerpts)
|
|
797
|
+
- User credentials
|
|
798
|
+
- Sensitive configuration
|
|
799
|
+
|
|
800
|
+
## Infrastructure Management
|
|
801
|
+
|
|
802
|
+
### Before Creating Resources
|
|
803
|
+
|
|
804
|
+
1. **Read Current State**: Always read `/infrastructure/infrastructure.md` first
|
|
805
|
+
2. **Check for Conflicts**: Ensure no port conflicts or naming collisions
|
|
806
|
+
3. **Plan Integration**: Consider how new resources integrate with existing ones
|
|
807
|
+
|
|
808
|
+
### Documentation Requirements
|
|
809
|
+
|
|
810
|
+
When creating infrastructure, document in `/infrastructure/infrastructure.md`:
|
|
811
|
+
- **Resource Name**: Clear, descriptive name
|
|
812
|
+
- **Type**: Server, container, service, etc.
|
|
813
|
+
- **Purpose**: What this resource does
|
|
814
|
+
- **Configuration**: Ports, environment variables, volumes
|
|
815
|
+
- **Dependencies**: What other resources it needs
|
|
816
|
+
- **Access Information**: How to connect or manage it
|
|
817
|
+
- **Rollback Plan**: How to safely remove if needed
|
|
818
|
+
|
|
819
|
+
### Infrastructure Change Process
|
|
820
|
+
|
|
821
|
+
1. Read `/infrastructure/infrastructure.md`
|
|
822
|
+
2. Declare intent in file coordination
|
|
823
|
+
3. Create/modify infrastructure
|
|
824
|
+
4. Update `/infrastructure/infrastructure.md`
|
|
825
|
+
5. Test the changes
|
|
826
|
+
6. Commit with `infra` type
|
|
827
|
+
|
|
828
|
+
## Common Workflows
|
|
829
|
+
|
|
830
|
+
### 1. Starting a New Development Session
|
|
831
|
+
```bash
|
|
832
|
+
npm start
|
|
833
|
+
# Select "N" for new session
|
|
834
|
+
# Enter task name
|
|
835
|
+
# Copy instructions to your coding agent
|
|
836
|
+
```
|
|
837
|
+
|
|
838
|
+
### 2. Handling Push-Behind Scenarios
|
|
839
|
+
The agent automatically:
|
|
840
|
+
1. Detects push failures
|
|
841
|
+
2. Pulls with --no-rebase to merge
|
|
842
|
+
3. Retries the push
|
|
843
|
+
4. Alerts on conflicts
|
|
844
|
+
|
|
845
|
+
### 3. Multiple Agent Coordination
|
|
846
|
+
```bash
|
|
847
|
+
# Terminal 1: Start agent for feature-auth
|
|
848
|
+
./start-devops-session.sh
|
|
849
|
+
# Creates session abc-123
|
|
850
|
+
|
|
851
|
+
# Terminal 2: Start agent for api-endpoints
|
|
852
|
+
./start-devops-session.sh
|
|
853
|
+
# Creates session def-456
|
|
854
|
+
|
|
855
|
+
# Each coding agent works in their respective worktree
|
|
856
|
+
```
|
|
857
|
+
|
|
858
|
+
## Review Cadence
|
|
859
|
+
|
|
860
|
+
- Review this file quarterly
|
|
861
|
+
- Update when adding major features
|
|
862
|
+
- Keep in sync with actual implementation
|
|
863
|
+
- Document lessons learned from production issues
|
|
864
|
+
|
|
865
|
+
## Additional Development Guidelines
|
|
866
|
+
|
|
867
|
+
### Error Handling
|
|
868
|
+
|
|
869
|
+
**Always provide meaningful error messages:**
|
|
870
|
+
```javascript
|
|
871
|
+
// Bad
|
|
872
|
+
if (!file) throw new Error('Error');
|
|
873
|
+
|
|
874
|
+
// Good
|
|
875
|
+
if (!file) {
|
|
876
|
+
throw new Error(`File not found: ${filePath}. Ensure the file exists and you have read permissions.`);
|
|
877
|
+
}
|
|
878
|
+
```
|
|
879
|
+
|
|
880
|
+
**Use try-catch appropriately:**
|
|
881
|
+
```javascript
|
|
882
|
+
try {
|
|
883
|
+
const result = await riskyOperation();
|
|
884
|
+
return result;
|
|
885
|
+
} catch (error) {
|
|
886
|
+
// Log the error with context
|
|
887
|
+
console.error(`Failed to perform operation: ${error.message}`, {
|
|
888
|
+
operation: 'riskyOperation',
|
|
889
|
+
context: relevantContext
|
|
890
|
+
});
|
|
891
|
+
|
|
892
|
+
// Decide whether to recover or propagate
|
|
893
|
+
if (canRecover(error)) {
|
|
894
|
+
return fallbackValue;
|
|
895
|
+
}
|
|
896
|
+
throw error; // Re-throw if unrecoverable
|
|
897
|
+
}
|
|
898
|
+
```
|
|
899
|
+
|
|
900
|
+
### Code Organization
|
|
901
|
+
|
|
902
|
+
**Single Responsibility Principle:**
|
|
903
|
+
- Each function should do one thing well
|
|
904
|
+
- Each module should have a clear, focused purpose
|
|
905
|
+
- If a function is > 50 lines, consider breaking it down
|
|
906
|
+
|
|
907
|
+
**DRY (Don't Repeat Yourself):**
|
|
908
|
+
- Extract common logic into utility functions
|
|
909
|
+
- Use configuration objects for repeated patterns
|
|
910
|
+
- Create abstractions for repeated workflows
|
|
911
|
+
|
|
912
|
+
### Performance Considerations
|
|
913
|
+
|
|
914
|
+
**File System Operations:**
|
|
915
|
+
```javascript
|
|
916
|
+
// Use async operations for better performance
|
|
917
|
+
const fs = require('fs').promises;
|
|
918
|
+
|
|
919
|
+
// Good - non-blocking
|
|
920
|
+
const data = await fs.readFile(path, 'utf8');
|
|
921
|
+
|
|
922
|
+
// Avoid - blocking
|
|
923
|
+
const data = fs.readFileSync(path, 'utf8');
|
|
924
|
+
```
|
|
925
|
+
|
|
926
|
+
**Git Operations:**
|
|
927
|
+
- Batch operations when possible
|
|
928
|
+
- Use `--no-pager` for git commands to avoid hanging
|
|
929
|
+
- Implement retry logic for network-dependent operations
|
|
930
|
+
|
|
931
|
+
### Security Best Practices
|
|
932
|
+
|
|
933
|
+
**Input Validation:**
|
|
934
|
+
```javascript
|
|
935
|
+
// Always validate and sanitize inputs
|
|
936
|
+
function processPath(userPath) {
|
|
937
|
+
// Prevent directory traversal
|
|
938
|
+
if (userPath.includes('../') || userPath.includes('..\\')) {
|
|
939
|
+
throw new Error('Invalid path: directory traversal detected');
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
// Ensure path is within allowed directory
|
|
943
|
+
const resolvedPath = path.resolve(userPath);
|
|
944
|
+
if (!resolvedPath.startsWith(ALLOWED_BASE_PATH)) {
|
|
945
|
+
throw new Error('Path outside allowed directory');
|
|
946
|
+
}
|
|
947
|
+
|
|
948
|
+
return resolvedPath;
|
|
949
|
+
}
|
|
950
|
+
```
|
|
951
|
+
|
|
952
|
+
**Command Injection Prevention:**
|
|
953
|
+
```javascript
|
|
954
|
+
// Never concatenate user input into shell commands
|
|
955
|
+
// Bad
|
|
956
|
+
execSync(`git checkout ${userBranch}`);
|
|
957
|
+
|
|
958
|
+
// Good - use array arguments
|
|
959
|
+
execSync('git', ['checkout', userBranch]);
|
|
960
|
+
```
|
|
961
|
+
|
|
962
|
+
### Git Workflow Best Practices
|
|
963
|
+
|
|
964
|
+
**Commit Guidelines:**
|
|
965
|
+
- Make atomic commits (one logical change per commit)
|
|
966
|
+
- Write clear, descriptive commit messages
|
|
967
|
+
- Reference issues/PRs when applicable
|
|
968
|
+
- Avoid committing commented-out code
|
|
969
|
+
|
|
970
|
+
**Branch Management:**
|
|
971
|
+
- Keep branches focused on single features/fixes
|
|
972
|
+
- Regularly sync with main branch
|
|
973
|
+
- Clean up merged branches
|
|
974
|
+
- Use meaningful branch names
|
|
975
|
+
|
|
976
|
+
### Documentation Requirements
|
|
977
|
+
|
|
978
|
+
**README Updates:**
|
|
979
|
+
- Update README when adding new features
|
|
980
|
+
- Include usage examples for new functionality
|
|
981
|
+
- Document breaking changes prominently
|
|
982
|
+
- Keep installation instructions current
|
|
983
|
+
|
|
984
|
+
**API Documentation:**
|
|
985
|
+
- Document all public functions/methods
|
|
986
|
+
- Include parameter types and return values
|
|
987
|
+
- Provide usage examples
|
|
988
|
+
- Note any side effects or prerequisites
|
|
989
|
+
|
|
990
|
+
### Debugging Helpers
|
|
991
|
+
|
|
992
|
+
**Debug Mode:**
|
|
993
|
+
```javascript
|
|
994
|
+
// Use environment variable for debug output
|
|
995
|
+
const DEBUG = process.env.DEBUG === 'true';
|
|
996
|
+
const DEBUG_FILE = process.env.DEBUG_FILE || './local_deploy/debug.log';
|
|
997
|
+
|
|
998
|
+
function debugLog(...args) {
|
|
999
|
+
if (DEBUG) {
|
|
1000
|
+
const timestamp = new Date().toISOString();
|
|
1001
|
+
const message = `[DEBUG] ${timestamp} ${args.join(' ')}`;
|
|
1002
|
+
console.log(message);
|
|
1003
|
+
|
|
1004
|
+
// Also write to debug file in local_deploy
|
|
1005
|
+
if (DEBUG_FILE) {
|
|
1006
|
+
fs.appendFileSync(DEBUG_FILE, message + '\n');
|
|
1007
|
+
}
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
```
|
|
1011
|
+
|
|
1012
|
+
**Debug Output Location:**
|
|
1013
|
+
- All debug files MUST be written to `local_deploy/` directory
|
|
1014
|
+
- Never write debug output to the project root or src directories
|
|
1015
|
+
- Example: `local_deploy/debug-${Date.now()}.log`
|
|
1016
|
+
|
|
1017
|
+
**Performance Timing:**
|
|
1018
|
+
```javascript
|
|
1019
|
+
function timeOperation(name, fn) {
|
|
1020
|
+
const start = Date.now();
|
|
1021
|
+
const result = fn();
|
|
1022
|
+
const duration = Date.now() - start;
|
|
1023
|
+
console.log(`[PERF] ${name} took ${duration}ms`);
|
|
1024
|
+
return result;
|
|
1025
|
+
}
|
|
1026
|
+
```
|
|
1027
|
+
|
|
1028
|
+
### Dependency Management
|
|
1029
|
+
|
|
1030
|
+
**Package.json Best Practices:**
|
|
1031
|
+
- Use exact versions for critical dependencies
|
|
1032
|
+
- Document why each dependency is needed
|
|
1033
|
+
- Regularly audit for security vulnerabilities
|
|
1034
|
+
- Keep dependencies up to date
|
|
1035
|
+
|
|
1036
|
+
**Import Organization:**
|
|
1037
|
+
```javascript
|
|
1038
|
+
// Group imports logically
|
|
1039
|
+
// 1. Node built-ins
|
|
1040
|
+
import fs from 'fs';
|
|
1041
|
+
import path from 'path';
|
|
1042
|
+
|
|
1043
|
+
// 2. External dependencies
|
|
1044
|
+
import express from 'express';
|
|
1045
|
+
import lodash from 'lodash';
|
|
1046
|
+
|
|
1047
|
+
// 3. Internal modules
|
|
1048
|
+
import { config } from './config';
|
|
1049
|
+
import { utils } from './utils';
|
|
1050
|
+
```
|
|
1051
|
+
|
|
1052
|
+
### Code Review Checklist
|
|
1053
|
+
|
|
1054
|
+
Before committing, verify:
|
|
1055
|
+
- [ ] Tests pass
|
|
1056
|
+
- [ ] No console.log() left in production code
|
|
1057
|
+
- [ ] Error handling is comprehensive
|
|
1058
|
+
- [ ] Documentation is updated
|
|
1059
|
+
- [ ] Code follows project style guide
|
|
1060
|
+
- [ ] No sensitive data in code or comments
|
|
1061
|
+
- [ ] Performance impact considered
|
|
1062
|
+
- [ ] Security implications reviewed
|
|
1063
|
+
|
|
1064
|
+
### Communication with Users
|
|
1065
|
+
|
|
1066
|
+
**Progress Updates:**
|
|
1067
|
+
- Provide clear status updates for long-running operations
|
|
1068
|
+
- Use spinners or progress bars where appropriate
|
|
1069
|
+
- Estimate completion time when possible
|
|
1070
|
+
|
|
1071
|
+
**Error Communication:**
|
|
1072
|
+
- Explain what went wrong in user-friendly terms
|
|
1073
|
+
- Suggest potential fixes or workarounds
|
|
1074
|
+
- Provide links to documentation when relevant
|
|
1075
|
+
- Include error codes for support reference
|
|
1076
|
+
|
|
1077
|
+
|
|
1078
|
+
---
|
|
1079
|
+
|
|
1080
|
+
## 🤖 DevOps Agent Automation (NEW: 2024-12-02)
|
|
1081
|
+
|
|
1082
|
+
**The DevOps Agent can now automatically generate, validate, and maintain contract files.**
|
|
1083
|
+
|
|
1084
|
+
### Automation Scripts
|
|
1085
|
+
|
|
1086
|
+
All automation scripts are located in `scripts/contract-automation/`:
|
|
1087
|
+
|
|
1088
|
+
1. **generate-contracts.js** - Scan codebase and extract contract information
|
|
1089
|
+
2. **analyze-with-llm.js** - Use Groq LLM for intelligent analysis
|
|
1090
|
+
3. **validate-commit.js** - Validate commit messages with contract flags
|
|
1091
|
+
4. **check-compliance.js** - Check if contracts are in sync with code
|
|
1092
|
+
|
|
1093
|
+
See `scripts/contract-automation/README.md` for detailed documentation.
|
|
1094
|
+
|
|
1095
|
+
### Contract Generation Workflow
|
|
1096
|
+
|
|
1097
|
+
**Step 1: Local Scanning**
|
|
1098
|
+
|
|
1099
|
+
```bash
|
|
1100
|
+
node scripts/contract-automation/generate-contracts.js --verbose
|
|
1101
|
+
```
|
|
1102
|
+
|
|
1103
|
+
This scans the codebase and extracts:
|
|
1104
|
+
- Features from `src/features/` and `src/modules/`
|
|
1105
|
+
- API endpoints from route files
|
|
1106
|
+
- Database tables from migrations
|
|
1107
|
+
- SQL queries from code
|
|
1108
|
+
- Third-party integrations from package.json
|
|
1109
|
+
- Environment variables from code
|
|
1110
|
+
|
|
1111
|
+
Output: `House_Rules_Contracts/contract-scan-results.json`
|
|
1112
|
+
|
|
1113
|
+
**Step 2: LLM Analysis (Optional but Recommended)**
|
|
1114
|
+
|
|
1115
|
+
```bash
|
|
1116
|
+
node scripts/contract-automation/analyze-with-llm.js \
|
|
1117
|
+
--scan-results=House_Rules_Contracts/contract-scan-results.json
|
|
1118
|
+
```
|
|
1119
|
+
|
|
1120
|
+
This uses Groq LLM to:
|
|
1121
|
+
- Generate human-readable descriptions
|
|
1122
|
+
- Create user stories and acceptance criteria
|
|
1123
|
+
- Infer API request/response formats
|
|
1124
|
+
- Provide security and performance recommendations
|
|
1125
|
+
- Validate contract completeness
|
|
1126
|
+
|
|
1127
|
+
Output: `House_Rules_Contracts/llm-analysis-results.json`
|
|
1128
|
+
|
|
1129
|
+
**Step 3: Manual Population**
|
|
1130
|
+
|
|
1131
|
+
Review the generated JSON files and manually populate the contract markdown files with the discovered information. Use the templates already in place.
|
|
1132
|
+
|
|
1133
|
+
### Commit Message Contract Flags (MANDATORY)
|
|
1134
|
+
|
|
1135
|
+
**All commits MUST include contract flags in this format:**
|
|
1136
|
+
|
|
1137
|
+
```
|
|
1138
|
+
feat(api): add user profile endpoint
|
|
1139
|
+
|
|
1140
|
+
Contracts: [SQL:T, API:T, DB:F, 3RD:F, FEAT:T, INFRA:F]
|
|
1141
|
+
|
|
1142
|
+
[WHY] Users need to view and update their profile information.
|
|
1143
|
+
|
|
1144
|
+
[WHAT]
|
|
1145
|
+
- File(s): src/api/profile.js - Added GET /api/v1/profile endpoint
|
|
1146
|
+
- File(s): House_Rules_Contracts/API_CONTRACT.md - Documented new endpoint
|
|
1147
|
+
```
|
|
1148
|
+
|
|
1149
|
+
**Contract Flags:**
|
|
1150
|
+
- `SQL:T/F` - SQL_CONTRACT.json modified
|
|
1151
|
+
- `API:T/F` - API_CONTRACT.md modified
|
|
1152
|
+
- `DB:T/F` - DATABASE_SCHEMA_CONTRACT.md modified
|
|
1153
|
+
- `3RD:T/F` - THIRD_PARTY_INTEGRATIONS.md modified
|
|
1154
|
+
- `FEAT:T/F` - FEATURES_CONTRACT.md modified
|
|
1155
|
+
- `INFRA:T/F` - INFRA_CONTRACT.md modified
|
|
1156
|
+
|
|
1157
|
+
**Validation:**
|
|
1158
|
+
|
|
1159
|
+
Before committing, run:
|
|
1160
|
+
|
|
1161
|
+
```bash
|
|
1162
|
+
node scripts/contract-automation/validate-commit.js --check-staged --auto-fix
|
|
1163
|
+
```
|
|
1164
|
+
|
|
1165
|
+
This will:
|
|
1166
|
+
- ✅ Check if claimed contract flags match actual file changes
|
|
1167
|
+
- ✅ Detect false positives (claimed T but not modified)
|
|
1168
|
+
- ✅ Detect false negatives (modified but not claimed)
|
|
1169
|
+
- ✅ Generate corrected commit message if --auto-fix used
|
|
1170
|
+
|
|
1171
|
+
**The DevOps Agent will alert the user if:**
|
|
1172
|
+
- Contract flags are missing
|
|
1173
|
+
- Contract flags don't match actual changes
|
|
1174
|
+
- Contract files should have been updated but weren't
|
|
1175
|
+
|
|
1176
|
+
### Compliance Checking
|
|
1177
|
+
|
|
1178
|
+
**Run periodic compliance checks:**
|
|
1179
|
+
|
|
1180
|
+
```bash
|
|
1181
|
+
node scripts/contract-automation/check-compliance.js
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
This checks if:
|
|
1185
|
+
- Features in code are documented in FEATURES_CONTRACT.md
|
|
1186
|
+
- API endpoints in code are documented in API_CONTRACT.md
|
|
1187
|
+
- Database tables in migrations are documented in DATABASE_SCHEMA_CONTRACT.md
|
|
1188
|
+
- Third-party services in package.json are documented in THIRD_PARTY_INTEGRATIONS.md
|
|
1189
|
+
- Environment variables in code are documented in INFRA_CONTRACT.md
|
|
1190
|
+
|
|
1191
|
+
**Output:**
|
|
1192
|
+
- List of items in code but missing from contracts
|
|
1193
|
+
- List of items in contracts but missing from code
|
|
1194
|
+
- Compliance status (pass/fail)
|
|
1195
|
+
|
|
1196
|
+
**Strict mode for CI/CD:**
|
|
1197
|
+
|
|
1198
|
+
```bash
|
|
1199
|
+
node scripts/contract-automation/check-compliance.js --strict
|
|
1200
|
+
```
|
|
1201
|
+
|
|
1202
|
+
Exits with error code 1 if any discrepancies found.
|
|
1203
|
+
|
|
1204
|
+
### DevOps Agent Responsibilities
|
|
1205
|
+
|
|
1206
|
+
**The DevOps Agent MUST:**
|
|
1207
|
+
|
|
1208
|
+
1. **Generate contracts** when setting up a new project or after major changes
|
|
1209
|
+
2. **Validate commit messages** before allowing commits
|
|
1210
|
+
3. **Alert users** if contract flags don't match actual changes
|
|
1211
|
+
4. **Run compliance checks** periodically (weekly recommended)
|
|
1212
|
+
5. **Report discrepancies** between code and contracts
|
|
1213
|
+
6. **Suggest fixes** when validation fails
|
|
1214
|
+
|
|
1215
|
+
**The DevOps Agent CAN:**
|
|
1216
|
+
|
|
1217
|
+
1. **Execute local scanning** without LLM for fast discovery
|
|
1218
|
+
2. **Use Groq LLM** for intelligent analysis and recommendations
|
|
1219
|
+
3. **Auto-fix commit messages** with correct contract flags
|
|
1220
|
+
4. **Generate JSON reports** for programmatic processing
|
|
1221
|
+
5. **Integrate with CI/CD** pipelines for automated validation
|
|
1222
|
+
|
|
1223
|
+
### LLM Integration (Groq)
|
|
1224
|
+
|
|
1225
|
+
**The DevOps Agent can use Groq LLM via OpenAI-compatible API:**
|
|
1226
|
+
|
|
1227
|
+
**Available Models:**
|
|
1228
|
+
- `llama-3.1-70b-versatile` (default) - Best for complex analysis
|
|
1229
|
+
- `llama-3.1-8b-instant` - Faster, good for simple tasks
|
|
1230
|
+
- `mixtral-8x7b-32768` - Alternative with large context window
|
|
1231
|
+
- `gemini-2.5-flash` - Fast and efficient
|
|
1232
|
+
|
|
1233
|
+
**Environment Variable:**
|
|
1234
|
+
- `OPENAI_API_KEY` - Set to Groq API key (already configured in sandbox)
|
|
1235
|
+
|
|
1236
|
+
**Use Cases:**
|
|
1237
|
+
- Analyze code files and extract documentation
|
|
1238
|
+
- Generate feature descriptions and user stories
|
|
1239
|
+
- Infer API request/response formats
|
|
1240
|
+
- Validate contract completeness
|
|
1241
|
+
- Provide security and performance recommendations
|
|
1242
|
+
|
|
1243
|
+
**Cost Optimization:**
|
|
1244
|
+
- Use local scanning first (free, fast)
|
|
1245
|
+
- Use LLM only for enhancement and validation
|
|
1246
|
+
- Cache LLM results to avoid redundant calls
|
|
1247
|
+
|
|
1248
|
+
### Hybrid Approach (Recommended)
|
|
1249
|
+
|
|
1250
|
+
**Combine local scanning + LLM analysis for best results:**
|
|
1251
|
+
|
|
1252
|
+
1. **Local scanning** (fast, deterministic)
|
|
1253
|
+
- Extract structured data (tables, endpoints, queries)
|
|
1254
|
+
- Pattern matching and regex
|
|
1255
|
+
- File system operations
|
|
1256
|
+
|
|
1257
|
+
2. **LLM analysis** (intelligent, contextual)
|
|
1258
|
+
- Generate human-readable descriptions
|
|
1259
|
+
- Infer relationships and dependencies
|
|
1260
|
+
- Provide recommendations
|
|
1261
|
+
- Validate completeness
|
|
1262
|
+
|
|
1263
|
+
3. **Manual review** (human oversight)
|
|
1264
|
+
- Review generated content
|
|
1265
|
+
- Fill in gaps
|
|
1266
|
+
- Verify accuracy
|
|
1267
|
+
- Make final decisions
|
|
1268
|
+
|
|
1269
|
+
### CI/CD Integration Example
|
|
1270
|
+
|
|
1271
|
+
```yaml
|
|
1272
|
+
# .github/workflows/contract-validation.yml
|
|
1273
|
+
name: Contract Validation
|
|
1274
|
+
|
|
1275
|
+
on: [pull_request]
|
|
1276
|
+
|
|
1277
|
+
jobs:
|
|
1278
|
+
validate:
|
|
1279
|
+
runs-on: ubuntu-latest
|
|
1280
|
+
steps:
|
|
1281
|
+
- uses: actions/checkout@v2
|
|
1282
|
+
- uses: actions/setup-node@v2
|
|
1283
|
+
|
|
1284
|
+
- name: Install Dependencies
|
|
1285
|
+
run: npm install
|
|
1286
|
+
|
|
1287
|
+
- name: Check Contract Compliance
|
|
1288
|
+
run: node scripts/contract-automation/check-compliance.js --strict --report=json
|
|
1289
|
+
|
|
1290
|
+
- name: Validate Commit Message
|
|
1291
|
+
run: |
|
|
1292
|
+
git log -1 --pretty=%B > commit-msg.txt
|
|
1293
|
+
node scripts/contract-automation/validate-commit.js --commit-msg=commit-msg.txt --check-staged
|
|
1294
|
+
```
|
|
1295
|
+
|
|
1296
|
+
### Troubleshooting
|
|
1297
|
+
|
|
1298
|
+
**Issue: "Contract directory not found"**
|
|
1299
|
+
|
|
1300
|
+
Solution: Merge the contract system branch first:
|
|
1301
|
+
```bash
|
|
1302
|
+
git merge origin/0212_SDD_Manus_HouseFilesUpgrade
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
**Issue: "OPENAI_API_KEY not set"**
|
|
1306
|
+
|
|
1307
|
+
Solution: Already set in sandbox environment. For local development:
|
|
1308
|
+
```bash
|
|
1309
|
+
export OPENAI_API_KEY="your-groq-api-key"
|
|
1310
|
+
```
|
|
1311
|
+
|
|
1312
|
+
**Issue: "No files found"**
|
|
1313
|
+
|
|
1314
|
+
Solution: Run from repository root:
|
|
1315
|
+
```bash
|
|
1316
|
+
cd /path/to/CS_DevOpsAgent
|
|
1317
|
+
node scripts/contract-automation/generate-contracts.js
|
|
1318
|
+
```
|
|
1319
|
+
|
|
1320
|
+
### Best Practices
|
|
1321
|
+
|
|
1322
|
+
1. **Run contract generation** after major feature additions
|
|
1323
|
+
2. **Validate commits** before pushing to prevent issues
|
|
1324
|
+
3. **Check compliance weekly** to keep contracts up-to-date
|
|
1325
|
+
4. **Use LLM sparingly** to minimize API costs
|
|
1326
|
+
5. **Review auto-generated content** before committing
|
|
1327
|
+
6. **Document exceptions** when automation can't handle something
|
|
1328
|
+
7. **Keep scripts updated** as codebase evolves
|
|
1329
|
+
|
|
1330
|
+
### Future Enhancements
|
|
1331
|
+
|
|
1332
|
+
**Planned features:**
|
|
1333
|
+
- Auto-fix for compliance issues
|
|
1334
|
+
- Visual HTML reports with charts
|
|
1335
|
+
- Git hooks for pre-commit validation
|
|
1336
|
+
- VSCode extension for real-time validation
|
|
1337
|
+
- Contract versioning and diff tool
|
|
1338
|
+
- Dependency graph visualization
|
|
1339
|
+
- Dashboard for contract status
|
|
1340
|
+
|
|
1341
|
+
---
|
|
1342
|
+
|
|
1343
|
+
**Last Updated:** 2024-12-02
|
|
1344
|
+
**Status:** ✅ Ready for use
|
|
1345
|
+
|
|
1346
|
+
|
|
1347
|
+
---
|
|
1348
|
+
|
|
1349
|
+
## 📋 DevOps Agent Change Workflow (NEW: 2024-12-16)
|
|
1350
|
+
|
|
1351
|
+
**This section provides a step-by-step workflow for DevOps Agents to handle change requests while adhering to the House Rules Contract System.**
|
|
1352
|
+
|
|
1353
|
+
### Objective
|
|
1354
|
+
|
|
1355
|
+
Implement changes to the codebase while strictly adhering to the House Rules Contract System to prevent conflicts and ensure consistency across all development activities.
|
|
1356
|
+
|
|
1357
|
+
### Context
|
|
1358
|
+
|
|
1359
|
+
As a DevOps Agent, you are responsible for maintaining the integrity of the microservices architecture. Before writing any code, you MUST follow the contract system to ensure coordination with other agents and prevent duplicate work.
|
|
1360
|
+
|
|
1361
|
+
### Step-by-Step Change Process
|
|
1362
|
+
|
|
1363
|
+
See the comprehensive workflow documentation in `House_Rules_Contracts/README.md` for detailed examples including:
|
|
1364
|
+
|
|
1365
|
+
- How to understand change requests
|
|
1366
|
+
- How to consult contracts before coding
|
|
1367
|
+
- How to analyze and decide whether to reuse or create
|
|
1368
|
+
- How to implement changes following contracts
|
|
1369
|
+
- How to update contracts after changes
|
|
1370
|
+
- How to commit with proper contract flags
|
|
1371
|
+
|
|
1372
|
+
### Quick Reference
|
|
1373
|
+
|
|
1374
|
+
**Before you code, ask yourself:**
|
|
1375
|
+
|
|
1376
|
+
- 📋 "Does this feature already exist?" → Check `FEATURES_CONTRACT.md`
|
|
1377
|
+
- 🔌 "Does this API endpoint already exist?" → Check `API_CONTRACT.md`
|
|
1378
|
+
- 🗄️ "Does this database table already exist?" → Check `DATABASE_SCHEMA_CONTRACT.md`
|
|
1379
|
+
- 📝 "Does this SQL query already exist?" → Check `SQL_CONTRACT.json`
|
|
1380
|
+
- 🌐 "Is this service already integrated?" → Check `THIRD_PARTY_INTEGRATIONS.md`
|
|
1381
|
+
- ⚙️ "Does this env variable already exist?" → Check `INFRA_CONTRACT.md`
|
|
1382
|
+
|
|
1383
|
+
**If YES → REUSE IT**
|
|
1384
|
+
**If NO → CREATE IT and DOCUMENT IT**
|
|
1385
|
+
|
|
1386
|
+
### Mandatory Commit Format
|
|
1387
|
+
|
|
1388
|
+
```
|
|
1389
|
+
<type>(<scope>): <subject>
|
|
1390
|
+
|
|
1391
|
+
Contracts: [SQL:T/F, API:T/F, DB:T/F, 3RD:T/F, FEAT:T/F, INFRA:T/F]
|
|
1392
|
+
|
|
1393
|
+
[WHY]
|
|
1394
|
+
<explanation of motivation>
|
|
1395
|
+
|
|
1396
|
+
[WHAT]
|
|
1397
|
+
- File(s): <path> - <description>
|
|
1398
|
+
- File(s): <path> - <description>
|
|
1399
|
+
|
|
1400
|
+
Resolves: [Task ID or Issue Number]
|
|
1401
|
+
Part of: House Rules Contract System
|
|
1402
|
+
```
|
|
1403
|
+
|
|
1404
|
+
### Validation Before Commit
|
|
1405
|
+
|
|
1406
|
+
```bash
|
|
1407
|
+
# Validate commit message and contract flags
|
|
1408
|
+
node scripts/contract-automation/validate-commit.js --check-staged --auto-fix
|
|
1409
|
+
|
|
1410
|
+
# If validation passes, commit and push
|
|
1411
|
+
git commit -F .claude-commit-msg
|
|
1412
|
+
git push origin <branch-name>
|
|
1413
|
+
```
|
|
1414
|
+
|
|
1415
|
+
### Critical Reminders
|
|
1416
|
+
|
|
1417
|
+
**DO:**
|
|
1418
|
+
|
|
1419
|
+
✅ Always check contracts BEFORE coding
|
|
1420
|
+
✅ Reuse existing components when possible
|
|
1421
|
+
✅ Document ALL changes in contracts immediately
|
|
1422
|
+
✅ Use the mandatory commit message format
|
|
1423
|
+
✅ Validate commits before pushing
|
|
1424
|
+
✅ Increment version numbers appropriately
|
|
1425
|
+
✅ Add comprehensive changelog entries
|
|
1426
|
+
✅ Cross-reference related contracts
|
|
1427
|
+
|
|
1428
|
+
**DON'T:**
|
|
1429
|
+
|
|
1430
|
+
❌ Create duplicate features/APIs/queries
|
|
1431
|
+
❌ Skip contract consultation
|
|
1432
|
+
❌ Forget to update contracts after coding
|
|
1433
|
+
❌ Use incorrect commit message format
|
|
1434
|
+
❌ Push without validation
|
|
1435
|
+
❌ Make breaking changes without documentation
|
|
1436
|
+
❌ Ignore existing implementations
|
|
1437
|
+
❌ Work in isolation from other agents
|
|
1438
|
+
|
|
1439
|
+
---
|
|
1440
|
+
|
|
1441
|
+
**Last Updated:** 2024-12-16
|
|
1442
|
+
**Status:** ✅ Ready for use
|