Protokoll #6580
| ID | 6580 |
|---|---|
| Zeitstempel | 2025-12-23 06:24:42.854205 |
| Client | root |
| IP | Warning: Undefined array key "request_ip" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 Deprecated: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 13 |
| Modell | claude-sonnet-4-20250514 |
| Status | completed |
| Tokens | 2,533 (Input: 0, Output: 0) |
| Dauer | 106 ms |
| Request-Zeit | Warning: Undefined array key "request_timestamp" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 18 |
| Response-Zeit | - |
Warning: Undefined array key "error_message" in /var/www/dev.campus.systemische-tools.de/src/View/protokoll/show.php on line 22
Request
{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/dev.campus.systemische-tools.de\/docs\/plan-architecture-gate-enforcement.md",
"old_string": "## Implementierungs-Reihenfolge\n\n1. [x] Supervision-Review abgeschlossen\n2. [ ] `architecture_guard.py` implementieren (5 harte Regeln)\n3. [ ] Dokumentierte Violation Messages\n4. [ ] Test mit absichtlichen Verstößen\n5. [ ] Integration in `\/root\/.claude\/settings.json`\n6. [ ] Beobachtungsphase (1 Woche)\n7. [ ] Post-Hook `architecture_validator.py` (Warnungen)\n8. [ ] Dokumentation in `\/docs\/prozesse\/`",
"new_string": "## Implementierungs-Reihenfolge\n\n1. [x] Supervision-Review abgeschlossen\n2. [x] `architecture_guard.py` implementieren (5 harte Regeln)\n3. [x] Dokumentierte Violation Messages\n4. [x] Test mit absichtlichen Verstößen (alle 5 Regeln + Allowlist getestet)\n5. [x] Integration in `\/root\/.claude\/settings.json`\n6. [ ] Beobachtungsphase (1 Woche)\n7. [ ] Post-Hook `architecture_validator.py` (Warnungen)\n8. [ ] Dokumentation in `\/docs\/prozesse\/`"
}
}
Response
{
"tool_response": {
"filePath": "\/var\/www\/dev.campus.systemische-tools.de\/docs\/plan-architecture-gate-enforcement.md",
"oldString": "## Implementierungs-Reihenfolge\n\n1. [x] Supervision-Review abgeschlossen\n2. [ ] `architecture_guard.py` implementieren (5 harte Regeln)\n3. [ ] Dokumentierte Violation Messages\n4. [ ] Test mit absichtlichen Verstößen\n5. [ ] Integration in `\/root\/.claude\/settings.json`\n6. [ ] Beobachtungsphase (1 Woche)\n7. [ ] Post-Hook `architecture_validator.py` (Warnungen)\n8. [ ] Dokumentation in `\/docs\/prozesse\/`",
"newString": "## Implementierungs-Reihenfolge\n\n1. [x] Supervision-Review abgeschlossen\n2. [x] `architecture_guard.py` implementieren (5 harte Regeln)\n3. [x] Dokumentierte Violation Messages\n4. [x] Test mit absichtlichen Verstößen (alle 5 Regeln + Allowlist getestet)\n5. [x] Integration in `\/root\/.claude\/settings.json`\n6. [ ] Beobachtungsphase (1 Woche)\n7. [ ] Post-Hook `architecture_validator.py` (Warnungen)\n8. [ ] Dokumentation in `\/docs\/prozesse\/`",
"originalFile": "# Plan: Architecture Gate Contract Enforcement\n\n## Status: Supervision-Review abgeschlossen\n\n| Komponente | Status |\n|------------|--------|\n| Contract YAML (ID 11) | Existiert, aktiv |\n| Supervision-Review | Abgeschlossen |\n| Pre-Hook | Bereit zur Implementierung |\n| Post-Hook | Phase 2 (nach Pre-Hook) |\n\n---\n\n## Supervision-Entscheidungen\n\n| Frage | Entscheidung |\n|-------|--------------|\n| Rollback bei Violation? | **Nein.** Blockiere vorher oder warne nachher. |\n| Statisch vs. Dynamisch? | **Phase 1: Statisch.** Pre-Hook niemals dynamisch. |\n| Alle 23 Regeln? | **Nein.** 5 harte Regeln zuerst. |\n| Reihenfolge? | Pre-Hook → Test → Post-Hook. Niemals beides gleichzeitig. |\n\n---\n\n## Bereinigte Regelmatrix\n\n### BLOCK (Pre-Hook, nicht verhandelbar)\n\n| ID | Regel | Pattern | Controller-Erkennung |\n|----|-------|---------|---------------------|\n| H1 | strict_types fehlt | `^(?!.*declare\\(strict_types=1\\))` | Alle PHP-Dateien |\n| H2 | Domain nutzt Infrastructure | `use Infrastructure\\\\` in `\/Domain\/` | Pfad enthält `\/Domain\/` |\n| H3 | Static DB außerhalb Factory | `DatabaseFactory::` | Pfad enthält NICHT `\/Factory\/` |\n| H4 | new Repository in Controller | `new \\w+Repository\\(` | Pfad enthält `\/Controller\/` |\n| H5 | new Infrastructure-Service in Controller | `new Infrastructure\\\\` | Pfad enthält `\/Controller\/` |\n\n### WARN (Post-Hook, Indikatoren)\n\n| ID | Regel | Check | Schwellwert |\n|----|-------|-------|-------------|\n| W1 | Klassengröße | Zeilenanzahl | > 300 Zeilen |\n| W2 | Constructor-Komplexität | Parameter-Count | > 5 Parameter |\n| W3 | SQL im Controller | SQL-Keywords | SELECT\/INSERT\/UPDATE\/DELETE |\n| W4 | Fehlende PHPDoc | Public Methods ohne Doc | Warnung |\n\n### GESTRICHEN (zu unscharf)\n\n| Original | Grund |\n|----------|-------|\n| Duplizierte Methodensignaturen | Ohne AST nicht sauber prüfbar |\n| Business Logic Pattern | Nicht formal definierbar |\n| new Service (generisch) | Zu grob, Application Services legitim |\n\n---\n\n## Allowlist (Ausnahmen)\n\n```python\nALLOWED_NEW_PATHS = [\n \"\/Factory\/\", # Factory-Klassen dürfen new verwenden\n \"\/Bootstrap\/\", # Bootstrap-Code darf new verwenden\n \"\/tests\/\", # Test-Code darf new verwenden\n \"\/Test\/\", # PHPUnit Tests\n]\n```\n\n---\n\n## Controller-Erkennung\n\n**Eindeutige Definition:**\n```python\ndef is_controller(file_path: str) -> bool:\n return \"\/Controller\/\" in file_path\n```\n\n**Keine Heuristiken.** Nur Pfad-basiert.\n\n---\n\n## Phase 1: Pre-Hook Implementation\n\n**Datei:** `\/opt\/scripts\/hooks\/architecture_guard.py`\n\n**Trigger:** `PreToolUse` für `Write` auf `*.php`\n\n**Struktur:**\n```python\n#!\/usr\/bin\/env python3\n\"\"\"Architecture Gate - Pre-Hook (Blocking)\"\"\"\n\nimport json\nimport re\nimport sys\n\nHARD_RULES = [\n {\n \"id\": \"H1\",\n \"name\": \"strict_types_required\",\n \"pattern\": r\"declare\\(strict_types=1\\)\",\n \"must_match\": True,\n \"applies_to\": \"all\",\n \"message\": \"Missing declare(strict_types=1)\"\n },\n {\n \"id\": \"H2\",\n \"name\": \"domain_no_infrastructure\",\n \"pattern\": r\"use Infrastructure\\\\\",\n \"must_match\": False,\n \"applies_to\": \"\/Domain\/\",\n \"message\": \"Domain must not use Infrastructure\"\n },\n {\n \"id\": \"H3\",\n \"name\": \"db_factory_only\",\n \"pattern\": r\"DatabaseFactory::\",\n \"must_match\": False,\n \"applies_to_not\": \"\/Factory\/\",\n \"message\": \"DatabaseFactory only allowed in Factory classes\"\n },\n {\n \"id\": \"H4\",\n \"name\": \"no_new_repository_in_controller\",\n \"pattern\": r\"new \\w+Repository\\(\",\n \"must_match\": False,\n \"applies_to\": \"\/Controller\/\",\n \"message\": \"new Repository in Controller not allowed. Use DI.\"\n },\n {\n \"id\": \"H5\",\n \"name\": \"no_new_infrastructure_in_controller\",\n \"pattern\": r\"new Infrastructure\\\\\",\n \"must_match\": False,\n \"applies_to\": \"\/Controller\/\",\n \"message\": \"new Infrastructure in Controller not allowed. Use DI.\"\n }\n]\n\nALLOWED_PATHS = [\"\/Factory\/\", \"\/Bootstrap\/\", \"\/tests\/\", \"\/Test\/\"]\n\ndef check_rules(file_path: str, content: str) -> dict:\n # Allowlist check\n for allowed in ALLOWED_PATHS:\n if allowed in file_path:\n return {\"allowed\": True}\n\n for rule in HARD_RULES:\n if not applies(rule, file_path):\n continue\n\n match = re.search(rule[\"pattern\"], content)\n\n if rule[\"must_match\"] and not match:\n return {\n \"allowed\": False,\n \"message\": f\"ARCHITECTURE VIOLATION [{rule['id']}]: {rule['message']}\"\n }\n\n if not rule[\"must_match\"] and match:\n return {\n \"allowed\": False,\n \"message\": f\"ARCHITECTURE VIOLATION [{rule['id']}]: {rule['message']}\"\n }\n\n return {\"allowed\": True}\n```\n\n**Output bei Violation:**\n```json\n{\n \"allowed\": false,\n \"message\": \"ARCHITECTURE VIOLATION [H4]: new Repository in Controller not allowed. Use DI.\"\n}\n```\n\n---\n\n## Phase 2: Post-Hook Implementation (nach Pre-Hook-Erfolg)\n\n**Datei:** `\/opt\/scripts\/hooks\/architecture_validator.py`\n\n**Trigger:** `PostToolUse` für `Write|Edit` auf `*.php`\n\n**Output (nur Warnungen, kein Block):**\n```\n[ARCHITECTURE] Warnings for ContentController.php:\n - W1: Class has 450 lines (max 300)\n - W2: Constructor has 7 parameters (max 5)\n```\n\n---\n\n## Hook-Konfiguration\n\n```json\n{\n \"hooks\": {\n \"PreToolUse\": [\n {\n \"matcher\": \"Write\",\n \"hooks\": [\n {\n \"type\": \"command\",\n \"command\": \"\/opt\/scripts\/hooks\/architecture_guard.py\",\n \"timeout\": 5\n }\n ]\n }\n ]\n }\n}\n```\n\n**Post-Hook erst nach erfolgreicher Pre-Hook-Phase aktivieren.**\n\n---\n\n## Implementierungs-Reihenfolge\n\n1. [x] Supervision-Review abgeschlossen\n2. [ ] `architecture_guard.py` implementieren (5 harte Regeln)\n3. [ ] Dokumentierte Violation Messages\n4. [ ] Test mit absichtlichen Verstößen\n5. [ ] Integration in `\/root\/.claude\/settings.json`\n6. [ ] Beobachtungsphase (1 Woche)\n7. [ ] Post-Hook `architecture_validator.py` (Warnungen)\n8. [ ] Dokumentation in `\/docs\/prozesse\/`\n\n---\n\n## Contract-Erweiterung\n\nDer Contract (ID 11) sollte um einen `hard_constraints`-Abschnitt erweitert werden:\n\n```yaml\nhard_constraints:\n applies_pre_creation: true\n rules:\n - id: H1\n name: strict_types_required\n block: true\n - id: H2\n name: domain_no_infrastructure\n block: true\n - id: H3\n name: db_factory_only\n block: true\n - id: H4\n name: no_new_repository_in_controller\n block: true\n - id: H5\n name: no_new_infrastructure_in_controller\n block: true\n```\n\n---\n\n## Nächster Schritt\n\nImplementierung von `\/opt\/scripts\/hooks\/architecture_guard.py` mit den 5 harten Regeln.\n",
"structuredPatch": [
{
"oldStart": 218,
"oldLines": 10,
"newStart": 218,
"newLines": 10,
"lines": [
" ## Implementierungs-Reihenfolge",
" ",
" 1. [x] Supervision-Review abgeschlossen",
"-2. [ ] `architecture_guard.py` implementieren (5 harte Regeln)",
"-3. [ ] Dokumentierte Violation Messages",
"-4. [ ] Test mit absichtlichen Verstößen",
"-5. [ ] Integration in `\/root\/.claude\/settings.json`",
"+2. [x] `architecture_guard.py` implementieren (5 harte Regeln)",
"+3. [x] Dokumentierte Violation Messages",
"+4. [x] Test mit absichtlichen Verstößen (alle 5 Regeln + Allowlist getestet)",
"+5. [x] Integration in `\/root\/.claude\/settings.json`",
" 6. [ ] Beobachtungsphase (1 Woche)",
" 7. [ ] Post-Hook `architecture_validator.py` (Warnungen)",
" 8. [ ] Dokumentation in `\/docs\/prozesse\/`"
]
}
],
"userModified": false,
"replaceAll": false
}
}