aios-core 4.0.2 → 4.0.4

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.
Files changed (145) hide show
  1. package/.aios-core/.session/current-session.json +14 -0
  2. package/.aios-core/core/registry/registry-schema.json +166 -166
  3. package/.aios-core/core/registry/service-registry.json +6585 -6585
  4. package/.aios-core/data/registry-update-log.jsonl +113 -0
  5. package/.aios-core/development/scripts/approval-workflow.js +642 -642
  6. package/.aios-core/development/scripts/backup-manager.js +606 -606
  7. package/.aios-core/development/scripts/branch-manager.js +389 -389
  8. package/.aios-core/development/scripts/code-quality-improver.js +1311 -1311
  9. package/.aios-core/development/scripts/commit-message-generator.js +849 -849
  10. package/.aios-core/development/scripts/conflict-resolver.js +674 -674
  11. package/.aios-core/development/scripts/dependency-analyzer.js +637 -637
  12. package/.aios-core/development/scripts/diff-generator.js +351 -351
  13. package/.aios-core/development/scripts/elicitation-engine.js +384 -384
  14. package/.aios-core/development/scripts/elicitation-session-manager.js +299 -299
  15. package/.aios-core/development/scripts/git-wrapper.js +461 -461
  16. package/.aios-core/development/scripts/manifest-preview.js +244 -244
  17. package/.aios-core/development/scripts/metrics-tracker.js +775 -775
  18. package/.aios-core/development/scripts/modification-validator.js +554 -554
  19. package/.aios-core/development/scripts/pattern-learner.js +1224 -1224
  20. package/.aios-core/development/scripts/performance-analyzer.js +757 -757
  21. package/.aios-core/development/scripts/refactoring-suggester.js +1138 -1138
  22. package/.aios-core/development/scripts/rollback-handler.js +530 -530
  23. package/.aios-core/development/scripts/security-checker.js +358 -358
  24. package/.aios-core/development/scripts/template-engine.js +239 -239
  25. package/.aios-core/development/scripts/template-validator.js +278 -278
  26. package/.aios-core/development/scripts/test-generator.js +843 -843
  27. package/.aios-core/development/scripts/transaction-manager.js +589 -589
  28. package/.aios-core/development/scripts/usage-tracker.js +673 -673
  29. package/.aios-core/development/scripts/validate-filenames.js +226 -226
  30. package/.aios-core/development/scripts/version-tracker.js +526 -526
  31. package/.aios-core/development/scripts/yaml-validator.js +396 -396
  32. package/.aios-core/development/templates/service-template/README.md.hbs +158 -158
  33. package/.aios-core/development/templates/service-template/__tests__/index.test.ts.hbs +237 -237
  34. package/.aios-core/development/templates/service-template/client.ts.hbs +403 -403
  35. package/.aios-core/development/templates/service-template/errors.ts.hbs +182 -182
  36. package/.aios-core/development/templates/service-template/index.ts.hbs +120 -120
  37. package/.aios-core/development/templates/service-template/package.json.hbs +87 -87
  38. package/.aios-core/development/templates/service-template/types.ts.hbs +145 -145
  39. package/.aios-core/development/templates/squad-template/LICENSE +21 -21
  40. package/.aios-core/docs/SHARD-TRANSLATION-GUIDE.md +335 -0
  41. package/.aios-core/docs/component-creation-guide.md +458 -0
  42. package/.aios-core/docs/session-update-pattern.md +307 -0
  43. package/.aios-core/docs/standards/AIOS-FRAMEWORK-MASTER.md +1963 -0
  44. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1-SUMMARY.md +1190 -0
  45. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO-V2.1.md +439 -0
  46. package/.aios-core/docs/standards/AIOS-LIVRO-DE-OURO.md +5398 -0
  47. package/.aios-core/docs/standards/V3-ARCHITECTURAL-DECISIONS.md +523 -0
  48. package/.aios-core/docs/template-syntax.md +267 -0
  49. package/.aios-core/docs/troubleshooting-guide.md +625 -0
  50. package/.aios-core/infrastructure/templates/aios-sync.yaml.template +193 -193
  51. package/.aios-core/infrastructure/templates/coderabbit.yaml.template +279 -279
  52. package/.aios-core/infrastructure/templates/github-workflows/ci.yml.template +169 -169
  53. package/.aios-core/infrastructure/templates/github-workflows/pr-automation.yml.template +330 -330
  54. package/.aios-core/infrastructure/templates/github-workflows/release.yml.template +196 -196
  55. package/.aios-core/infrastructure/templates/gitignore/gitignore-aios-base.tmpl +63 -63
  56. package/.aios-core/infrastructure/templates/gitignore/gitignore-brownfield-merge.tmpl +18 -18
  57. package/.aios-core/infrastructure/templates/gitignore/gitignore-node.tmpl +85 -85
  58. package/.aios-core/infrastructure/templates/gitignore/gitignore-python.tmpl +145 -145
  59. package/.aios-core/infrastructure/tests/utilities-audit-results.json +501 -0
  60. package/.aios-core/install-manifest.yaml +97 -97
  61. package/.aios-core/local-config.yaml.template +68 -68
  62. package/.aios-core/manifests/agents.csv +1 -0
  63. package/.aios-core/manifests/schema/manifest-schema.json +190 -190
  64. package/.aios-core/manifests/tasks.csv +121 -0
  65. package/.aios-core/manifests/workers.csv +204 -0
  66. package/.aios-core/monitor/hooks/lib/__init__.py +1 -1
  67. package/.aios-core/monitor/hooks/lib/enrich.py +58 -58
  68. package/.aios-core/monitor/hooks/lib/send_event.py +47 -47
  69. package/.aios-core/monitor/hooks/notification.py +29 -29
  70. package/.aios-core/monitor/hooks/post_tool_use.py +45 -45
  71. package/.aios-core/monitor/hooks/pre_compact.py +29 -29
  72. package/.aios-core/monitor/hooks/pre_tool_use.py +40 -40
  73. package/.aios-core/monitor/hooks/stop.py +29 -29
  74. package/.aios-core/monitor/hooks/subagent_stop.py +29 -29
  75. package/.aios-core/monitor/hooks/user_prompt_submit.py +38 -38
  76. package/.aios-core/product/templates/adr.hbs +125 -125
  77. package/.aios-core/product/templates/component-react-tmpl.tsx +98 -98
  78. package/.aios-core/product/templates/dbdr.hbs +241 -241
  79. package/.aios-core/product/templates/engine/schemas/adr.schema.json +102 -102
  80. package/.aios-core/product/templates/engine/schemas/dbdr.schema.json +205 -205
  81. package/.aios-core/product/templates/engine/schemas/epic.schema.json +175 -175
  82. package/.aios-core/product/templates/engine/schemas/pmdr.schema.json +175 -175
  83. package/.aios-core/product/templates/engine/schemas/prd-v2.schema.json +300 -300
  84. package/.aios-core/product/templates/engine/schemas/prd.schema.json +152 -152
  85. package/.aios-core/product/templates/engine/schemas/story.schema.json +222 -222
  86. package/.aios-core/product/templates/engine/schemas/task.schema.json +154 -154
  87. package/.aios-core/product/templates/epic.hbs +212 -212
  88. package/.aios-core/product/templates/eslintrc-security.json +32 -32
  89. package/.aios-core/product/templates/github-actions-cd.yml +212 -212
  90. package/.aios-core/product/templates/github-actions-ci.yml +172 -172
  91. package/.aios-core/product/templates/pmdr.hbs +186 -186
  92. package/.aios-core/product/templates/prd-v2.0.hbs +216 -216
  93. package/.aios-core/product/templates/prd.hbs +201 -201
  94. package/.aios-core/product/templates/shock-report-tmpl.html +502 -502
  95. package/.aios-core/product/templates/story.hbs +263 -263
  96. package/.aios-core/product/templates/task.hbs +170 -170
  97. package/.aios-core/product/templates/tmpl-comment-on-examples.sql +158 -158
  98. package/.aios-core/product/templates/tmpl-migration-script.sql +91 -91
  99. package/.aios-core/product/templates/tmpl-rls-granular-policies.sql +104 -104
  100. package/.aios-core/product/templates/tmpl-rls-kiss-policy.sql +10 -10
  101. package/.aios-core/product/templates/tmpl-rls-roles.sql +135 -135
  102. package/.aios-core/product/templates/tmpl-rls-simple.sql +77 -77
  103. package/.aios-core/product/templates/tmpl-rls-tenant.sql +152 -152
  104. package/.aios-core/product/templates/tmpl-rollback-script.sql +77 -77
  105. package/.aios-core/product/templates/tmpl-seed-data.sql +140 -140
  106. package/.aios-core/product/templates/tmpl-smoke-test.sql +16 -16
  107. package/.aios-core/product/templates/tmpl-staging-copy-merge.sql +139 -139
  108. package/.aios-core/product/templates/tmpl-stored-proc.sql +140 -140
  109. package/.aios-core/product/templates/tmpl-trigger.sql +152 -152
  110. package/.aios-core/product/templates/tmpl-view-materialized.sql +133 -133
  111. package/.aios-core/product/templates/tmpl-view.sql +177 -177
  112. package/.aios-core/product/templates/token-exports-css-tmpl.css +240 -240
  113. package/.aios-core/quality/schemas/quality-metrics.schema.json +233 -233
  114. package/.aios-core/scripts/migrate-framework-docs.sh +300 -300
  115. package/.aios-core/scripts/pm.sh +0 -0
  116. package/.claude/hooks/enforce-architecture-first.py +196 -0
  117. package/.claude/hooks/install-hooks.sh +41 -0
  118. package/.claude/hooks/mind-clone-governance.py +192 -0
  119. package/.claude/hooks/pre-commit-mmos-guard.sh +99 -0
  120. package/.claude/hooks/pre-commit-version-check.sh +156 -0
  121. package/.claude/hooks/read-protection.py +151 -0
  122. package/.claude/hooks/slug-validation.py +176 -0
  123. package/.claude/hooks/sql-governance.py +182 -0
  124. package/.claude/hooks/write-path-validation.py +194 -0
  125. package/.claude/rules/agent-authority.md +105 -0
  126. package/.claude/rules/coderabbit-integration.md +93 -0
  127. package/.claude/rules/ids-principles.md +112 -0
  128. package/.claude/rules/story-lifecycle.md +139 -0
  129. package/.claude/rules/workflow-execution.md +150 -0
  130. package/LICENSE +48 -48
  131. package/README.md +30 -7
  132. package/bin/aios-minimal.js +0 -0
  133. package/bin/aios.js +15 -15
  134. package/package.json +2 -4
  135. package/packages/aios-install/bin/aios-install.js +0 -0
  136. package/packages/aios-install/bin/edmcp.js +0 -0
  137. package/packages/aios-pro-cli/bin/aios-pro.js +0 -0
  138. package/scripts/check-markdown-links.py +352 -352
  139. package/scripts/dashboard-parallel-dev.sh +0 -0
  140. package/scripts/dashboard-parallel-phase3.sh +0 -0
  141. package/scripts/dashboard-parallel-phase4.sh +0 -0
  142. package/scripts/glue/README.md +355 -0
  143. package/scripts/glue/compose-agent-prompt.cjs +362 -0
  144. package/scripts/install-monitor-hooks.sh +0 -0
  145. package/.aios-core/lib/build.json +0 -1
