@jaguilar87/gaia-ops 1.0.0
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/CHANGELOG.md +315 -0
- package/CLAUDE.md +154 -0
- package/LICENSE +21 -0
- package/README.md +221 -0
- package/agents/aws-troubleshooter.md +50 -0
- package/agents/claude-architect.md +821 -0
- package/agents/devops-developer.md +92 -0
- package/agents/gcp-troubleshooter.md +50 -0
- package/agents/gitops-operator.md +360 -0
- package/agents/terraform-architect.md +289 -0
- package/bin/gaia-init.js +620 -0
- package/commands/architect.md +97 -0
- package/commands/restore-session.md +87 -0
- package/commands/save-session.md +88 -0
- package/commands/session-status.md +61 -0
- package/commands/speckit.add-task.md +144 -0
- package/commands/speckit.analyze-task.md +65 -0
- package/commands/speckit.implement.md +96 -0
- package/commands/speckit.init.md +237 -0
- package/commands/speckit.plan.md +88 -0
- package/commands/speckit.specify.md +161 -0
- package/commands/speckit.tasks.md +188 -0
- package/config/AGENTS.md +162 -0
- package/config/agent-catalog.md +604 -0
- package/config/context-contracts.md +682 -0
- package/config/git-standards.md +674 -0
- package/config/git_standards.json +69 -0
- package/config/orchestration-workflow.md +735 -0
- package/hooks/__pycache__/post_tool_use.cpython-312.pyc +0 -0
- package/hooks/__pycache__/pre_kubectl_security.cpython-312.pyc +0 -0
- package/hooks/__pycache__/pre_tool_use.cpython-312.pyc +0 -0
- package/hooks/__pycache__/session_start.cpython-312.pyc +0 -0
- package/hooks/__pycache__/subagent_stop.cpython-312.pyc +0 -0
- package/hooks/post_tool_use.py +463 -0
- package/hooks/pre_kubectl_security.py +205 -0
- package/hooks/pre_tool_use.py +530 -0
- package/hooks/session_start.py +315 -0
- package/hooks/subagent_stop.py +549 -0
- package/index.js +92 -0
- package/package.json +59 -0
- package/speckit/README.en.md +648 -0
- package/speckit/README.md +353 -0
- package/speckit/governance.md +169 -0
- package/speckit/scripts/check-prerequisites.sh +194 -0
- package/speckit/scripts/common.sh +126 -0
- package/speckit/scripts/create-new-feature.sh +131 -0
- package/speckit/scripts/init.sh +42 -0
- package/speckit/scripts/setup-plan.sh +95 -0
- package/speckit/scripts/update-agent-context.sh +718 -0
- package/speckit/templates/adr-template.md +118 -0
- package/speckit/templates/agent-file-template.md +23 -0
- package/speckit/templates/plan-template.md +233 -0
- package/speckit/templates/spec-template.md +116 -0
- package/speckit/templates/tasks-template-bkp.md +136 -0
- package/speckit/templates/tasks-template.md +345 -0
- package/templates/CLAUDE.template.md +170 -0
- package/templates/code-examples/approval_gate_workflow.py +141 -0
- package/templates/code-examples/clarification_workflow.py +94 -0
- package/templates/code-examples/commit_validation.py +86 -0
- package/templates/project-context.template.json +126 -0
- package/templates/settings.template.json +307 -0
- package/tools/__pycache__/agent_router.cpython-312.pyc +0 -0
- package/tools/__pycache__/approval_gate.cpython-312.pyc +0 -0
- package/tools/__pycache__/clarify_engine.cpython-312.pyc +0 -0
- package/tools/__pycache__/clarify_patterns.cpython-312.pyc +0 -0
- package/tools/__pycache__/commit_validator.cpython-312.pyc +0 -0
- package/tools/__pycache__/context_section_reader.cpython-312.pyc +0 -0
- package/tools/__pycache__/routing_dashboard.cpython-312.pyc +0 -0
- package/tools/__pycache__/routing_feedback.cpython-312.pyc +0 -0
- package/tools/__pycache__/semantic_matcher.cpython-312.pyc +0 -0
- package/tools/__pycache__/task_manager.cpython-312.pyc +0 -0
- package/tools/agent_capabilities.json +231 -0
- package/tools/agent_invoker_helper.py +239 -0
- package/tools/agent_router.py +730 -0
- package/tools/approval_gate.py +318 -0
- package/tools/clarify_engine.py +511 -0
- package/tools/clarify_patterns.py +356 -0
- package/tools/commit_validator.py +338 -0
- package/tools/context_provider.py +181 -0
- package/tools/context_section_reader.py +301 -0
- package/tools/demo_clarify.py +104 -0
- package/tools/generate_embeddings.py +168 -0
- package/tools/quicktriage_aws_troubleshooter.sh +45 -0
- package/tools/quicktriage_devops_developer.sh +38 -0
- package/tools/quicktriage_gcp_troubleshooter.sh +51 -0
- package/tools/quicktriage_gitops_operator.sh +47 -0
- package/tools/quicktriage_terraform_architect.sh +40 -0
- package/tools/semantic_matcher.py +222 -0
- package/tools/task_manager.py +547 -0
- package/tools/task_manager_README.md +395 -0
- package/tools/task_manager_example.py +215 -0
|
@@ -0,0 +1,674 @@
|
|
|
1
|
+
# Git Commit Standards
|
|
2
|
+
|
|
3
|
+
**Version:** 2.0.0
|
|
4
|
+
**Last Updated:** 2025-11-07
|
|
5
|
+
**Parent:** CLAUDE.md
|
|
6
|
+
**Applies To:** Orchestrator AND all specialist agents
|
|
7
|
+
|
|
8
|
+
This document defines the universal commit message standards for this repository. ALL git commit operations MUST comply with these standards, regardless of who performs them (orchestrator or agent).
|
|
9
|
+
|
|
10
|
+
---
|
|
11
|
+
|
|
12
|
+
## Universal Validation Requirement
|
|
13
|
+
|
|
14
|
+
**CRITICAL:** Before EVERY `git commit`, the entity performing the commit (orchestrator or agent) MUST validate the commit message.
|
|
15
|
+
|
|
16
|
+
### Validation Code (MANDATORY)
|
|
17
|
+
|
|
18
|
+
```python
|
|
19
|
+
import sys
|
|
20
|
+
sys.path.insert(0, '/home/jaguilar/aaxis/rnd/repositories/.claude/tools')
|
|
21
|
+
from commit_validator import safe_validate_before_commit
|
|
22
|
+
|
|
23
|
+
# Validate commit message
|
|
24
|
+
if not safe_validate_before_commit(commit_message):
|
|
25
|
+
# Validation failed - errors already printed to stderr
|
|
26
|
+
return {
|
|
27
|
+
"status": "failed",
|
|
28
|
+
"reason": "commit_message_validation_failed"
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
# Only if validation passes:
|
|
32
|
+
# Proceed with git commit
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
**Why this is mandatory:**
|
|
36
|
+
- Ensures consistency across all commit sources (orchestrator, agents)
|
|
37
|
+
- Enforces repository standards programmatically
|
|
38
|
+
- Logs violations for audit trail
|
|
39
|
+
- Prevents non-compliant commits from entering history
|
|
40
|
+
|
|
41
|
+
---
|
|
42
|
+
|
|
43
|
+
## Commit Message Format
|
|
44
|
+
|
|
45
|
+
### Standard: Conventional Commits
|
|
46
|
+
|
|
47
|
+
We use the [Conventional Commits](https://www.conventionalcommits.org/) specification.
|
|
48
|
+
|
|
49
|
+
**Format:**
|
|
50
|
+
```
|
|
51
|
+
<type>(<scope>): <description>
|
|
52
|
+
|
|
53
|
+
[optional body]
|
|
54
|
+
|
|
55
|
+
[optional footer]
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
**Example:**
|
|
59
|
+
```
|
|
60
|
+
feat(helmrelease): add Phase 3.3 services
|
|
61
|
+
|
|
62
|
+
Deploys tcm-api and pg-query-api to non-prod-rnd cluster.
|
|
63
|
+
Includes HelmRelease configurations and health checks.
|
|
64
|
+
|
|
65
|
+
Refs: #234
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
---
|
|
69
|
+
|
|
70
|
+
## Type (Required)
|
|
71
|
+
|
|
72
|
+
The commit type MUST be one of the following:
|
|
73
|
+
|
|
74
|
+
| Type | Description | Example |
|
|
75
|
+
|------|-------------|---------|
|
|
76
|
+
| `feat` | New feature | `feat(api): add user authentication` |
|
|
77
|
+
| `fix` | Bug fix | `fix(pg-api): correct database connection timeout` |
|
|
78
|
+
| `refactor` | Code refactoring (no functional change) | `refactor(context): simplify enrichment logic` |
|
|
79
|
+
| `docs` | Documentation changes | `docs(readme): update installation instructions` |
|
|
80
|
+
| `test` | Test additions/modifications | `test(router): add agent selection tests` |
|
|
81
|
+
| `chore` | Maintenance tasks | `chore(deps): update kubectl to v1.28` |
|
|
82
|
+
| `ci` | CI/CD changes | `ci(github): add terraform validation workflow` |
|
|
83
|
+
| `perf` | Performance improvements | `perf(query): optimize database index usage` |
|
|
84
|
+
| `style` | Code style changes (formatting, semicolons, etc.) | `style(hooks): format with black` |
|
|
85
|
+
| `build` | Build system changes | `build(docker): update base image to alpine 3.19` |
|
|
86
|
+
|
|
87
|
+
**Invalid types will be REJECTED by commit_validator.py**
|
|
88
|
+
|
|
89
|
+
---
|
|
90
|
+
|
|
91
|
+
## Scope (Optional but Recommended)
|
|
92
|
+
|
|
93
|
+
The scope provides additional context about what part of the codebase is affected.
|
|
94
|
+
|
|
95
|
+
**Common scopes in this repository:**
|
|
96
|
+
|
|
97
|
+
### Infrastructure/GitOps
|
|
98
|
+
- `helmrelease`: HelmRelease manifests
|
|
99
|
+
- `deployment`: Kubernetes Deployment resources
|
|
100
|
+
- `service`: Kubernetes Service resources
|
|
101
|
+
- `ingress`: Kubernetes Ingress resources
|
|
102
|
+
- `configmap`: ConfigMaps
|
|
103
|
+
- `secret`: Secrets
|
|
104
|
+
- `namespace`: Namespace configurations
|
|
105
|
+
|
|
106
|
+
### Terraform
|
|
107
|
+
- `terraform`: General terraform changes
|
|
108
|
+
- `gke`: GKE cluster configuration
|
|
109
|
+
- `cloudsql`: CloudSQL instances
|
|
110
|
+
- `vpc`: VPC networking
|
|
111
|
+
- `iam`: IAM policies
|
|
112
|
+
|
|
113
|
+
### Agent System
|
|
114
|
+
- `orchestrator`: Orchestrator logic (CLAUDE.md)
|
|
115
|
+
- `agent`: Agent definitions
|
|
116
|
+
- `router`: Agent routing logic
|
|
117
|
+
- `context`: Context provider
|
|
118
|
+
- `approval`: Approval gate
|
|
119
|
+
- `clarify`: Clarification engine
|
|
120
|
+
|
|
121
|
+
### Services (use service name)
|
|
122
|
+
- `tcm-api`: TCM API service
|
|
123
|
+
- `pg-api`: PG API service
|
|
124
|
+
- `pg-query-api`: PG Query API service
|
|
125
|
+
- `tcm-admin-ui`: TCM Admin UI service
|
|
126
|
+
|
|
127
|
+
**Scope format:**
|
|
128
|
+
- Lowercase
|
|
129
|
+
- Hyphenated (not camelCase or snake_case)
|
|
130
|
+
- Singular (not plural): `deployment` not `deployments`
|
|
131
|
+
|
|
132
|
+
---
|
|
133
|
+
|
|
134
|
+
## Description (Required)
|
|
135
|
+
|
|
136
|
+
The description is a short summary of the change.
|
|
137
|
+
|
|
138
|
+
**Rules:**
|
|
139
|
+
- Maximum 72 characters (commit_validator.py enforces this)
|
|
140
|
+
- Start with lowercase letter
|
|
141
|
+
- Use imperative mood ("add feature" NOT "added feature" or "adds feature")
|
|
142
|
+
- No period at the end
|
|
143
|
+
- Be concise but descriptive
|
|
144
|
+
|
|
145
|
+
**Good Examples:**
|
|
146
|
+
```
|
|
147
|
+
add Phase 3.3 services to non-prod cluster
|
|
148
|
+
correct API key environment variable mappings
|
|
149
|
+
simplify context provider enrichment logic
|
|
150
|
+
update kubectl version to 1.28.4
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
**Bad Examples:**
|
|
154
|
+
```
|
|
155
|
+
Added new feature. # ❌ Not imperative, has period
|
|
156
|
+
Update # ❌ Too vague
|
|
157
|
+
Adds the new user authentication feature to the API with JWT tokens and refresh logic # ❌ Too long (>72 chars)
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
---
|
|
161
|
+
|
|
162
|
+
## Body (Optional)
|
|
163
|
+
|
|
164
|
+
The body provides additional context about the change.
|
|
165
|
+
|
|
166
|
+
**When to include a body:**
|
|
167
|
+
- Change is non-obvious or requires explanation
|
|
168
|
+
- Breaking changes need documentation
|
|
169
|
+
- Multiple related changes in one commit
|
|
170
|
+
- References to issues, tickets, or external docs
|
|
171
|
+
|
|
172
|
+
**Format:**
|
|
173
|
+
- Separate from description with blank line
|
|
174
|
+
- Wrap at 72 characters per line
|
|
175
|
+
- Use bullet points for multiple items
|
|
176
|
+
- Explain "why" rather than "what" (code shows "what")
|
|
177
|
+
|
|
178
|
+
**Example:**
|
|
179
|
+
```
|
|
180
|
+
feat(pg-api): add connection pooling
|
|
181
|
+
|
|
182
|
+
Implements HikariCP connection pooling to reduce database
|
|
183
|
+
connection overhead. Configuration:
|
|
184
|
+
- Max pool size: 10
|
|
185
|
+
- Connection timeout: 30s
|
|
186
|
+
- Idle timeout: 600s
|
|
187
|
+
|
|
188
|
+
This resolves intermittent "too many connections" errors
|
|
189
|
+
observed in non-prod environment.
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
---
|
|
193
|
+
|
|
194
|
+
## Footer (Optional)
|
|
195
|
+
|
|
196
|
+
Footers provide metadata about the commit.
|
|
197
|
+
|
|
198
|
+
### Allowed Footers
|
|
199
|
+
|
|
200
|
+
| Footer | Purpose | Example |
|
|
201
|
+
|--------|---------|---------|
|
|
202
|
+
| `BREAKING CHANGE:` | Indicates incompatible API change | `BREAKING CHANGE: remove deprecated /v1/users endpoint` |
|
|
203
|
+
| `Refs:` | References issue/ticket | `Refs: #234, #235` |
|
|
204
|
+
| `Closes:` | Closes issue/ticket | `Closes: #123` |
|
|
205
|
+
| `Fixes:` | Fixes issue/ticket | `Fixes: #456` |
|
|
206
|
+
| `Implements:` | Implements feature spec | `Implements: SPEC-789` |
|
|
207
|
+
| `See:` | Links to external resource | `See: https://docs.example.com/api-v2` |
|
|
208
|
+
|
|
209
|
+
**Format:**
|
|
210
|
+
- Each footer on separate line
|
|
211
|
+
- Footer key followed by colon and space
|
|
212
|
+
- Multiple values separated by commas
|
|
213
|
+
|
|
214
|
+
**Example:**
|
|
215
|
+
```
|
|
216
|
+
feat(api): add v2 endpoints
|
|
217
|
+
|
|
218
|
+
Refs: #234, #235
|
|
219
|
+
Implements: SPEC-789
|
|
220
|
+
BREAKING CHANGE: /v1/users endpoint removed, use /v2/users
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
---
|
|
224
|
+
|
|
225
|
+
### Forbidden Footers
|
|
226
|
+
|
|
227
|
+
**CRITICAL:** The following footers are FORBIDDEN and will cause validation to FAIL:
|
|
228
|
+
|
|
229
|
+
1. **Claude Code Attribution:**
|
|
230
|
+
```
|
|
231
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
2. **Claude Co-Author:**
|
|
235
|
+
```
|
|
236
|
+
Co-Authored-By: Claude <noreply@anthropic.com>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
3. **Any variant:**
|
|
240
|
+
- `Generated with Claude Code`
|
|
241
|
+
- `Co-Authored-By: Claude`
|
|
242
|
+
- Any line containing "Claude Code" or "Co-Authored-By: Claude"
|
|
243
|
+
|
|
244
|
+
**Reason:** This repository's policy is to NOT attribute AI-generated code in commit messages. Attribution happens at repository level (README, CLAUDE.md), not per-commit.
|
|
245
|
+
|
|
246
|
+
**Enforcement:** `commit_validator.py` scans commit message and REJECTS any commit with forbidden footers.
|
|
247
|
+
|
|
248
|
+
---
|
|
249
|
+
|
|
250
|
+
## Subject Line Rules (Enforced)
|
|
251
|
+
|
|
252
|
+
The subject line (type + scope + description) MUST comply with:
|
|
253
|
+
|
|
254
|
+
1. **Maximum length:** 72 characters
|
|
255
|
+
2. **No period:** Subject must not end with `.`
|
|
256
|
+
3. **Imperative mood:** "add" not "added" or "adds"
|
|
257
|
+
4. **Lowercase description:** First word of description is lowercase (unless proper noun)
|
|
258
|
+
|
|
259
|
+
**Validation:**
|
|
260
|
+
```python
|
|
261
|
+
# commit_validator.py checks:
|
|
262
|
+
if len(subject) > 72:
|
|
263
|
+
return False, "Subject line exceeds 72 characters"
|
|
264
|
+
|
|
265
|
+
if subject.endswith('.'):
|
|
266
|
+
return False, "Subject line must not end with period"
|
|
267
|
+
|
|
268
|
+
if not is_imperative_mood(description):
|
|
269
|
+
return False, "Use imperative mood (add, fix, update)"
|
|
270
|
+
```
|
|
271
|
+
|
|
272
|
+
---
|
|
273
|
+
|
|
274
|
+
## Examples
|
|
275
|
+
|
|
276
|
+
### Valid Commits
|
|
277
|
+
|
|
278
|
+
**Simple feature:**
|
|
279
|
+
```
|
|
280
|
+
feat(helmrelease): add Phase 3.3 services
|
|
281
|
+
```
|
|
282
|
+
|
|
283
|
+
**Bug fix with body:**
|
|
284
|
+
```
|
|
285
|
+
fix(pg-non-prod): correct API key environment variable mappings
|
|
286
|
+
|
|
287
|
+
The API_KEY variable was pointing to wrong secret key.
|
|
288
|
+
Updated to use pg-api-credentials.api-key instead of
|
|
289
|
+
tcm-api-credentials.api-key.
|
|
290
|
+
|
|
291
|
+
Fixes: #345
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
**Refactoring with explanation:**
|
|
295
|
+
```
|
|
296
|
+
refactor(context): simplify enrichment logic
|
|
297
|
+
|
|
298
|
+
Replaces nested loops with dictionary comprehension for
|
|
299
|
+
service correlation. Improves performance by ~40% on
|
|
300
|
+
large project-context.json files.
|
|
301
|
+
|
|
302
|
+
No functional changes.
|
|
303
|
+
```
|
|
304
|
+
|
|
305
|
+
**Breaking change:**
|
|
306
|
+
```
|
|
307
|
+
feat(api): migrate to v2 endpoints
|
|
308
|
+
|
|
309
|
+
Updates all API routes to /v2 prefix with new request/response
|
|
310
|
+
formats. Deprecates v1 endpoints (to be removed in 3 months).
|
|
311
|
+
|
|
312
|
+
BREAKING CHANGE: /v1/users endpoint removed, use /v2/users
|
|
313
|
+
Refs: #567
|
|
314
|
+
See: https://docs.example.com/api-v2-migration
|
|
315
|
+
```
|
|
316
|
+
|
|
317
|
+
**Documentation:**
|
|
318
|
+
```
|
|
319
|
+
docs(claude): refactor CLAUDE.md to modular structure
|
|
320
|
+
|
|
321
|
+
Splits 380-line monolith into:
|
|
322
|
+
- CLAUDE.md (core instructions, 150 lines)
|
|
323
|
+
- orchestration-workflow.md (phases 0-5)
|
|
324
|
+
- git-standards.md (this file)
|
|
325
|
+
- context-contracts.md
|
|
326
|
+
- agent-catalog.md
|
|
327
|
+
|
|
328
|
+
Refs: #890
|
|
329
|
+
```
|
|
330
|
+
|
|
331
|
+
---
|
|
332
|
+
|
|
333
|
+
### Invalid Commits (Will Be Rejected)
|
|
334
|
+
|
|
335
|
+
**Bad type:**
|
|
336
|
+
```
|
|
337
|
+
added(helmrelease): add Phase 3.3 services
|
|
338
|
+
# ❌ Invalid type: "added" (should be "feat")
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
**Too long:**
|
|
342
|
+
```
|
|
343
|
+
feat(helmrelease): add Phase 3.3 services including tcm-api, pg-query-api, and pg-admin-ui to non-prod-rnd cluster
|
|
344
|
+
# ❌ Subject exceeds 72 characters
|
|
345
|
+
```
|
|
346
|
+
|
|
347
|
+
**Period at end:**
|
|
348
|
+
```
|
|
349
|
+
feat(helmrelease): add Phase 3.3 services.
|
|
350
|
+
# ❌ Subject ends with period
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
**Not imperative:**
|
|
354
|
+
```
|
|
355
|
+
feat(helmrelease): added Phase 3.3 services
|
|
356
|
+
# ❌ Not imperative mood ("added" should be "add")
|
|
357
|
+
```
|
|
358
|
+
|
|
359
|
+
**Forbidden footer:**
|
|
360
|
+
```
|
|
361
|
+
feat(helmrelease): add Phase 3.3 services
|
|
362
|
+
|
|
363
|
+
🤖 Generated with [Claude Code](https://claude.com/claude-code)
|
|
364
|
+
# ❌ Forbidden footer
|
|
365
|
+
```
|
|
366
|
+
|
|
367
|
+
**Wrong mood:**
|
|
368
|
+
```
|
|
369
|
+
fix(pg-api): fixes the database timeout issue
|
|
370
|
+
# ❌ Not imperative ("fixes" should be "fix")
|
|
371
|
+
```
|
|
372
|
+
|
|
373
|
+
---
|
|
374
|
+
|
|
375
|
+
## Configuration
|
|
376
|
+
|
|
377
|
+
Standards are defined in JSON schema: `.claude/config/git_standards.json`
|
|
378
|
+
|
|
379
|
+
**Schema:**
|
|
380
|
+
```json
|
|
381
|
+
{
|
|
382
|
+
"allowed_types": ["feat", "fix", "refactor", "docs", "test", "chore", "ci", "perf", "style", "build"],
|
|
383
|
+
"max_subject_length": 72,
|
|
384
|
+
"forbidden_footers": [
|
|
385
|
+
"Generated with [Claude Code]",
|
|
386
|
+
"Co-Authored-By: Claude"
|
|
387
|
+
],
|
|
388
|
+
"imperative_mood_required": true,
|
|
389
|
+
"scope_format": "lowercase-hyphenated"
|
|
390
|
+
}
|
|
391
|
+
```
|
|
392
|
+
|
|
393
|
+
**Modifying standards:**
|
|
394
|
+
1. Edit `.claude/config/git_standards.json`
|
|
395
|
+
2. Run validation tests: `pytest .claude/tests/test_commit_validator.py`
|
|
396
|
+
3. Update this document to reflect changes
|
|
397
|
+
4. Increment version number in frontmatter
|
|
398
|
+
|
|
399
|
+
---
|
|
400
|
+
|
|
401
|
+
## Violation Logging
|
|
402
|
+
|
|
403
|
+
All commit validation violations are logged to: `.claude/logs/commit-violations.jsonl`
|
|
404
|
+
|
|
405
|
+
**Log Entry Format:**
|
|
406
|
+
```json
|
|
407
|
+
{
|
|
408
|
+
"timestamp": "2025-11-07T15:42:33Z",
|
|
409
|
+
"commit_message": "added new feature.",
|
|
410
|
+
"violations": [
|
|
411
|
+
{"type": "invalid_type", "message": "Type 'added' is not allowed"},
|
|
412
|
+
{"type": "subject_format", "message": "Subject ends with period"}
|
|
413
|
+
],
|
|
414
|
+
"source": "orchestrator",
|
|
415
|
+
"rejected": true
|
|
416
|
+
}
|
|
417
|
+
```
|
|
418
|
+
|
|
419
|
+
**Uses:**
|
|
420
|
+
- Audit trail of rejected commits
|
|
421
|
+
- Analysis of common mistakes
|
|
422
|
+
- Training data for improving commit message generation
|
|
423
|
+
- Compliance reporting
|
|
424
|
+
|
|
425
|
+
---
|
|
426
|
+
|
|
427
|
+
## Git Operations: Who Does What
|
|
428
|
+
|
|
429
|
+
### Orchestrator-Level Commits
|
|
430
|
+
|
|
431
|
+
The orchestrator performs git commits for:
|
|
432
|
+
- **Ad-hoc commits** (user: "commitea los cambios")
|
|
433
|
+
- **Standalone operations** (user: "crea un PR")
|
|
434
|
+
- **Simple changes** (not part of infrastructure workflow)
|
|
435
|
+
|
|
436
|
+
**Process:**
|
|
437
|
+
1. Generate commit message (following standards)
|
|
438
|
+
2. Validate with `commit_validator.py`
|
|
439
|
+
3. If valid: Execute `git add`, `git commit`
|
|
440
|
+
4. If invalid: Report violations to user, regenerate
|
|
441
|
+
|
|
442
|
+
---
|
|
443
|
+
|
|
444
|
+
### Agent-Level Commits
|
|
445
|
+
|
|
446
|
+
Specialist agents perform git commits for:
|
|
447
|
+
- **Infrastructure workflows** (Phase 5 realization)
|
|
448
|
+
- **Deployment operations** (gitops-operator)
|
|
449
|
+
- **Terraform changes** (terraform-architect)
|
|
450
|
+
- **Complex multi-step workflows** (part of larger operation)
|
|
451
|
+
|
|
452
|
+
**Process:**
|
|
453
|
+
1. Receive realization package with commit message
|
|
454
|
+
2. Validate commit message with `commit_validator.py`
|
|
455
|
+
3. If valid: Execute `git add`, `git commit`, `git push`
|
|
456
|
+
4. If invalid: Fail realization, report to orchestrator
|
|
457
|
+
|
|
458
|
+
**Same validation applies:** Agents use identical validation logic.
|
|
459
|
+
|
|
460
|
+
---
|
|
461
|
+
|
|
462
|
+
## Integration with Tools
|
|
463
|
+
|
|
464
|
+
### commit_validator.py
|
|
465
|
+
|
|
466
|
+
Located at: `/home/jaguilar/aaxis/rnd/repositories/.claude/tools/commit_validator.py`
|
|
467
|
+
|
|
468
|
+
**Functions:**
|
|
469
|
+
|
|
470
|
+
```python
|
|
471
|
+
def safe_validate_before_commit(commit_message: str) -> bool:
|
|
472
|
+
"""
|
|
473
|
+
Validates commit message against standards.
|
|
474
|
+
|
|
475
|
+
Returns:
|
|
476
|
+
True if valid, False if invalid
|
|
477
|
+
|
|
478
|
+
Side effects:
|
|
479
|
+
- Prints errors to stderr
|
|
480
|
+
- Logs violations to commit-violations.jsonl
|
|
481
|
+
"""
|
|
482
|
+
|
|
483
|
+
def validate_commit_message(commit_message: str) -> tuple[bool, list[str]]:
|
|
484
|
+
"""
|
|
485
|
+
Validates commit message, returns detailed errors.
|
|
486
|
+
|
|
487
|
+
Returns:
|
|
488
|
+
(is_valid, list_of_error_messages)
|
|
489
|
+
"""
|
|
490
|
+
|
|
491
|
+
def is_imperative_mood(text: str) -> bool:
|
|
492
|
+
"""
|
|
493
|
+
Checks if text is in imperative mood.
|
|
494
|
+
|
|
495
|
+
Returns:
|
|
496
|
+
True if imperative, False otherwise
|
|
497
|
+
"""
|
|
498
|
+
```
|
|
499
|
+
|
|
500
|
+
**Usage in orchestrator:**
|
|
501
|
+
```python
|
|
502
|
+
from commit_validator import safe_validate_before_commit
|
|
503
|
+
|
|
504
|
+
msg = generate_commit_message(changes)
|
|
505
|
+
if not safe_validate_before_commit(msg):
|
|
506
|
+
# Regenerate or ask user
|
|
507
|
+
msg = regenerate_commit_message(changes, feedback)
|
|
508
|
+
if not safe_validate_before_commit(msg):
|
|
509
|
+
report_to_user("Cannot generate valid commit message")
|
|
510
|
+
return
|
|
511
|
+
|
|
512
|
+
# Proceed with commit
|
|
513
|
+
```
|
|
514
|
+
|
|
515
|
+
**Usage in agents:**
|
|
516
|
+
```python
|
|
517
|
+
from commit_validator import safe_validate_before_commit
|
|
518
|
+
|
|
519
|
+
# Realization package includes commit message
|
|
520
|
+
commit_msg = realization_package["git_operations"]["commit_message"]
|
|
521
|
+
|
|
522
|
+
if not safe_validate_before_commit(commit_msg):
|
|
523
|
+
return {
|
|
524
|
+
"status": "failed",
|
|
525
|
+
"reason": "commit_message_validation_failed",
|
|
526
|
+
"message": "Orchestrator provided invalid commit message"
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
# Proceed with git operations
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
---
|
|
533
|
+
|
|
534
|
+
### Pre-commit Hook Integration (Future)
|
|
535
|
+
|
|
536
|
+
**Future enhancement:** Integrate validation into git pre-commit hook.
|
|
537
|
+
|
|
538
|
+
**Benefit:** Catches violations even for manual git commits (outside Claude Code).
|
|
539
|
+
|
|
540
|
+
**Implementation:**
|
|
541
|
+
```bash
|
|
542
|
+
# .git/hooks/pre-commit
|
|
543
|
+
|
|
544
|
+
#!/bin/bash
|
|
545
|
+
COMMIT_MSG=$(git log -1 --pretty=%B)
|
|
546
|
+
python3 .claude/tools/commit_validator.py "$COMMIT_MSG"
|
|
547
|
+
if [ $? -ne 0 ]; then
|
|
548
|
+
echo "Commit message validation failed"
|
|
549
|
+
exit 1
|
|
550
|
+
fi
|
|
551
|
+
```
|
|
552
|
+
|
|
553
|
+
---
|
|
554
|
+
|
|
555
|
+
## Common Pitfalls
|
|
556
|
+
|
|
557
|
+
### Pitfall 1: Skipping Validation
|
|
558
|
+
|
|
559
|
+
**Symptom:** Non-compliant commits in git history
|
|
560
|
+
|
|
561
|
+
**Cause:** Entity (orchestrator or agent) executed `git commit` without calling `safe_validate_before_commit()`
|
|
562
|
+
|
|
563
|
+
**Fix:** Enforce validation in code (make commit_validator.py a hard dependency)
|
|
564
|
+
|
|
565
|
+
---
|
|
566
|
+
|
|
567
|
+
### Pitfall 2: Generating Non-Imperative Mood
|
|
568
|
+
|
|
569
|
+
**Symptom:** Commit messages like "added feature", "fixes bug"
|
|
570
|
+
|
|
571
|
+
**Cause:** LLM defaults to past tense or present tense
|
|
572
|
+
|
|
573
|
+
**Fix:** Explicitly instruct LLM: "Use imperative mood: add, fix, update (NOT added, fixed, updated)"
|
|
574
|
+
|
|
575
|
+
---
|
|
576
|
+
|
|
577
|
+
### Pitfall 3: Exceeding 72 Characters
|
|
578
|
+
|
|
579
|
+
**Symptom:** Commit messages truncated in git log, GitHub UI
|
|
580
|
+
|
|
581
|
+
**Cause:** LLM generates verbose descriptions
|
|
582
|
+
|
|
583
|
+
**Fix:** Count characters before validation, trim if necessary
|
|
584
|
+
|
|
585
|
+
---
|
|
586
|
+
|
|
587
|
+
### Pitfall 4: Including Forbidden Footers
|
|
588
|
+
|
|
589
|
+
**Symptom:** Commits rejected with "forbidden footer" error
|
|
590
|
+
|
|
591
|
+
**Cause:** Global Claude Code instructions add attribution footers
|
|
592
|
+
|
|
593
|
+
**Fix:** Override global instructions in CLAUDE.md with explicit "NO attribution footers"
|
|
594
|
+
|
|
595
|
+
---
|
|
596
|
+
|
|
597
|
+
### Pitfall 5: Vague Descriptions
|
|
598
|
+
|
|
599
|
+
**Symptom:** Commit messages like "update config", "fix bug"
|
|
600
|
+
|
|
601
|
+
**Cause:** Insufficient context provided to commit message generator
|
|
602
|
+
|
|
603
|
+
**Fix:** Analyze git diff, extract specific changes (file names, function names), include in description
|
|
604
|
+
|
|
605
|
+
---
|
|
606
|
+
|
|
607
|
+
## Testing Standards Compliance
|
|
608
|
+
|
|
609
|
+
### Manual Testing
|
|
610
|
+
|
|
611
|
+
```bash
|
|
612
|
+
# Test with sample commit messages
|
|
613
|
+
python3 .claude/tools/commit_validator.py "feat(helmrelease): add Phase 3.3 services"
|
|
614
|
+
# Expected: ✅ Valid
|
|
615
|
+
|
|
616
|
+
python3 .claude/tools/commit_validator.py "added new feature."
|
|
617
|
+
# Expected: ❌ Invalid (type, period)
|
|
618
|
+
```
|
|
619
|
+
|
|
620
|
+
### Automated Testing
|
|
621
|
+
|
|
622
|
+
```bash
|
|
623
|
+
# Run test suite
|
|
624
|
+
pytest .claude/tests/test_commit_validator.py -v
|
|
625
|
+
|
|
626
|
+
# Expected: 55+ tests, all passing
|
|
627
|
+
```
|
|
628
|
+
|
|
629
|
+
**Test categories:**
|
|
630
|
+
- Valid commit formats (10+ cases)
|
|
631
|
+
- Invalid types (5+ cases)
|
|
632
|
+
- Length violations (3+ cases)
|
|
633
|
+
- Forbidden footers (5+ cases)
|
|
634
|
+
- Imperative mood detection (10+ cases)
|
|
635
|
+
- Edge cases (special characters, unicode, etc.)
|
|
636
|
+
|
|
637
|
+
---
|
|
638
|
+
|
|
639
|
+
## Metrics
|
|
640
|
+
|
|
641
|
+
Track compliance metrics in `.claude/logs/commit-compliance.jsonl`:
|
|
642
|
+
|
|
643
|
+
- **Validation Pass Rate:** % of commit messages that pass validation on first attempt
|
|
644
|
+
- **Common Violations:** Top 5 validation errors
|
|
645
|
+
- **Source Distribution:** % of commits from orchestrator vs agents
|
|
646
|
+
- **Regeneration Rate:** % of commits that required regeneration after initial failure
|
|
647
|
+
|
|
648
|
+
**Target Thresholds:**
|
|
649
|
+
- Validation Pass Rate: >90%
|
|
650
|
+
- Regeneration Rate: <5%
|
|
651
|
+
|
|
652
|
+
---
|
|
653
|
+
|
|
654
|
+
## References
|
|
655
|
+
|
|
656
|
+
- **Conventional Commits Spec:** https://www.conventionalcommits.org/
|
|
657
|
+
- **Imperative Mood Guide:** https://chris.beams.io/posts/git-commit/#imperative
|
|
658
|
+
- **Git Commit Best Practices:** https://git-scm.com/book/en/v2/Distributed-Git-Contributing-to-a-Project
|
|
659
|
+
|
|
660
|
+
---
|
|
661
|
+
|
|
662
|
+
## Version History
|
|
663
|
+
|
|
664
|
+
### 2.0.0 (2025-11-07)
|
|
665
|
+
- Extracted from CLAUDE.md monolith
|
|
666
|
+
- Added comprehensive examples (valid and invalid)
|
|
667
|
+
- Clarified orchestrator vs agent responsibilities
|
|
668
|
+
- Added forbidden footers enforcement
|
|
669
|
+
- Added testing, metrics, pitfalls sections
|
|
670
|
+
|
|
671
|
+
### 1.x (Historical)
|
|
672
|
+
- Embedded in CLAUDE.md
|
|
673
|
+
- Basic Conventional Commits spec
|
|
674
|
+
- No automated validation
|