architecture-gate-contract

ID 11
UUID 00be3e7a-e6a5-4151-b973-39d36b2a0303
Version 1.1
Status active
Scope Mandatory analysis and validation for every new PHP file
Erstellt 2025-12-23 06:09:03 von supervision
Aktualisiert 2025-12-23 06:17:12

YAML-Inhalt

architecture_gate_contract:
  meta:
    name: architecture_gate_contract
    version: 1.1.0
    status: binding
    scope: every_new_php_file

  purpose:
    description: >
      Defines mandatory analysis and validation steps
      before and after creating any new file.

  hard_constraints:
    description: >
      Pre-creation blocking rules. These are enforced by architecture_guard.py
      and will block file creation if violated.
    applies_pre_creation: true
    rules:
      - id: H1
        name: strict_types_required
        pattern: "declare(strict_types=1)"
        must_match: true
        applies_to: all
        block: true

      - id: H2
        name: domain_no_infrastructure
        pattern: "use Infrastructure\\"
        must_match: false
        applies_to: "/Domain/"
        block: true

      - id: H3
        name: db_factory_only
        pattern: "DatabaseFactory::"
        must_match: false
        applies_to_not: "/Factory/"
        block: true

      - id: H4
        name: no_new_repository_in_controller
        pattern: "new \\w+Repository\\("
        must_match: false
        applies_to: "/Controller/"
        block: true

      - id: H5
        name: no_new_infrastructure_in_controller
        pattern: "new Infrastructure\\"
        must_match: false
        applies_to: "/Controller/"
        block: true

    allowlist:
      - "/Factory/"
      - "/Bootstrap/"
      - "/tests/"
      - "/Test/"

  phase_1_pre_creation_analysis:
    A1_purpose_definition:
      rule: exactly_one_purpose
      check: purpose_must_be_expressible_in_one_sentence

    A2_layer_assignment:
      rule: exactly_one_layer
      allowed_layers:
        - domain
        - application
        - infrastructure
        - presentation

    A3_responsibility_boundary:
      rule: explicit_exclusions_required
      check: non_responsibilities_must_be_named

    A4_dependency_analysis:
      rule: dependencies_must_be_known_upfront
      required:
        - required_dependencies_listed
        - forbidden_dependencies_listed

    A5_abstraction_level:
      rule: single_abstraction_level
      allowed:
        - policy
        - detail

    A6_data_representation:
      rule: explicit_decision_required
      allowed:
        - objects
        - value_objects
        - arrays

    A7_instantiation_source:
      rule: instantiation_must_be_defined
      allowed:
        - container
        - factory
        - explicit_creator

    A8_extension_strategy:
      rule: extension_without_modification
      check: open_closed_principle_addressed

    A9_test_strategy:
      rule: isolated_testability_required
      check: test_approach_defined

  phase_2_post_creation_validation:
    B1_srp:
      rule: single_responsibility
      violation_if: more_than_one_reason_to_change

    B2_dry:
      rule: no_logic_duplication
      violation_if: duplicated_behavior_detected

    B3_kiss:
      rule: minimal_complexity
      violation_if: unnecessary_abstractions_present

    B4_solid:
      rule: solid_principles_respected
      checks:
        - no_new_of_dependencies_in_business_code
        - no_static_infrastructure_access

    B5_dip:
      rule: dependency_direction_enforced
      violation_if: domain_depends_on_infrastructure

    B6_crud_discipline:
      rule: responsibility_separation
      mapping:
        controller: orchestration_only
        use_case: decision_logic
        repository: persistence_only

    B7_mvc_consistency:
      rule: mvc_roles_respected
      violation_if:
        - business_logic_in_controller
        - decision_logic_in_view

    B8_oop_integrity:
      rule: behavior_and_state_coupled
      violation_if: anemic_objects_without_reason

    B9_yagni:
      rule: no_future_speculation
      violation_if: unused_extension_points

    B10_type_consistency:
      rule: strict_typing_required
      checks:
        - strict_types_enabled
        - parameters_typed
        - return_types_defined

    B11_psr_conformance:
      rule: psr_compliance_required
      checks:
        - namespace_matches_path
        - class_name_matches_file

    B12_dependency_visibility:
      rule: explicit_dependencies_only
      check: all_dependencies_in_constructor

    B13_removability:
      rule: safe_deletion_possible
      check: no_hidden_side_effects

    B14_readability:
      rule: fast_comprehension
      check: purpose_and_boundary_understandable_in_minutes

  warning_indicators:
    description: >
      Post-creation warnings. These are enforced by architecture_validator.py
      and will warn but not block.
    applies_post_creation: true
    rules:
      - id: W1
        name: class_size
        check: line_count
        threshold: 300
        warn: true

      - id: W2
        name: constructor_complexity
        check: parameter_count
        threshold: 5
        warn: true

      - id: W3
        name: sql_in_controller
        check: sql_keywords
        applies_to: "/Controller/"
        warn: true

      - id: W4
        name: missing_phpdoc
        check: public_methods_without_doc
        warn: true

Aktionen

Bearbeiten

Versionshistorie

Version Geändert am Von Beschreibung
1.1 (aktuell) 2025-12-23 06:17:12 - -
1.0 2025-12-23 06:17:12 mcp-contracts Added hard_constraints section with 5 blocking rules (H1-H5), allowlist for exceptions, and warning_indicators section (W1-W4) based on supervision review
1.0 2025-12-23 06:09:58 user Contract aktiviert nach Supervision-Review

Letzte Validierungen

Datum Ergebnis Critical Major Minor Dauer
2025-12-25 11:06:26 passed 0 0 0 6ms

← Zurück zur Übersicht