@@ -0,0 +1,194 @@
1
+ #!/usr/bin/env python3
2
+ """
3
+ Hook: Write Path Validation
4
+
5
+ REGRA: Documentos devem ir para os paths corretos conforme convenções.
6
+
7
+ Este hook intercepta Write/Edit e AVISA (não bloqueia) quando o path
8
+ parece violar as convenções de organização de documentos.
9
+
10
+ Exit Codes:
11
+ - 0: Sempre (apenas avisa, nunca bloqueia)
12
+ """
13
+
14
+ import json
15
+ import sys
16
+ import os
17
+ import re
18
+ from datetime import datetime
19
+
20
+ # =============================================================================
21
+ # CONFIGURAÇÃO: Regras de organização de documentos
22
+ # =============================================================================
23
+
24
+ PATH_RULES = [
25
+ # (pattern no nome/conteúdo, path esperado, descrição)
26
+ {
27
+ "name_patterns": [r"session", r"handoff", r"^2\d{3}-\d{2}-\d{2}"],
28
+ "expected_path": "docs/sessions/",
29
+ "description": "Session logs e handoffs → docs/sessions/YYYY-MM/",
30
+ },
31
+ {
32
+ "name_patterns": [r"architecture", r"system-design", r"infra"],
33
+ "expected_path": "docs/architecture/",
34
+ "description": "Docs de arquitetura → docs/architecture/",
35
+ "exclude_patterns": [r"ARCHITECTURE_RULES"], # Exceção para MMOS
36
+ },
37
+ {
38
+ "name_patterns": [r"guide", r"tutorial", r"how-to"],
39
+ "expected_path": "docs/guides/",
40
+ "description": "Guias e tutoriais → docs/guides/",
41
+ },
42
+ {
43
+ "name_patterns": [r"prd\.md$", r"epic.*\.md$", r"story.*\.md$"],
44
+ "expected_path": "docs/projects/",
45
+ "description": "PRDs, Epics, Stories → docs/projects/{project}/",
46
+ },
47
+ {
48
+ "name_patterns": [r"mind.*specific", r"mind.*validation"],
49
+ "expected_path": "outputs/minds/",
50
+ "description": "Docs específicos de mind → outputs/minds/{slug}/docs/",
51
+ },
52
+ ]
53
+
54
+ # Paths que são sempre válidos (não avisar)
55
+ ALWAYS_VALID_PATHS = [
56
+ ".claude/",
57
+ ".aios-core/",
58
+ ".aios-upstream/",
59
+ "squads/",
60
+ "node_modules/",
61
+ ".git/",
62
+ "app/",
63
+ "supabase/",
64
+ "outputs/",
65
+ ]
66
+
67
+ # =============================================================================
68
+ # LÓGICA DO HOOK
69
+ # =============================================================================
70
+
71
+ def get_project_root():
72
+ """Obtém o root do projeto."""
73
+ return os.environ.get("CLAUDE_PROJECT_DIR", os.getcwd())
74
+
75
+ def normalize_path(file_path: str, project_root: str) -> str:
76
+ """Normaliza path para relativo."""
77
+ if file_path.startswith(project_root):
78
+ return file_path[len(project_root):].lstrip("/")
79
+ return file_path
80
+
81
+ def is_always_valid(relative_path: str) -> bool:
82
+ """Verifica se o path está em área sempre válida."""
83
+ for valid in ALWAYS_VALID_PATHS:
84
+ if relative_path.startswith(valid):
85
+ return True
86
+ return False
87
+
88
+ def is_documentation_file(relative_path: str) -> bool:
89
+ """Verifica se é um arquivo de documentação."""
90
+ doc_extensions = [".md", ".mdx", ".txt", ".rst"]
91
+ return any(relative_path.endswith(ext) for ext in doc_extensions)
92
+
93
+ def check_path_rules(relative_path: str) -> list[dict]:
94
+ """
95
+ Verifica se o path viola alguma regra.
96
+
97
+ Returns:
98
+ Lista de violações com sugestões
99
+ """
100
+ violations = []
101
+ filename = os.path.basename(relative_path)
102
+
103
+ for rule in PATH_RULES:
104
+ # Verificar se o nome do arquivo corresponde ao pattern
105
+ matches_name = False
106
+ for pattern in rule["name_patterns"]:
107
+ if re.search(pattern, filename, re.IGNORECASE):
108
+ matches_name = True
109
+ break
110
+
111
+ if not matches_name:
112
+ continue
113
+
114
+ # Verificar exceções
115
+ if "exclude_patterns" in rule:
116
+ is_excluded = False
117
+ for exc_pattern in rule["exclude_patterns"]:
118
+ if re.search(exc_pattern, filename, re.IGNORECASE):
119
+ is_excluded = True
120
+ break
121
+ if is_excluded:
122
+ continue
123
+
124
+ # Verificar se está no path esperado
125
+ expected = rule["expected_path"]
126
+ if not relative_path.startswith(expected):
127
+ violations.append({
128
+ "current_path": relative_path,
129
+ "expected_path": expected,
130
+ "description": rule["description"],
131
+ })
132
+
133
+ return violations
134
+
135
+ def main():
136
+ # Ler input do stdin
137
+ try:
138
+ input_data = json.load(sys.stdin)
139
+ except json.JSONDecodeError:
140
+ sys.exit(0)
141
+
142
+ tool_name = input_data.get("tool_name", "")
143
+ tool_input = input_data.get("tool_input", {})
144
+
145
+ # Só processar Write e Edit
146
+ if tool_name not in ["Write", "Edit"]:
147
+ sys.exit(0)
148
+
149
+ file_path = tool_input.get("file_path", "")
150
+ if not file_path:
151
+ sys.exit(0)
152
+
153
+ # Normalizar path
154
+ project_root = get_project_root()
155
+ relative_path = normalize_path(file_path, project_root)
156
+
157
+ # Verificar se é área sempre válida
158
+ if is_always_valid(relative_path):
159
+ sys.exit(0)
160
+
161
+ # Só verificar arquivos de documentação
162
+ if not is_documentation_file(relative_path):
163
+ sys.exit(0)
164
+
165
+ # Verificar regras
166
+ violations = check_path_rules(relative_path)
167
+
168
+ if not violations:
169
+ sys.exit(0)
170
+
171
+ # AVISAR (não bloquear)
172
+ violation = violations[0] # Mostrar primeira violação
173
+
174
+ warning_message = f"""
175
+ ┌──────────────────────────────────────────────────────────────────────────────┐
176
+ │ ⚠️ PATH WARNING: Documento pode estar no local errado │
177
+ ├──────────────────────────────────────────────────────────────────────────────┤
178
+ │ │
179
+ │ Arquivo: {relative_path[:60]:<60} │
180
+ │ │
181
+ │ Convenção: {violation['description'][:56]:<56} │
182
+ │ Esperado: {violation['expected_path']:<57} │
183
+ │ │
184
+ │ NOTA: Este é apenas um AVISO, a operação será executada. │
185
+ │ Verifique se o path está correto antes de continuar. │
186
+ │ │
187
+ └──────────────────────────────────────────────────────────────────────────────┘
188
+ """
189
+ # Imprimir warning mas NÃO bloquear (exit 0)
190
+ print(warning_message, file=sys.stderr)
191
+ sys.exit(0)
192
+
193
+ if __name__ == "__main__":
194
+ main()
@@ -0,0 +1,105 @@
1
+ # Agent Authority — Detailed Rules
2
+
3
+ ## Delegation Matrix
4
+
5
+ ### @devops (Gage) — EXCLUSIVE Authority
6
+
7
+ | Operation | Exclusive? | Other Agents |
8
+ |-----------|-----------|--------------|
9
+ | `git push` / `git push --force` | YES | BLOCKED |
10
+ | `gh pr create` / `gh pr merge` | YES | BLOCKED |
11
+ | MCP add/remove/configure | YES | BLOCKED |
12
+ | CI/CD pipeline management | YES | BLOCKED |
13
+ | Release management | YES | BLOCKED |
14
+
15
+ ### @pm (Morgan) — Epic Orchestration
16
+
17
+ | Operation | Exclusive? | Delegated From |
18
+ |-----------|-----------|---------------|
19
+ | `*execute-epic` | YES | — |
20
+ | `*create-epic` | YES | — |
21
+ | EPIC-{ID}-EXECUTION.yaml management | YES | — |
22
+ | Requirements gathering | YES | — |
23
+ | Spec writing (spec pipeline) | YES | — |
24
+
25
+ ### @po (Pax) — Story Validation
26
+
27
+ | Operation | Exclusive? | Details |
28
+ |-----------|-----------|---------|
29
+ | `*validate-story-draft` | YES | 10-point checklist |
30
+ | Story context tracking in epics | YES | — |
31
+ | Epic context management | YES | — |
32
+ | Backlog prioritization | YES | — |
33
+
34
+ ### @sm (River) — Story Creation
35
+
36
+ | Operation | Exclusive? | Details |
37
+ |-----------|-----------|---------|
38
+ | `*draft` / `*create-story` | YES | From epic/PRD |
39
+ | Story template selection | YES | — |
40
+
41
+ ### @dev (Dex) — Implementation
42
+
43
+ | Allowed | Blocked |
44
+ |---------|---------|
45
+ | `git add`, `git commit`, `git status` | `git push` (delegate to @devops) |
46
+ | `git branch`, `git checkout`, `git merge` (local) | `gh pr create/merge` (delegate to @devops) |
47
+ | `git stash`, `git diff`, `git log` | MCP management |
48
+ | Story file updates (File List, checkboxes) | Story file updates (AC, scope, title) |
49
+
50
+ ### @architect (Aria) — Design Authority
51
+
52
+ | Owns | Delegates To |
53
+ |------|-------------|
54
+ | System architecture decisions | — |
55
+ | Technology selection | — |
56
+ | High-level data architecture | @data-engineer (detailed DDL) |
57
+ | Integration patterns | @data-engineer (query optimization) |
58
+ | Complexity assessment | — |
59
+
60
+ ### @data-engineer (Dara) — Database
61
+
62
+ | Owns (delegated from @architect) | Does NOT Own |
63
+ |----------------------------------|-------------|
64
+ | Schema design (detailed DDL) | System architecture |
65
+ | Query optimization | Application code |
66
+ | RLS policies implementation | Git operations |
67
+ | Index strategy execution | Frontend/UI |
68
+ | Migration planning & execution | — |
69
+
70
+ ### @aios-master — Framework Governance
71
+
72
+ | Capability | Details |
73
+ |-----------|---------|
74
+ | Execute ANY task directly | No restrictions |
75
+ | Framework governance | Constitutional enforcement |
76
+ | Override agent boundaries | When necessary for framework health |
77
+
78
+ ## Cross-Agent Delegation Patterns
79
+
80
+ ### Git Push Flow
81
+ ```
82
+ ANY agent → @devops *push
83
+ ```
84
+
85
+ ### Schema Design Flow
86
+ ```
87
+ @architect (decides technology) → @data-engineer (implements DDL)
88
+ ```
89
+
90
+ ### Story Flow
91
+ ```
92
+ @sm *draft → @po *validate → @dev *develop → @qa *qa-gate → @devops *push
93
+ ```
94
+
95
+ ### Epic Flow
96
+ ```
97
+ @pm *create-epic → @pm *execute-epic → @sm *draft (per story)
98
+ ```
99
+
100
+ ## Escalation Rules
101
+
102
+ 1. Agent cannot complete task → Escalate to @aios-master
103
+ 2. Quality gate fails → Return to @dev with specific feedback
104
+ 3. Constitutional violation detected → BLOCK, require fix before proceed
105
+ 4. Agent boundary conflict → @aios-master mediates
@@ -0,0 +1,93 @@
1
+ # CodeRabbit Integration — Detailed Rules
2
+
3
+ ## Self-Healing Configuration
4
+
5
+ ### Dev Phase (@dev — Story Development Cycle Phase 3)
6
+
7
+ ```yaml
8
+ mode: light
9
+ max_iterations: 2
10
+ timeout_minutes: 30
11
+ severity_filter: [CRITICAL, HIGH]
12
+ behavior:
13
+ CRITICAL: auto_fix
14
+ HIGH: auto_fix (iteration < 2) else document_as_debt
15
+ MEDIUM: document_as_debt
16
+ LOW: ignore
17
+ ```
18
+
19
+ **Flow:**
20
+ ```
21
+ RUN CodeRabbit → CRITICAL found?
22
+ YES → auto-fix (iteration < 2) → Re-run
23
+ NO → Document HIGH as debt, proceed
24
+ After 2 iterations with CRITICAL → HALT, manual intervention
25
+ ```
26
+
27
+ ### QA Phase (@qa — QA Loop Pre-Review)
28
+
29
+ ```yaml
30
+ mode: full
31
+ max_iterations: 3
32
+ timeout_minutes: 30
33
+ severity_filter: [CRITICAL, HIGH]
34
+ behavior:
35
+ CRITICAL: auto_fix
36
+ HIGH: auto_fix
37
+ MEDIUM: document_as_debt
38
+ LOW: ignore
39
+ ```
40
+
41
+ **Flow:**
42
+ 1. Pre-commit review scan
43
+ 2. Self-healing loop (max 3 iterations)
44
+ 3. Manual QA analysis (architectural, traceability, NFR)
45
+ 4. Gate decision (verdict)
46
+
47
+ ## Severity Handling Summary
48
+
49
+ | Severity | Dev Phase | QA Phase |
50
+ |----------|-----------|----------|
51
+ | CRITICAL | auto_fix, block if persists | auto_fix, block if persists |
52
+ | HIGH | auto_fix, document if fails | auto_fix, document if fails |
53
+ | MEDIUM | document_as_tech_debt | document_as_tech_debt |
54
+ | LOW | ignore | ignore |
55
+
56
+ ## WSL Execution (Windows)
57
+
58
+ ```bash
59
+ # Self-healing mode (automatic in dev tasks)
60
+ wsl bash -c 'cd /mnt/c/.../aios-core && ~/.local/bin/coderabbit --severity CRITICAL,HIGH --auto-fix'
61
+
62
+ # Manual review
63
+ wsl bash -c 'cd /mnt/c/.../aios-core && ~/.local/bin/coderabbit -t uncommitted'
64
+
65
+ # Prompt-only mode
66
+ wsl bash -c 'cd /mnt/c/.../aios-core && ~/.local/bin/coderabbit --prompt-only -t uncommitted'
67
+ ```
68
+
69
+ ## Integration Points
70
+
71
+ | Workflow | Phase | Trigger | Agent |
72
+ |----------|-------|---------|-------|
73
+ | Story Development Cycle | 3 (Implement) | After task completion | @dev |
74
+ | QA Loop | 1 (Review) | At review start | @qa |
75
+ | Standalone | Any | `*coderabbit-review` command | Any |
76
+
77
+ ## Focus Areas by Story Type
78
+
79
+ | Story Type | Primary Focus |
80
+ |-----------|--------------|
81
+ | Feature | Code patterns, test coverage, API design |
82
+ | Bug Fix | Regression risk, root cause coverage |
83
+ | Refactor | Breaking changes, interface stability |
84
+ | Documentation | Markdown quality, reference validity |
85
+ | Database | SQL injection, RLS coverage, migration safety |
86
+
87
+ ## Report Location
88
+
89
+ CodeRabbit reports saved to: `docs/qa/coderabbit-reports/`
90
+
91
+ ## Configuration Reference
92
+
93
+ Full config in `.aios-core/core-config.yaml` under `coderabbit_integration` section.
@@ -0,0 +1,112 @@
1
+ # IDS Principles — Detailed Rules
2
+
3
+ > Status: Planned (IDS epic is Draft — principles apply as aspirational guidance)
4
+
5
+ ## Decision Hierarchy: REUSE > ADAPT > CREATE
6
+
7
+ ### REUSE (Relevance >= 90%)
8
+ - Use existing artifact directly without modification
9
+ - Import/reference existing entity
10
+ - No justification needed beyond confirming match
11
+
12
+ ### ADAPT (Relevance 60-89%)
13
+ - Adaptability score >= 0.6
14
+ - Changes MUST NOT exceed 30% of original artifact
15
+ - Changes MUST NOT break existing consumers (check usedBy list)
16
+ - Document changes in artifact's change log
17
+ - Update registry relationships
18
+ - Impact analysis required
19
+
20
+ ### CREATE (No suitable match)
21
+ Required justification:
22
+ - `evaluated_patterns`: Existing entities you considered
23
+ - `rejection_reasons`: Why each was rejected (technical reasons)
24
+ - `new_capability`: What unique capability this provides
25
+ - Register in Entity Registry within 24 hours
26
+ - Establish relationships with existing entities
27
+ - Define adaptability constraints for future reuse
28
+
29
+ ## Verification Gates G1-G6
30
+
31
+ ### G1: Epic Creation (@pm)
32
+ - **Type:** Human-in-loop, Advisory
33
+ - **Trigger:** `*create-epic` workflow
34
+ - **Action:** Query registry for related entities, display potentially reusable artifacts
35
+ - **Latency:** < 24h (async)
36
+ - **Blocking:** No
37
+
38
+ ### G2: Story Creation (@sm)
39
+ - **Type:** Human-in-loop, Advisory
40
+ - **Trigger:** `*draft` workflow
41
+ - **Action:** Check existing tasks/templates matching story work
42
+ - **Latency:** < 24h (async)
43
+ - **Blocking:** No
44
+
45
+ ### G3: Story Validation (@po)
46
+ - **Type:** Human-in-loop, Soft Block
47
+ - **Trigger:** `*validate-story-draft` workflow
48
+ - **Action:** Verify referenced artifacts exist, detect potential duplication
49
+ - **Latency:** < 4h (async)
50
+ - **Blocking:** Soft (can override with reason)
51
+
52
+ ### G4: Dev Context (@dev)
53
+ - **Type:** Automated, Informational
54
+ - **Trigger:** Story assignment / `*develop` start
55
+ - **Action:** Display matching patterns as reminder
56
+ - **Latency:** < 2s
57
+ - **Blocking:** NO (logged only for metrics)
58
+
59
+ ### G5: QA Review (@qa)
60
+ - **Type:** Automated, Blocks Merge
61
+ - **Trigger:** PR/merge request
62
+ - **Action:** Check if new artifacts could have reused existing
63
+ - **Latency:** < 30s
64
+ - **Blocking:** YES if new entity without registry entry or justification
65
+
66
+ ### G6: CI/CD (@devops)
67
+ - **Type:** Automated, Blocks Merge
68
+ - **Trigger:** CI pipeline
69
+ - **Action:** Registry integrity check + sync
70
+ - **Latency:** < 60s
71
+ - **Blocking:** YES on CRITICAL, WARN on MEDIUM/LOW
72
+
73
+ ## Override Policy
74
+
75
+ **Command:** `--override-ids --override-reason "explanation"`
76
+
77
+ **Permitted when:**
78
+ - Time-critical fix requires immediate creation
79
+ - Adaptation would introduce unacceptable risk
80
+ - Existing artifact is deprecated/frozen
81
+
82
+ **Requirements:**
83
+ - Logged for audit trail
84
+ - Reviewed within 7 days
85
+ - Include override reason in gate verification log
86
+
87
+ ## Graceful Degradation
88
+
89
+ All gates implement circuit breaker:
90
+ - **Timeout:** 2s default
91
+ - **On timeout:** warn-and-proceed
92
+ - **On error:** log-and-proceed
93
+ - **Key principle:** Development NEVER blocked by IDS failures
94
+
95
+ ```yaml
96
+ circuit_breaker:
97
+ failure_threshold: 5
98
+ success_threshold: 3
99
+ reset_timeout_ms: 60000
100
+ ```
101
+
102
+ ## Article IV-A: Incremental Development (Constitution Amendment)
103
+
104
+ **Severity:** MUST
105
+
106
+ **Four Core Rules:**
107
+ 1. **Registry Consultation Required** — Query before creating
108
+ 2. **Decision Hierarchy** — REUSE > ADAPT > CREATE strictly
109
+ 3. **Adaptation Limits** — Changes < 30%, don't break consumers
110
+ 4. **Creation Requirements** — Full justification, register within 24h
111
+
112
+ **Reference:** `docs/stories/epics/epic-ids-incremental-development/`
@@ -0,0 +1,139 @@
1
+ # Story Lifecycle — Detailed Rules
2
+
3
+ ## Status Progression
4
+
5
+ ```
6
+ Draft → Ready → InProgress → InReview → Done
7
+ ```
8
+
9
+ | Status | Trigger | Agent | Action |
10
+ |--------|---------|-------|--------|
11
+ | Draft | @sm creates story | @sm | Story file created |
12
+ | Ready | @po validates (GO) | @po | **MUST update status field in story file from Draft → Ready** |
13
+ | InProgress | @dev starts implementation | @dev | Update status field |
14
+ | InReview | @dev completes, @qa reviews | @qa | Update status field |
15
+ | Done | @qa PASS, @devops pushes | @devops | Update status field |
16
+
17
+ **CRITICAL:** The `Draft → Ready` transition is the responsibility of @po during `*validate-story-draft`. When verdict is GO (including conditional GO after fixes are applied), @po MUST update the story's Status field to `Ready` and log the transition in the Change Log. A story left in `Draft` after a GO verdict is a process violation.
18
+
19
+ ## Phase 1: Create (@sm)
20
+
21
+ **Task:** `create-next-story.md`
22
+ **Inputs:** PRD sharded, epic context
23
+ **Output:** `{epicNum}.{storyNum}.story.md`
24
+
25
+ ## Phase 2: Validate (@po)
26
+
27
+ **Task:** `validate-next-story.md`
28
+
29
+ ### 10-Point Validation Checklist
30
+
31
+ 1. Clear and objective title
32
+ 2. Complete description (problem/need explained)
33
+ 3. Testable acceptance criteria (Given/When/Then preferred)
34
+ 4. Well-defined scope (IN and OUT clearly listed)
35
+ 5. Dependencies mapped (prerequisite stories/resources)
36
+ 6. Complexity estimate (points or T-shirt sizing)
37
+ 7. Business value (benefit to user/business clear)
38
+ 8. Risks documented (potential problems identified)
39
+ 9. Criteria of Done (clear definition of complete)
40
+ 10. Alignment with PRD/Epic (consistency with source docs)
41
+
42
+ **Decision:** GO (≥7/10) or NO-GO (<7/10 with required fixes)
43
+
44
+ ## Phase 3: Implement (@dev)
45
+
46
+ **Task:** `dev-develop-story.md`
47
+
48
+ ### Execution Modes
49
+
50
+ **YOLO (autonomous):**
51
+ - 0-1 prompts
52
+ - Decisions logged in `decision-log-{story-id}.md`
53
+ - Best for: simple, deterministic tasks
54
+
55
+ **Interactive (default):**
56
+ - 5-10 prompts with educational checkpoints
57
+ - Confirmations at key decision points
58
+ - Best for: learning, complex decisions
59
+
60
+ **Pre-Flight (plan-first):**
61
+ - All questions upfront (10-15 prompts)
62
+ - Generates execution plan
63
+ - Then zero-ambiguity execution
64
+ - Best for: ambiguous requirements, critical work
65
+
66
+ ### CodeRabbit Self-Healing in Dev Phase
67
+
68
+ ```
69
+ iteration = 0
70
+ while CRITICAL issues found AND iteration < 2:
71
+ auto-fix CRITICAL/HIGH
72
+ iteration++
73
+ if CRITICAL persist after 2 iterations:
74
+ HALT — manual intervention required
75
+ ```
76
+
77
+ ## Phase 4: QA Gate (@qa)
78
+
79
+ **Task:** `qa-gate.md`
80
+
81
+ ### 7 Quality Checks
82
+
83
+ 1. **Code review** — patterns, readability, maintainability
84
+ 2. **Unit tests** — adequate coverage, all passing
85
+ 3. **Acceptance criteria** — all met per story AC
86
+ 4. **No regressions** — existing functionality preserved
87
+ 5. **Performance** — within acceptable limits
88
+ 6. **Security** — OWASP basics verified
89
+ 7. **Documentation** — updated if necessary
90
+
91
+ ### Gate Decisions
92
+
93
+ | Decision | Score | Action |
94
+ |----------|-------|--------|
95
+ | PASS | All checks OK | Approve, proceed to @devops push |
96
+ | CONCERNS | Minor issues | Approve with observations documented |
97
+ | FAIL | HIGH/CRITICAL issues | Return to @dev with feedback |
98
+ | WAIVED | Issues accepted | Approve with waiver documented (rare) |
99
+
100
+ ### Gate File Structure
101
+
102
+ ```yaml
103
+ storyId: STORY-42
104
+ verdict: PASS | CONCERNS | FAIL | WAIVED
105
+ issues:
106
+ - severity: low | medium | high
107
+ category: code | tests | requirements | performance | security | docs
108
+ description: "..."
109
+ recommendation: "..."
110
+ ```
111
+
112
+ ## QA Loop (Iterative Review-Fix)
113
+
114
+ ```
115
+ @qa review → verdict → @dev fixes → re-review (max 5 iterations)
116
+ ```
117
+
118
+ **Commands:**
119
+ - `*qa-loop {storyId}` — Start full loop
120
+ - `*stop-qa-loop` — Pause and save state
121
+ - `*resume-qa-loop` — Resume from saved state
122
+ - `*escalate-qa-loop` — Force manual escalation
123
+
124
+ **Escalation triggers:**
125
+ - max_iterations_reached (default: 5)
126
+ - verdict_blocked
127
+ - fix_failure (after retries)
128
+ - manual_escalate (user command)
129
+
130
+ **Status:** Tracked in `qa/loop-status.json`
131
+
132
+ ## Story File Update Rules
133
+
134
+ | Section | Who Can Edit |
135
+ |---------|-------------|
136
+ | Title, Description, AC, Scope | @po only |
137
+ | File List, Dev Notes, checkboxes | @dev |
138
+ | QA Results | @qa only |
139
+ | Change Log | Any agent (append only) |