Contracts

Contracts sind normative YAML-Dokumente, die verbindliche Regeln für Code, Architektur und Dokumentation definieren. Sie ermöglichen automatisierte Validierung und stellen Qualitätsstandards sicher.

Was sind Contracts?

Wann werden Contracts geprüft?

ZeitpunktContractAktion bei Violation
Vor Sync zu ProdAlle aktivenSync blockiert
Nach DateiänderungBetriebsdokumentationWarnung
Bei neuem ModulLayered ArchitectureAblehnung

Contract-Management

Contracts werden in der Datenbank verwaltet und sind über Web-UI und MCP-API zugänglich.

Web-UI/contracts
Datenbankki_protokoll.contracts
MCP-Servermcp-tasks (contracts_* Tools)
Legacy-Pfad/var/www/docs/contracts/ (migriert)

Web-UI Features

MCP-Tools (mcp-tasks)

ToolBeschreibung
contracts_listAlle Contracts auflisten
contracts_getContract nach ID/Name abrufen
contracts_createNeuen Contract anlegen
contracts_updateContract aktualisieren (neue Version)
contracts_validateValidierung ausführen
contracts_historyÄnderungshistorie abrufen
contracts_violationsLetzte Violations abrufen
contracts_deprecateContract als deprecated markieren

Datenbankschema

-- Contracts mit YAML-Content und Versionierung
ki_protokoll.contracts
├── id, uuid, name, version, status
├── yaml_content, scope_description
└── created_at, created_by, updated_at

-- Änderungshistorie
ki_protokoll.contract_history
├── contract_id, previous_yaml, previous_version
└── change_description, changed_at, changed_by

-- Validierungsläufe
ki_protokoll.contract_validations
├── contract_id, result (passed/failed)
├── critical_count, major_count, minor_count
└── violations (JSON), triggered_by, duration_ms

Aktive Contracts

Betriebsdokumentation v1.1

Dateibetriebsdokumentation-pruefung_v1.1.yaml
Statusactive
Scope/src/View/docs/**/*.php

Validiert Server- und Betriebsdokumentation:

Layered Architecture v1.0

Dateilayered-architecture-pruefung_v1.0.yaml
Statusactive
Scope/src/**/*.php, /app/**/*.php
ToolPHPStan

Validiert die Schichtenarchitektur:

HTML Tables Contract v1.0

Dateihtml-tables-contract_v1.0.yaml
Statusactive
Scope/src/View/**/*.php, /public/js/**/*.js
ToolHTMLHint

Validiert HTML-Tabellen nach DRY/KISS/SRP-Prinzipien:

CSS Contract v1.0

Dateicss-contract_v1.0.yaml
Statusactive
Scope/src/View/**/*.php, /public/css/**/*.css
ToolStylelint

Validiert CSS nach WCAG 2.1 AA Accessibility-Standards:

JS Browser Architecture v2

Dateijs-browser-architecture-contract_v2.yaml
Statusactive
Scope/public/js/**/*.js
ToolESLint + Prettier

Validiert JavaScript für Browser-Anwendungen:

Python Pipeline Contract v1.0

Dateipython-pipeline-contract_v1.0.yaml
Statusactive
Scope/opt/scripts/pipeline/**/*.py
ToolRuff + mypy

Validiert Python-Code in der KI-Pipeline:

View Structure Contract v1.0

Dateiview-structure-contract_v1.0.yaml
Statusactive
ScopeCRUD-Ressourcen: /src/View/tasks/*, /src/View/content/*

Validiert die Struktur von CRUD-Views (index, show, new, edit):

Gilt nicht für: /docs (eigener Contract), /chat (interaktives Tool), /home (Landing Pages)

Neue CRUD-Ressource hinzufügen

  1. Verzeichnis erstellen: /src/View/{resource}/
  2. Views anlegen: index.php, show.php, new.php, edit.php
  3. Contract-Scope erweitern: includes += "/src/View/{resource}/*.php"
  4. Vorlage: /src/View/tasks/* kopieren und anpassen

Zukünftige Contracts

Geplante Contracts für zukünftige Erweiterungen:

Severity Levels

LevelBedeutungAktion
criticalFaktisch falschDokument abgelehnt
majorUnvollständigÜberarbeitung nötig
minorKosmetischNur protokolliert

Pass-Schwelle

Automatische Validierung

Alle Contracts werden automatisch vor dem Sync zu Produktion geprüft.

Pre-Sync Hook

Script/opt/scripts/contract-check.sh
Aufruf/opt/scripts/contract-check.sh [path]
Integration/opt/scripts/sync-dev-prod.sh
Exit-Codes0 = OK, 1 = Critical, 2 = Major

Geprüfte Contracts

ContractPrüfungTool
View Structure v1.0Struktur, verbotene ElementeGrep
HTML Tables v1.0Modals, Aktionen-SpalteGrep
CSS Contract v1.0Styling-RegelnStylelint
Python Pipeline v1.0Code-Qualität, TypesRuff, mypy
Layered Architecture v1.0Layer-GrenzenGrep, find
Betriebsdokumentation v1.1StrukturGrep

Manuell ausführen

# Alle Contracts prüfen
/opt/scripts/contract-check.sh

# Mit spezifischem Pfad
/opt/scripts/contract-check.sh /var/www/dev.campus.systemische-tools.de