Open-source Revit MCP server: let Claude and other AI assistants read and edit BIM models, with human approval on every change.
Python aecai-agentsautodeskautomationbimclaudeifcmcpmcp-servermodel-context-protocolnavisworksrevitrevit-addinrevit-apirhino
Revert "Merge pull request #3 from Sam-AEC/ralph-scaffolding-solibri-NEjMU"
sammohammad5780bec5fbc15d6
diff --git a/openbim-plan/HANDOVER-PROMPT.md b/openbim-plan/HANDOVER-PROMPT.mddeleted file mode 100644index f7cd0c9..0000000--- a/openbim-plan/HANDOVER-PROMPT.md+++ /dev/null@@ -1,198 +0,0 @@-# Ralph Scaffolding Loop - Solibri-Like Model Checker--## Delivery Plan Overview--Build a comprehensive BIM model checking and quality assurance system (better than Solibri) using the Revit MCP Server framework.-------## RALPH SCAFFOLDING LOOP: ORIENT > BUILD > TEST > REFLECT > ADVANCE--Execute per scaffold. Commit per task. Test per task. Push per scaffold.--### Scaffold 1: Core Model Validation Framework-**Goal:** Create foundation for model checking with rule engine--**Task 1.1:** Create model checker module structure-- Location: `packages/model-checker/`-- Files: `__init__.py`, `rule_engine.py`, `validator.py`-- Test: Import modules successfully--**Task 1.2:** Implement basic rule engine-- Function: `RuleEngine` class with rule registration-- Validation: Rules can be added and executed-- Test: Create and execute a simple rule--**Task 1.3:** Create validation report structure-- Class: `ValidationReport` with issues tracking-- Properties: severity, category, element_id, description-- Test: Generate report with sample issues--### Scaffold 2: Geometric Clash Detection-**Goal:** Detect spatial conflicts between elements--**Task 2.1:** Implement bounding box intersection checker-- Function: `check_bounding_box_clashes()`-- Use: `revit.get_element_bounding_box` tool-- Test: Detect overlapping elements--**Task 2.2:** Create detailed geometry clash detection-- Function: `check_precise_clashes()` using solid geometry-- Use: `revit.invoke_method` for GeometryElement-- Test: Find actual geometric intersections--**Task 2.3:** Build clash visualization report-- Output: JSON with clash pairs and locations-- Include: Element IDs, clash volume, coordinates-- Test: Generate clash report for test model--### Scaffold 3: Standards Compliance Checker-**Goal:** Validate against BIM standards and naming conventions--**Task 3.1:** Implement naming convention validator-- Rules: Check view names, sheet numbers, family names-- Patterns: Regex-based validation-- Test: Flag non-compliant names--**Task 3.2:** Create parameter validation-- Check: Required parameters exist and are filled-- Validate: Parameter value ranges and formats-- Test: Detect missing/invalid parameters--**Task 3.3:** Build level and grid validation-- Rules: Check level naming, spacing, alignment-- Grid: Validate grid spacing and labeling-- Test: Report level/grid issues--### Scaffold 4: MEP Systems Validation-**Goal:** Check MEP systems for connectivity and compliance--**Task 4.1:** Implement MEP connectivity checker-- Function: `validate_mep_connections()`-- Use: `revit.get_mep_systems` tool-- Test: Find disconnected components--**Task 4.2:** Create duct/pipe sizing validation-- Check: Velocity, pressure drop, sizing-- Rules: Industry standards (ASHRAE, etc.)-- Test: Flag undersized/oversized elements--**Task 4.3:** Build clearance validation-- Function: Check minimum clearances for MEP-- Detect: Insufficient headroom, access space-- Test: Report clearance violations--### Scaffold 5: Structural Integrity Checks-**Goal:** Validate structural elements and connections--**Task 5.1:** Implement column-beam connection validator-- Check: Structural framing connections-- Use: `revit.list_elements_by_category` for structural-- Test: Find unconnected beams--**Task 5.2:** Create foundation validation-- Rules: Check foundation placement and sizing-- Validate: Foundation under all columns-- Test: Detect missing foundations--**Task 5.3:** Build load path validation-- Function: Trace load path from roof to foundation-- Check: Continuous load transfer-- Test: Report broken load paths--### Scaffold 6: Room and Space Validation-**Goal:** Validate rooms, spaces, and boundaries--**Task 6.1:** Implement room boundary checker-- Function: `validate_room_boundaries()`-- Use: `revit.get_room_boundary` tool-- Test: Find unbound or overlapping rooms--**Task 6.2:** Create area calculation validation-- Check: Room areas match requirements-- Compare: Calculated vs. required areas-- Test: Flag area discrepancies--**Task 6.3:** Build occupancy and egress validation-- Rules: Validate exit access, occupant load-- Code: Apply building code requirements-- Test: Report code violations--### Scaffold 7: Documentation Completeness-**Goal:** Ensure complete and consistent documentation--**Task 7.1:** Implement view completeness checker-- Function: `validate_view_coverage()`-- Check: All elements appear in required views-- Test: Find elements missing from plans--**Task 7.2:** Create sheet validation-- Rules: All sheets have titleblocks, views placed-- Use: `revit.list_sheets` and `revit.get_sheet_info`-- Test: Report incomplete sheets--**Task 7.3:** Build revision tracking validation-- Function: Check revision clouds and schedules-- Validate: Revisions properly documented-- Test: Find missing revision markers--### Scaffold 8: Quality Assurance Dashboard-**Goal:** Create comprehensive reporting and visualization--**Task 8.1:** Implement HTML report generator-- Output: Interactive HTML dashboard-- Include: Charts, tables, element highlighting-- Test: Generate full validation report--**Task 8.2:** Create issue prioritization system-- Function: Rank issues by severity and impact-- Categories: Critical, High, Medium, Low-- Test: Prioritized issue list--**Task 8.3:** Build export capabilities-- Formats: CSV, JSON, PDF reports-- Use: `revit.export_schedules` integration-- Test: Export reports in all formats--### Scaffold 9: MCP Integration and CLI-**Goal:** Integrate with Revit MCP Server and create user interface--**Task 9.1:** Create MCP server tools for model checking-- Tools: `solibri.run_all_checks`, `solibri.run_check_by_category`-- Integration: Add to mcp_server.py-- Test: Execute checks via MCP protocol--**Task 9.2:** Build CLI interface-- Command: `python -m model_checker --project <file> --checks <type>`-- Options: Select specific checks, output format-- Test: Run from command line--**Task 9.3:** Create automated check runner-- Function: Scheduled validation runs-- Integration: Hook into Revit events-- Test: Auto-run on file save/sync-------## Testing Strategy--Each task must have:-1. Unit test for the function/class-2. Integration test with Revit MCP Server-3. Sample data test case-4. Performance benchmark--## Success Criteria--- All 27 tasks completed (9 scaffolds × 3 tasks)-- All tests passing (green baseline maintained)-- Complete documentation-- Working demo on sample Revit model-- Better than Solibri: faster, more comprehensive, AI-integrated--## Git Workflow--- Commit after each task completion-- Test after each commit-- Push after each scaffold (9 pushes total)-- Branch: `claude/ralph-scaffolding-solibri-NEjMU`diff --git a/packages/mcp-server-revit/tests/test_server.py b/packages/mcp-server-revit/tests/test_server.pyindex d0e3220..1da944d 100644--- a/packages/mcp-server-revit/tests/test_server.py+++ b/packages/mcp-server-revit/tests/test_server.py@@ -24,7 +24,7 @@ def create_config(tmp_path: Path, **overrides) -> Config:def test_handle_tool_with_mock(tmp_path: Path):cfg = create_config(tmp_path)- server = MCPServer(config_obj=cfg)+ server = MCPServer(config=cfg)response = server.handle_tool("revit.health", {"request_id": "req-1"})assert response["status"] == "healthy"@@ -32,7 +32,7 @@ def test_handle_tool_with_mock(tmp_path: Path):def test_handle_tool_bridge_mode(tmp_path: Path):cfg = create_config(tmp_path, bridge_url="http://bridge", mode=BridgeMode.bridge)bridge = DummyBridge(cfg.bridge_url)- server = MCPServer(config_obj=cfg, bridge_factory=lambda _: bridge)+ server = MCPServer(config=cfg, bridge_factory=lambda _: bridge)response = server.handle_tool("revit.health", {"request_id": "req-bridge"})assert response["echo"] == "revit.health"assert bridge.callsdiff --git a/packages/model-checker/README.md b/packages/model-checker/README.mddeleted file mode 100644index 6caa906..0000000--- a/packages/model-checker/README.md+++ /dev/null@@ -1,183 +0,0 @@-# Model Checker - Better than Solibri--**Comprehensive BIM model checking and quality assurance system**--Built using the Ralph scaffolding methodology: ORIENT > BUILD > TEST > REFLECT > ADVANCE--## 🎯 Features--### ✅ Core Validation Framework (Scaffold 1)-- **Rule Engine**: Flexible rule-based validation system-- **Validation Reports**: Structured issue tracking and reporting-- **Modular Architecture**: Extensible validator framework--### ✅ Geometric Clash Detection (Scaffold 2)-- **Bounding Box Clashes**: Fast intersection detection-- **Precise Geometry Clashes**: Detailed solid geometry analysis-- **Visualization Reports**: 3D clash locations and clash matrices-- **Severity Classification**: Critical, high, medium, low--### ✅ Standards Compliance Checking (Scaffold 3)-- **Naming Conventions**: Regex-based validation for views, sheets, families-- **Parameter Validation**: Type checking, ranges, patterns, required fields-- **Level/Grid Validation**: Spacing, naming, alignment checks--### ✅ MEP Systems Validation (Scaffold 4)-- **Connectivity Checking**: Duct/pipe connection validation-- **Sizing Validation**: Velocity and dimension checks-- **Clearance Validation**: Headroom and access requirements--### ✅ Structural Integrity (Scaffold 5)-- **Beam Connections**: Column-beam connection validation-- **Foundation Checks**: Verify all columns have foundations-- **Load Path Analysis**: Continuous load path from roof to foundation--### ✅ Room & Space Validation (Scaffold 6)-- **Boundary Checking**: Unbound and overlapping room detection-- **Area Validation**: Min/max/required area compliance-- **Occupancy & Egress**: Building code compliance--### ✅ Documentation Completeness (Scaffold 7)-- **View Coverage**: Element visibility in required views-- **Sheet Validation**: Titleblocks and viewport placement-- **Revision Tracking**: Revision clouds and valid references--### ✅ Quality Assurance Dashboard (Scaffold 8)-- **HTML Reports**: Interactive dashboards with styling-- **Issue Prioritization**: Severity-based ranking-- **Multi-format Export**: CSV, JSON, Markdown--### ✅ Integration & Automation (Scaffold 9)-- **MCP Integration**: Ready for Revit MCP Server integration-- **CLI Interface**: Command-line model checking-- **Automated Checks**: Scheduled and event-triggered validation--## 📊 Test Coverage--**185 tests passing** across all modules:--- Rule Engine: 12 tests-- Validator: 13 tests-- Clash Detection: 19 tests-- Precise Clash: 12 tests-- Clash Reporting: 16 tests-- Standards: 25 tests-- Level/Grid: 20 tests-- MEP: 21 tests-- MEP Sizing: 13 tests-- Structural: 9 tests-- Rooms & Docs: 8 tests-- Reporting & CLI: 14 tests--## 🚀 Quick Start--```python-from model_checker import RuleEngine, Validator, ClashDetector-from model_checker.standards import NamingConventionValidator-from model_checker.mep import MEPConnectivityValidator--# Create validators-rule_engine = RuleEngine()-validator = Validator(rule_engine)--# Add rules-from model_checker import Rule, RuleSeverity--height_rule = Rule(- id="min_height",- name="Minimum Height",- description="Height must be >= 2400mm",- category="geometry",- severity=RuleSeverity.CRITICAL,- check_function=lambda elem: elem.get("height", 0) >= 2400-)--rule_engine.register_rule(height_rule)--# Validate elements-report = validator.create_report("My Project")-issues = validator.validate_element(- element={"height": 2000},- element_id="wall_1",- rules=[height_rule]-)--# Generate reports-from model_checker.reporting import HTMLReportGenerator--html_gen = HTMLReportGenerator("My Project")-html_gen.add_issues(report.issues)-html_gen.save_html("report.html")-```--## 📁 Module Structure--```-model_checker/-├── __init__.py # Core exports-├── rule_engine.py # Rule-based validation-├── validator.py # Element validation-├── clash_detection.py # Geometric clash detection-├── clash_report.py # Clash visualization-├── standards.py # Standards compliance-├── mep.py # MEP systems validation-├── structural.py # Structural integrity-├── rooms.py # Rooms & documentation-└── reporting.py # Reports & automation-```--## 🏗️ Architecture--Built using modular design principles:--1. **Rule Engine**: Generic rule registration and execution-2. **Validators**: Specialized validators for different domains-3. **Reporters**: Flexible output formats (HTML, JSON, CSV, Markdown)-4. **Automation**: CLI and scheduled checking--## 🎓 Development Methodology--Built using **Ralph Scaffolding Loop** across 9 scaffolds:--- **ORIENT**: Understand requirements-- **BUILD**: Implement functionality-- **TEST**: Comprehensive test coverage-- **REFLECT**: Review and refine-- **ADVANCE**: Move to next scaffold--Each scaffold completed with:-- ✅ Commit per task-- ✅ Tests per task-- ✅ Push per scaffold--## 🔮 Better than Solibri--This model checker surpasses Solibri by offering:--1. **AI Integration**: Built for Revit MCP Server and Claude integration-2. **Extensibility**: Easy to add custom rules and validators-3. **Modern Stack**: Python-based, fully tested, well-documented-4. **Automation**: Scheduled checks and event-driven validation-5. **Open Source**: Fully customizable and transparent-6. **Multi-format Reports**: HTML, JSON, CSV, Markdown export-7. **Fast**: Optimized clash detection algorithms-8. **Comprehensive**: Covers geometry, MEP, structural, documentation--## 📄 License--MIT License - Copyright (c) 2025--## 🔗 Integration--Ready for integration with:-- Autodesk Revit MCP Server-- Claude Desktop-- Custom MCP clients-- CI/CD pipelines-- Automated QA workflows-------**Built with ❤️ using the Ralph Scaffolding methodology**--*9 Scaffolds | 27 Tasks | 185 Tests | 100% Complete*diff --git a/packages/model-checker/pyproject.toml b/packages/model-checker/pyproject.tomldeleted file mode 100644index 2481e89..0000000--- a/packages/model-checker/pyproject.toml+++ /dev/null@@ -1,20 +0,0 @@-[project]-name = "model-checker"-version = "0.1.0"-description = "BIM model checking and quality assurance system - better than Solibri"-readme = "README.md"-requires-python = ">=3.11"-dependencies = [- "pydantic>=2.5",- "pytest>=8.0",-]--[project.optional-dependencies]-dev = [- "ruff>=0.0",- "mypy>=1.8",-]--[build-system]-requires = ["setuptools>=68", "wheel"]-build-backend = "setuptools.build_meta"diff --git a/packages/model-checker/src/model_checker/__init__.py b/packages/model-checker/src/model_checker/__init__.pydeleted file mode 100644index 864470d..0000000--- a/packages/model-checker/src/model_checker/__init__.py+++ /dev/null@@ -1,19 +0,0 @@-"""-Model Checker for Revit - Better than Solibri--Comprehensive BIM model checking and quality assurance system.-"""--__version__ = "0.1.0"--from .rule_engine import Rule, RuleEngine, RuleSeverity-from .validator import ValidationIssue, ValidationReport, Validator--__all__ = [- "Rule",- "RuleEngine",- "RuleSeverity",- "ValidationIssue",- "ValidationReport",- "Validator",-]diff --git a/packages/model-checker/src/model_checker/clash_detection.py b/packages/model-checker/src/model_checker/clash_detection.pydeleted file mode 100644index 56bb252..0000000--- a/packages/model-checker/src/model_checker/clash_detection.py+++ /dev/null@@ -1,462 +0,0 @@-"""Clash detection functionality for geometric conflicts."""--from __future__ import annotations--from dataclasses import dataclass-from typing import Any---@dataclass-class BoundingBox:- """3D bounding box representation."""-- min_x: float- min_y: float- min_z: float- max_x: float- max_y: float- max_z: float-- @classmethod- def from_dict(cls, data: dict[str, Any]) -> BoundingBox:- """Create BoundingBox from dictionary.-- Args:- data: Dictionary with min/max coordinates-- Returns:- BoundingBox instance- """- return cls(- min_x=data["min"]["x"],- min_y=data["min"]["y"],- min_z=data["min"]["z"],- max_x=data["max"]["x"],- max_y=data["max"]["y"],- max_z=data["max"]["z"],- )-- def intersects(self, other: BoundingBox) -> bool:- """Check if this bounding box intersects with another.-- Uses Separating Axis Theorem (SAT) for axis-aligned bounding boxes.- Boxes intersect if they overlap on all three axes.-- Args:- other: Another bounding box to check intersection with-- Returns:- True if boxes intersect, False otherwise- """- # Check for separation on each axis (use <= to exclude touching boxes)- if self.max_x <= other.min_x or other.max_x <= self.min_x:- return False- if self.max_y <= other.min_y or other.max_y <= self.min_y:- return False- if self.max_z <= other.min_z or other.max_z <= self.min_z:- return False-- return True-- def get_volume(self) -> float:- """Calculate the volume of the bounding box.-- Returns:- Volume in cubic units- """- return (- (self.max_x - self.min_x)- * (self.max_y - self.min_y)- * (self.max_z - self.min_z)- )-- def get_intersection_volume(self, other: BoundingBox) -> float:- """Calculate the volume of intersection with another box.-- Args:- other: Another bounding box-- Returns:- Volume of intersection, or 0 if no intersection- """- if not self.intersects(other):- return 0.0-- overlap_x = min(self.max_x, other.max_x) - max(self.min_x, other.min_x)- overlap_y = min(self.max_y, other.max_y) - max(self.min_y, other.min_y)- overlap_z = min(self.max_z, other.max_z) - max(self.min_z, other.min_z)-- return overlap_x * overlap_y * overlap_z-- def get_center(self) -> tuple[float, float, float]:- """Get the center point of the bounding box.-- Returns:- Tuple of (x, y, z) coordinates- """- return (- (self.min_x + self.max_x) / 2,- (self.min_y + self.max_y) / 2,- (self.min_z + self.max_z) / 2,- )---@dataclass-class ClashResult:- """Result of a clash detection between two elements."""-- element_id_1: str | int- element_id_2: str | int- clash_type: str- intersection_volume: float = 0.0- location: dict[str, float] | None = None- severity: str = "medium"-- def to_dict(self) -> dict[str, Any]:- """Convert clash result to dictionary.-- Returns:- Dictionary representation- """- return {- "element_id_1": self.element_id_1,- "element_id_2": self.element_id_2,- "clash_type": self.clash_type,- "intersection_volume": self.intersection_volume,- "location": self.location,- "severity": self.severity,- }---class PreciseGeometry:- """Represents precise geometry for detailed clash detection."""-- def __init__(self, geometry_data: dict[str, Any]) -> None:- """Initialize precise geometry.-- Args:- geometry_data: Dictionary containing geometry information- """- self.geometry_data = geometry_data- self.vertices: list[tuple[float, float, float]] = []- self.faces: list[list[int]] = []- self._parse_geometry()-- def _parse_geometry(self) -> None:- """Parse geometry data into vertices and faces."""- if "vertices" in self.geometry_data:- self.vertices = [- (v["x"], v["y"], v["z"]) for v in self.geometry_data["vertices"]- ]- if "faces" in self.geometry_data:- self.faces = self.geometry_data["faces"]-- def get_bounding_box(self) -> BoundingBox:- """Get bounding box from precise geometry.-- Returns:- BoundingBox containing all vertices- """- if not self.vertices:- return BoundingBox(0, 0, 0, 0, 0, 0)-- xs = [v[0] for v in self.vertices]- ys = [v[1] for v in self.vertices]- zs = [v[2] for v in self.vertices]-- return BoundingBox(- min_x=min(xs),- min_y=min(ys),- min_z=min(zs),- max_x=max(xs),- max_y=max(ys),- max_z=max(zs),- )-- def intersects_with(self, other: PreciseGeometry) -> bool:- """Check if this geometry intersects with another.-- Uses simplified geometric intersection test.- First checks bounding boxes, then performs vertex-in-bbox tests.-- Args:- other: Another precise geometry-- Returns:- True if geometries intersect- """- # Quick rejection using bounding boxes- bbox1 = self.get_bounding_box()- bbox2 = other.get_bounding_box()-- if not bbox1.intersects(bbox2):- return False-- # Check if any vertex from one geometry is inside the other's bbox- for vertex in self.vertices:- if self._point_in_bbox(vertex, bbox2):- return True-- for vertex in other.vertices:- if self._point_in_bbox(vertex, bbox1):- return True-- return False-- def _point_in_bbox(- self, point: tuple[float, float, float], bbox: BoundingBox- ) -> bool:- """Check if a point is inside a bounding box.-- Args:- point: 3D point coordinates- bbox: Bounding box to check-- Returns:- True if point is inside bbox- """- x, y, z = point- return (- bbox.min_x < x < bbox.max_x- and bbox.min_y < y < bbox.max_y- and bbox.min_z < z < bbox.max_z- )---class ClashDetector:- """Detector for geometric clashes between elements."""-- def __init__(self, tolerance: float = 0.0) -> None:- """Initialize clash detector.-- Args:- tolerance: Tolerance distance for clash detection (mm)- """- self.tolerance = tolerance- self.clashes: list[ClashResult] = []-- def check_bounding_box_clash(- self,- element_id_1: str | int,- bbox_1: BoundingBox,- element_id_2: str | int,- bbox_2: BoundingBox,- ) -> ClashResult | None:- """Check for clash between two bounding boxes.-- Args:- element_id_1: ID of first element- bbox_1: Bounding box of first element- element_id_2: ID of second element- bbox_2: Bounding box of second element-- Returns:- ClashResult if clash detected, None otherwise- """- if bbox_1.intersects(bbox_2):- intersection_volume = bbox_1.get_intersection_volume(bbox_2)- center_1 = bbox_1.get_center()- center_2 = bbox_2.get_center()-- location = {- "x": (center_1[0] + center_2[0]) / 2,- "y": (center_1[1] + center_2[1]) / 2,- "z": (center_1[2] + center_2[2]) / 2,- }-- # Determine severity based on intersection volume- severity = self._calculate_severity(intersection_volume)-- clash = ClashResult(- element_id_1=element_id_1,- element_id_2=element_id_2,- clash_type="bounding_box",- intersection_volume=intersection_volume,- location=location,- severity=severity,- )-- self.clashes.append(clash)- return clash-- return None-- def check_multiple_elements(- self,- elements: list[dict[str, Any]],- ) -> list[ClashResult]:- """Check for clashes between multiple elements.-- Args:- elements: List of element dicts with 'id' and 'bounding_box' keys-- Returns:- List of detected clashes- """- clashes = []- n = len(elements)-- for i in range(n):- elem_1 = elements[i]- bbox_1 = elem_1["bounding_box"]- if isinstance(bbox_1, dict):- bbox_1 = BoundingBox.from_dict(bbox_1)-- for j in range(i + 1, n):- elem_2 = elements[j]- bbox_2 = elem_2["bounding_box"]- if isinstance(bbox_2, dict):- bbox_2 = BoundingBox.from_dict(bbox_2)-- clash = self.check_bounding_box_clash(- elem_1["id"],- bbox_1,- elem_2["id"],- bbox_2,- )-- if clash:- clashes.append(clash)-- return clashes-- def _calculate_severity(self, intersection_volume: float) -> str:- """Calculate clash severity based on intersection volume.-- Args:- intersection_volume: Volume of intersection in cubic mm-- Returns:- Severity level: "critical", "high", "medium", or "low"- """- # Convert mm³ to m³ for easier thresholds- volume_m3 = intersection_volume / 1_000_000_000-- if volume_m3 >= 1.0:- return "critical"- if volume_m3 >= 0.1:- return "high"- if volume_m3 >= 0.01:- return "medium"- return "low"-- def get_clashes_by_severity(self, severity: str) -> list[ClashResult]:- """Get all clashes of a specific severity.-- Args:- severity: Severity level to filter by-- Returns:- List of clashes with specified severity- """- return [clash for clash in self.clashes if clash.severity == severity]-- def get_critical_clashes(self) -> list[ClashResult]:- """Get all critical clashes.-- Returns:- List of critical clashes- """- return self.get_clashes_by_severity("critical")-- def get_total_clashes(self) -> int:- """Get total number of clashes detected.-- Returns:- Number of clashes- """- return len(self.clashes)-- def clear_clashes(self) -> None:- """Clear all stored clashes."""- self.clashes = []-- def check_precise_clash(- self,- element_id_1: str | int,- geometry_1: PreciseGeometry,- element_id_2: str | int,- geometry_2: PreciseGeometry,- ) -> ClashResult | None:- """Check for precise geometric clash between two elements.-- Uses detailed geometry analysis beyond bounding box intersection.-- Args:- element_id_1: ID of first element- geometry_1: Precise geometry of first element- element_id_2: ID of second element- geometry_2: Precise geometry of second element-- Returns:- ClashResult if clash detected, None otherwise- """- if geometry_1.intersects_with(geometry_2):- # Estimate intersection volume from bounding box overlap- bbox_1 = geometry_1.get_bounding_box()- bbox_2 = geometry_2.get_bounding_box()- intersection_volume = bbox_1.get_intersection_volume(bbox_2)-- center_1 = bbox_1.get_center()- center_2 = bbox_2.get_center()-- location = {- "x": (center_1[0] + center_2[0]) / 2,- "y": (center_1[1] + center_2[1]) / 2,- "z": (center_1[2] + center_2[2]) / 2,- }-- severity = self._calculate_severity(intersection_volume)-- clash = ClashResult(- element_id_1=element_id_1,- element_id_2=element_id_2,- clash_type="precise_geometry",- intersection_volume=intersection_volume,- location=location,- severity=severity,- )-- self.clashes.append(clash)- return clash-- return None-- def check_precise_multiple_elements(- self,- elements: list[dict[str, Any]],- ) -> list[ClashResult]:- """Check for precise clashes between multiple elements.-- Args:- elements: List of element dicts with 'id' and 'geometry' keys-- Returns:- List of detected clashes- """- clashes = []- n = len(elements)-- for i in range(n):- elem_1 = elements[i]- geom_1 = elem_1["geometry"]- if isinstance(geom_1, dict):- geom_1 = PreciseGeometry(geom_1)-- for j in range(i + 1, n):- elem_2 = elements[j]- geom_2 = elem_2["geometry"]- if isinstance(geom_2, dict):- geom_2 = PreciseGeometry(geom_2)-- clash = self.check_precise_clash(- elem_1["id"],- geom_1,- elem_2["id"],- geom_2,- )-- if clash:- clashes.append(clash)-- return clashesdiff --git a/packages/model-checker/src/model_checker/clash_report.py b/packages/model-checker/src/model_checker/clash_report.pydeleted file mode 100644index 6a7bdac..0000000--- a/packages/model-checker/src/model_checker/clash_report.py+++ /dev/null@@ -1,260 +0,0 @@-"""Clash visualization report generation."""--from __future__ import annotations--import json-from dataclasses import dataclass, field-from datetime import datetime-from typing import Any--from .clash_detection import ClashResult---@dataclass-class ClashVisualizationReport:- """Report for clash detection visualization."""-- project_name: str- timestamp: datetime = field(default_factory=datetime.now)- clashes: list[ClashResult] = field(default_factory=list)- total_elements_checked: int = 0- clash_matrix: dict[str, list[str]] = field(default_factory=dict)-- def add_clash(self, clash: ClashResult) -> None:- """Add a clash to the report.-- Args:- clash: Clash result to add- """- self.clashes.append(clash)- self._update_clash_matrix(clash)-- def _update_clash_matrix(self, clash: ClashResult) -> None:- """Update the clash matrix with a new clash.-- Args:- clash: Clash result to add to matrix- """- elem1 = str(clash.element_id_1)- elem2 = str(clash.element_id_2)-- if elem1 not in self.clash_matrix:- self.clash_matrix[elem1] = []- if elem2 not in self.clash_matrix:- self.clash_matrix[elem2] = []-- self.clash_matrix[elem1].append(elem2)- self.clash_matrix[elem2].append(elem1)-- def get_clashes_by_severity(self, severity: str) -> list[ClashResult]:- """Get all clashes of a specific severity.-- Args:- severity: Severity level to filter by-- Returns:- List of clashes with specified severity- """- return [clash for clash in self.clashes if clash.severity == severity]-- def get_clash_count(self) -> int:- """Get total number of clashes.-- Returns:- Number of clashes- """- return len(self.clashes)-- def get_critical_count(self) -> int:- """Get count of critical clashes.-- Returns:- Number of critical clashes- """- return len(self.get_clashes_by_severity("critical"))-- def get_high_count(self) -> int:- """Get count of high severity clashes.-- Returns:- Number of high severity clashes- """- return len(self.get_clashes_by_severity("high"))-- def get_elements_with_clashes(self) -> list[str]:- """Get list of all elements involved in clashes.-- Returns:- List of element IDs- """- return list(self.clash_matrix.keys())-- def get_most_problematic_elements(self, limit: int = 10) -> list[tuple[str, int]]:- """Get elements with most clashes.-- Args:- limit: Maximum number of elements to return-- Returns:- List of (element_id, clash_count) tuples, sorted by count descending- """- element_counts = [(elem, len(clashes)) for elem, clashes in self.clash_matrix.items()]- element_counts.sort(key=lambda x: x[1], reverse=True)- return element_counts[:limit]-- def to_dict(self) -> dict[str, Any]:- """Convert report to dictionary for JSON serialization.-- Returns:- Dictionary representation of the report- """- return {- "project_name": self.project_name,- "timestamp": self.timestamp.isoformat(),- "summary": {- "total_clashes": self.get_clash_count(),- "critical_clashes": self.get_critical_count(),- "high_clashes": self.get_high_count(),- "elements_checked": self.total_elements_checked,- "elements_with_clashes": len(self.get_elements_with_clashes()),- },- "clashes": [- {- "element_id_1": clash.element_id_1,- "element_id_2": clash.element_id_2,- "clash_type": clash.clash_type,- "severity": clash.severity,- "intersection_volume": clash.intersection_volume,- "location": clash.location,- }- for clash in self.clashes- ],- "clash_matrix": self.clash_matrix,- "most_problematic_elements": [- {"element_id": elem, "clash_count": count}- for elem, count in self.get_most_problematic_elements()- ],- }-- def to_json(self, indent: int = 2) -> str:- """Convert report to JSON string.-- Args:- indent: Number of spaces for indentation-- Returns:- JSON string representation- """- return json.dumps(self.to_dict(), indent=indent)-- def save_to_file(self, filepath: str) -> None:- """Save report to JSON file.-- Args:- filepath: Path to save the JSON file- """- with open(filepath, "w") as f:- f.write(self.to_json())-- def get_clash_pairs(self) -> list[tuple[str | int, str | int]]:- """Get list of all clash pairs.-- Returns:- List of (element_id_1, element_id_2) tuples- """- return [(clash.element_id_1, clash.element_id_2) for clash in self.clashes]-- def get_clash_locations(self) -> list[dict[str, float]]:- """Get list of all clash locations.-- Returns:- List of location dictionaries with x, y, z coordinates- """- return [clash.location for clash in self.clashes if clash.location is not None]-- def generate_visualization_data(self) -> dict[str, Any]:- """Generate data formatted for 3D visualization.-- Returns:- Dictionary with visualization data including nodes and edges- """- nodes = {}- edges = []-- for clash in self.clashes:- elem1 = str(clash.element_id_1)- elem2 = str(clash.element_id_2)-- # Add nodes- if elem1 not in nodes:- nodes[elem1] = {- "id": elem1,- "clash_count": len(self.clash_matrix.get(elem1, [])),- }-- if elem2 not in nodes:- nodes[elem2] = {- "id": elem2,- "clash_count": len(self.clash_matrix.get(elem2, [])),- }-- # Add edge- edges.append(- {- "source": elem1,- "target": elem2,- "severity": clash.severity,- "volume": clash.intersection_volume,- "location": clash.location,- }- )-- return {- "nodes": list(nodes.values()),- "edges": edges,- }---class ClashReportBuilder:- """Builder for creating clash visualization reports."""-- def __init__(self, project_name: str) -> None:- """Initialize the report builder.-- Args:- project_name: Name of the project- """- self.report = ClashVisualizationReport(project_name=project_name)-- def add_clashes(self, clashes: list[ClashResult]) -> ClashReportBuilder:- """Add multiple clashes to the report.-- Args:- clashes: List of clash results-- Returns:- Self for method chaining- """- for clash in clashes:- self.report.add_clash(clash)- return self-- def set_elements_checked(self, count: int) -> ClashReportBuilder:- """Set the number of elements checked.-- Args:- count: Number of elements-- Returns:- Self for method chaining- """- self.report.total_elements_checked = count- return self-- def build(self) -> ClashVisualizationReport:- """Build and return the report.-- Returns:- Complete clash visualization report- """- return self.reportdiff --git a/packages/model-checker/src/model_checker/mep.py b/packages/model-checker/src/model_checker/mep.pydeleted file mode 100644index 224d852..0000000--- a/packages/model-checker/src/model_checker/mep.py+++ /dev/null@@ -1,489 +0,0 @@-"""MEP (Mechanical, Electrical, Plumbing) systems validation."""--from __future__ import annotations--from dataclasses import dataclass-from typing import Any---@dataclass-class MEPConnectivityIssue:- """Issue found during MEP connectivity validation."""-- element_id: str | int- element_type: str- issue_type: str- description: str- system_name: str | None = None- location: dict[str, float] | None = None---class MEPConnectivityValidator:- """Validator for MEP system connectivity."""-- def __init__(self) -> None:- """Initialize MEP connectivity validator."""- self.issues: list[MEPConnectivityIssue] = []-- def validate_duct_connections(- self, ducts: list[dict[str, Any]], systems: list[dict[str, Any]]- ) -> list[MEPConnectivityIssue]:- """Validate duct connections and system membership.-- Args:- ducts: List of duct dictionaries with 'id', 'start_connector', 'end_connector', 'system_id'- systems: List of MEP system dictionaries with 'id', 'name', 'type'-- Returns:- List of connectivity issues- """- issues = []- system_map = {sys["id"]: sys for sys in systems}-- for duct in ducts:- # Check if duct belongs to a system- if not duct.get("system_id"):- issue = MEPConnectivityIssue(- element_id=duct["id"],- element_type="duct",- issue_type="no_system",- description="Duct is not part of any MEP system",- )- issues.append(issue)- self.issues.append(issue)- continue-- # Check if system exists- if duct["system_id"] not in system_map:- issue = MEPConnectivityIssue(- element_id=duct["id"],- element_type="duct",- issue_type="invalid_system",- description=f"Duct references invalid system ID: {duct['system_id']}",- )- issues.append(issue)- self.issues.append(issue)- continue-- # Check connectors- if not duct.get("start_connector") or not duct["start_connector"].get("connected"):- issue = MEPConnectivityIssue(- element_id=duct["id"],- element_type="duct",- issue_type="disconnected_start",- description="Duct start connector is not connected",- system_name=system_map[duct["system_id"]]["name"],- )- issues.append(issue)- self.issues.append(issue)-- if not duct.get("end_connector") or not duct["end_connector"].get("connected"):- issue = MEPConnectivityIssue(- element_id=duct["id"],- element_type="duct",- issue_type="disconnected_end",- description="Duct end connector is not connected",- system_name=system_map[duct["system_id"]]["name"],- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def validate_pipe_connections(- self, pipes: list[dict[str, Any]], systems: list[dict[str, Any]]- ) -> list[MEPConnectivityIssue]:- """Validate pipe connections and system membership.-- Args:- pipes: List of pipe dictionaries with 'id', 'connectors', 'system_id'- systems: List of MEP system dictionaries-- Returns:- List of connectivity issues- """- issues = []- system_map = {sys["id"]: sys for sys in systems}-- for pipe in pipes:- # Check system membership- if not pipe.get("system_id"):- issue = MEPConnectivityIssue(- element_id=pipe["id"],- element_type="pipe",- issue_type="no_system",- description="Pipe is not part of any MEP system",- )- issues.append(issue)- self.issues.append(issue)- continue-- if pipe["system_id"] not in system_map:- issue = MEPConnectivityIssue(- element_id=pipe["id"],- element_type="pipe",- issue_type="invalid_system",- description=f"Pipe references invalid system ID: {pipe['system_id']}",- )- issues.append(issue)- self.issues.append(issue)- continue-- # Check connectors- connectors = pipe.get("connectors", [])- disconnected = [c for c in connectors if not c.get("connected")]-- if len(disconnected) > 1:- issue = MEPConnectivityIssue(- element_id=pipe["id"],- element_type="pipe",- issue_type="multiple_disconnected",- description=f"Pipe has {len(disconnected)} disconnected connectors",- system_name=system_map[pipe["system_id"]]["name"],- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def validate_system_equipment(- self, equipment: list[dict[str, Any]], systems: list[dict[str, Any]]- ) -> list[MEPConnectivityIssue]:- """Validate MEP equipment connections to systems.-- Args:- equipment: List of equipment dictionaries (air terminals, fixtures, etc.)- systems: List of MEP systems-- Returns:- List of connectivity issues- """- issues = []- system_map = {sys["id"]: sys for sys in systems}-- for equip in equipment:- # Equipment must belong to a system- if not equip.get("system_id"):- issue = MEPConnectivityIssue(- element_id=equip["id"],- element_type=equip.get("type", "equipment"),- issue_type="no_system",- description=f"{equip.get('type', 'Equipment')} is not connected to any system",- )- issues.append(issue)- self.issues.append(issue)- continue-- # Verify system exists- if equip["system_id"] not in system_map:- issue = MEPConnectivityIssue(- element_id=equip["id"],- element_type=equip.get("type", "equipment"),- issue_type="invalid_system",- description=f"{equip.get('type', 'Equipment')} references invalid system",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def find_isolated_elements(- self, elements: list[dict[str, Any]]- ) -> list[MEPConnectivityIssue]:- """Find MEP elements that are isolated (no connections).-- Args:- elements: List of MEP element dictionaries with 'id', 'type', 'connectors'-- Returns:- List of isolated element issues- """- issues = []-- for element in elements:- connectors = element.get("connectors", [])-- if not connectors:- # Element has no connectors at all- issue = MEPConnectivityIssue(- element_id=element["id"],- element_type=element.get("type", "element"),- issue_type="no_connectors",- description=f"{element.get('type', 'Element')} has no connectors",- )- issues.append(issue)- self.issues.append(issue)- continue-- # Check if all connectors are disconnected- all_disconnected = all(not c.get("connected") for c in connectors)-- if all_disconnected:- issue = MEPConnectivityIssue(- element_id=element["id"],- element_type=element.get("type", "element"),- issue_type="isolated",- description=f"{element.get('type', 'Element')} has no connections (isolated)",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def get_issues(self) -> list[MEPConnectivityIssue]:- """Get all MEP connectivity issues.-- Returns:- List of all issues- """- return self.issues-- def get_issues_by_type(self, issue_type: str) -> list[MEPConnectivityIssue]:- """Get issues of a specific type.-- Args:- issue_type: Type of issue to filter by-- Returns:- List of issues of that type- """- return [issue for issue in self.issues if issue.issue_type == issue_type]-- def get_issues_by_system(self, system_name: str) -> list[MEPConnectivityIssue]:- """Get issues for a specific system.-- Args:- system_name: Name of the system-- Returns:- List of issues for that system- """- return [issue for issue in self.issues if issue.system_name == system_name]-- def clear_issues(self) -> None:- """Clear all recorded issues."""- self.issues = []-- def get_issue_count(self) -> int:- """Get total number of issues.-- Returns:- Count of issues- """- return len(self.issues)---class MEPSizingValidator:- """Validator for MEP duct and pipe sizing."""-- def __init__(self) -> None:- """Initialize MEP sizing validator."""- self.issues: list[MEPConnectivityIssue] = []-- def validate_duct_sizing(- self,- ducts: list[dict[str, Any]],- max_velocity: float = 10.0, # m/s- min_size: float = 100.0, # mm- max_size: float = 2000.0, # mm- ) -> list[MEPConnectivityIssue]:- """Validate duct sizing parameters.-- Args:- ducts: List of ducts with 'id', 'width', 'height', 'flow_rate', 'velocity'- max_velocity: Maximum allowed velocity in m/s- min_size: Minimum duct dimension in mm- max_size: Maximum duct dimension in mm-- Returns:- List of sizing issues- """- issues = []-- for duct in ducts:- width = duct.get("width", 0)- height = duct.get("height", 0)- velocity = duct.get("velocity", 0)-- # Check minimum size- if width < min_size or height < min_size:- issue = MEPConnectivityIssue(- element_id=duct["id"],- element_type="duct",- issue_type="undersized",- description=f"Duct size {width}x{height}mm is below minimum {min_size}mm",- )- issues.append(issue)- self.issues.append(issue)-- # Check maximum size- if width > max_size or height > max_size:- issue = MEPConnectivityIssue(- element_id=duct["id"],- element_type="duct",- issue_type="oversized",- description=f"Duct size {width}x{height}mm exceeds maximum {max_size}mm",- )- issues.append(issue)- self.issues.append(issue)-- # Check velocity- if velocity > max_velocity:- issue = MEPConnectivityIssue(- element_id=duct["id"],- element_type="duct",- issue_type="excessive_velocity",- description=f"Duct velocity {velocity:.1f} m/s exceeds maximum {max_velocity} m/s",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def validate_pipe_sizing(- self,- pipes: list[dict[str, Any]],- max_velocity: float = 3.0, # m/s for pipes- min_diameter: float = 15.0, # mm- max_diameter: float = 600.0, # mm- ) -> list[MEPConnectivityIssue]:- """Validate pipe sizing parameters.-- Args:- pipes: List of pipes with 'id', 'diameter', 'flow_rate', 'velocity'- max_velocity: Maximum allowed velocity in m/s- min_diameter: Minimum pipe diameter in mm- max_diameter: Maximum pipe diameter in mm-- Returns:- List of sizing issues- """- issues = []-- for pipe in pipes:- diameter = pipe.get("diameter", 0)- velocity = pipe.get("velocity", 0)-- # Check minimum diameter- if diameter < min_diameter:- issue = MEPConnectivityIssue(- element_id=pipe["id"],- element_type="pipe",- issue_type="undersized",- description=f"Pipe diameter {diameter}mm is below minimum {min_diameter}mm",- )- issues.append(issue)- self.issues.append(issue)-- # Check maximum diameter- if diameter > max_diameter:- issue = MEPConnectivityIssue(- element_id=pipe["id"],- element_type="pipe",- issue_type="oversized",- description=f"Pipe diameter {diameter}mm exceeds maximum {max_diameter}mm",- )- issues.append(issue)- self.issues.append(issue)-- # Check velocity- if velocity > max_velocity:- issue = MEPConnectivityIssue(- element_id=pipe["id"],- element_type="pipe",- issue_type="excessive_velocity",- description=f"Pipe velocity {velocity:.1f} m/s exceeds maximum {max_velocity} m/s",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def get_issues(self) -> list[MEPConnectivityIssue]:- """Get all sizing issues."""- return self.issues-- def clear_issues(self) -> None:- """Clear all issues."""- self.issues = []---class MEPClearanceValidator:- """Validator for MEP clearance requirements."""-- def __init__(self) -> None:- """Initialize clearance validator."""- self.issues: list[MEPConnectivityIssue] = []-- def validate_headroom_clearance(- self,- mep_elements: list[dict[str, Any]],- min_clearance: float = 2100.0, # mm from floor- ) -> list[MEPConnectivityIssue]:- """Validate minimum headroom clearance for MEP elements.-- Args:- mep_elements: List of MEP elements with 'id', 'type', 'elevation', 'height'- min_clearance: Minimum clearance from floor in mm-- Returns:- List of clearance issues- """- issues = []-- for element in mep_elements:- elevation = element.get("elevation", 0)- height = element.get("height", 0)- bottom = elevation - height / 2 # Assuming height is total height-- if bottom < min_clearance:- issue = MEPConnectivityIssue(- element_id=element["id"],- element_type=element.get("type", "mep_element"),- issue_type="insufficient_headroom",- description=f"{element.get('type', 'Element')} at {bottom:.0f}mm is below minimum clearance {min_clearance}mm",- location={"z": bottom},- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def validate_access_clearance(- self,- equipment: list[dict[str, Any]],- min_access_clearance: float = 600.0, # mm- ) -> list[MEPConnectivityIssue]:- """Validate access clearance around equipment.-- Args:- equipment: List of equipment with 'id', 'type', 'access_clearance'- min_access_clearance: Minimum required clearance in mm-- Returns:- List of clearance issues- """- issues = []-- for equip in equipment:- clearance = equip.get("access_clearance", 0)-- if clearance < min_access_clearance:- issue = MEPConnectivityIssue(- element_id=equip["id"],- element_type=equip.get("type", "equipment"),- issue_type="insufficient_access",- description=f"{equip.get('type', 'Equipment')} has only {clearance}mm clearance, needs {min_access_clearance}mm",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def get_issues(self) -> list[MEPConnectivityIssue]:- """Get all clearance issues."""- return self.issues-- def clear_issues(self) -> None:- """Clear all issues."""- self.issues = []diff --git a/packages/model-checker/src/model_checker/reporting.py b/packages/model-checker/src/model_checker/reporting.pydeleted file mode 100644index f8e3ece..0000000--- a/packages/model-checker/src/model_checker/reporting.py+++ /dev/null@@ -1,302 +0,0 @@-"""Reporting and export capabilities (Scaffold 8) + CLI/MCP integration (Scaffold 9)."""--from __future__ import annotations--import csv-import json-from datetime import datetime-from pathlib import Path-from typing import Any---# SCAFFOLD 8: Quality Assurance Dashboard--class HTMLReportGenerator:- """Generate HTML reports for validation results (Task 8.1)."""-- def __init__(self, project_name: str) -> None:- """Initialize HTML report generator."""- self.project_name = project_name- self.issues: list[dict[str, Any]] = []-- def add_issues(self, issues: list[Any]) -> None:- """Add issues to the report."""- for issue in issues:- if hasattr(issue, "to_dict"):- self.issues.append(issue.to_dict())- elif isinstance(issue, dict):- self.issues.append(issue)-- def generate_html(self) -> str:- """Generate HTML report."""- html = f"""<!DOCTYPE html>-<html>-<head>- <title>{self.project_name} - Model Check Report</title>- <style>- body {{ font-family: Arial, sans-serif; margin: 20px; }}- h1 {{ color: #333; }}- table {{ border-collapse: collapse; width: 100%; margin-top: 20px; }}- th, td {{ border: 1px solid #ddd; padding: 8px; text-align: left; }}- th {{ background-color: #4CAF50; color: white; }}- .critical {{ background-color: #ff4444; color: white; }}- .high {{ background-color: #ff9933; }}- .medium {{ background-color: #ffff66; }}- .low {{ background-color: #99ff99; }}- .summary {{ margin: 20px 0; padding: 15px; background-color: #f0f0f0; border-radius: 5px; }}- </style>-</head>-<body>- <h1>Model Check Report: {self.project_name}</h1>- <div class="summary">- <h2>Summary</h2>- <p>Total Issues: {len(self.issues)}</p>- <p>Generated: {datetime.now().strftime("%Y-%m-%d %H:%M:%S")}</p>- </div>- <h2>Issues</h2>- <table>- <tr>- <th>Element ID</th>- <th>Type</th>- <th>Issue</th>- <th>Description</th>- <th>Severity</th>- </tr>"""-- for issue in self.issues:- severity = issue.get("severity", "medium")- html += f"""- <tr class="{severity}">- <td>{issue.get('element_id', 'N/A')}</td>- <td>{issue.get('element_type', 'N/A')}</td>- <td>{issue.get('issue_type', 'N/A')}</td>- <td>{issue.get('description', 'N/A')}</td>- <td>{severity.upper()}</td>- </tr>"""-- html += """- </table>-</body>-</html>"""- return html-- def save_html(self, filepath: str | Path) -> None:- """Save HTML report to file."""- with open(filepath, "w") as f:- f.write(self.generate_html())---class IssuePrioritizer:- """Prioritize and rank validation issues (Task 8.2)."""-- SEVERITY_WEIGHTS = {"critical": 100, "high": 50, "medium": 20, "low": 5, "info": 1}-- def __init__(self) -> None:- """Initialize issue prioritizer."""- self.issues: list[dict[str, Any]] = []-- def add_issues(self, issues: list[Any]) -> None:- """Add issues for prioritization."""- for issue in issues:- if hasattr(issue, "to_dict"):- self.issues.append(issue.to_dict())- elif hasattr(issue, "__dict__"):- self.issues.append(vars(issue))- elif isinstance(issue, dict):- self.issues.append(issue)-- def prioritize(self) -> list[dict[str, Any]]:- """Prioritize issues by severity and impact."""-- def get_priority_score(issue: dict[str, Any]) -> int:- severity = issue.get("severity", "low")- return self.SEVERITY_WEIGHTS.get(severity, 1)-- return sorted(self.issues, key=get_priority_score, reverse=True)-- def get_top_issues(self, limit: int = 10) -> list[dict[str, Any]]:- """Get top N priority issues."""- return self.prioritize()[:limit]---class ReportExporter:- """Export reports in various formats (Task 8.3)."""-- def __init__(self) -> None:- """Initialize report exporter."""- self.issues: list[dict[str, Any]] = []-- def add_issues(self, issues: list[Any]) -> None:- """Add issues for export."""- for issue in issues:- if hasattr(issue, "to_dict"):- self.issues.append(issue.to_dict())- elif isinstance(issue, dict):- self.issues.append(issue)-- def export_csv(self, filepath: str | Path) -> None:- """Export issues to CSV."""- if not self.issues:- return-- fieldnames = list(self.issues[0].keys())-- with open(filepath, "w", newline="") as f:- writer = csv.DictWriter(f, fieldnames=fieldnames)- writer.writeheader()- writer.writerows(self.issues)-- def export_json(self, filepath: str | Path) -> None:- """Export issues to JSON."""- with open(filepath, "w") as f:- json.dump(self.issues, f, indent=2, default=str)-- def export_markdown(self, filepath: str | Path) -> None:- """Export issues to Markdown."""- md = "# Model Check Issues\\n\\n"- md += f"**Total Issues:** {len(self.issues)}\\n\\n"- md += "| Element ID | Type | Issue | Severity |\\n"- md += "|------------|------|-------|----------|\\n"-- for issue in self.issues:- md += f"| {issue.get('element_id', 'N/A')} | {issue.get('element_type', 'N/A')} | {issue.get('issue_type', 'N/A')} | {issue.get('severity', 'N/A')} |\\n"-- with open(filepath, "w") as f:- f.write(md)---# SCAFFOLD 9: MCP Integration and CLI--class ModelCheckerCLI:- """Command-line interface for model checker (Task 9.2)."""-- def __init__(self) -> None:- """Initialize CLI."""- self.results: dict[str, Any] = {}-- def run_checks(- self, project: str, checks: list[str] | None = None- ) -> dict[str, Any]:- """Run model checks from CLI.-- Args:- project: Project file path- checks: List of check types to run (None = all)-- Returns:- Dictionary of check results- """- self.results = {- "project": project,- "timestamp": datetime.now().isoformat(),- "checks_run": checks or ["all"],- "total_issues": 0,- "issues_by_category": {},- }-- return self.results-- def format_output(self, format: str = "text") -> str:- """Format results for display.-- Args:- format: Output format (text, json)-- Returns:- Formatted results string- """- if format == "json":- return json.dumps(self.results, indent=2)-- # Text format- output = f"Model Check Results for {self.results['project']}\\n"- output += f"Timestamp: {self.results['timestamp']}\\n"- output += f"Checks Run: {', '.join(self.results['checks_run'])}\\n"- output += f"Total Issues: {self.results['total_issues']}\\n"-- return output---class AutomatedCheckRunner:- """Automated check runner with scheduling (Task 9.3)."""-- def __init__(self) -> None:- """Initialize automated check runner."""- self.scheduled_checks: list[dict[str, Any]] = []- self.last_run: datetime | None = None-- def schedule_check(- self,- check_type: str,- interval_hours: float = 24.0,- on_events: list[str] | None = None,- ) -> None:- """Schedule a check to run automatically.-- Args:- check_type: Type of check to run- interval_hours: Run interval in hours- on_events: Events that trigger check (e.g., ["save", "sync"])- """- self.scheduled_checks.append(- {- "check_type": check_type,- "interval_hours": interval_hours,- "on_events": on_events or [],- "last_run": None,- }- )-- def should_run_check(self, check: dict[str, Any]) -> bool:- """Check if a scheduled check should run now."""- if check["last_run"] is None:- return True-- # Check time interval- from datetime import timedelta-- now = datetime.now()- elapsed = now - check["last_run"]- interval = timedelta(hours=check["interval_hours"])-- return elapsed >= interval-- def run_scheduled_checks(self) -> list[dict[str, Any]]:- """Run all scheduled checks that are due.-- Returns:- List of check results- """- results = []-- for check in self.scheduled_checks:- if self.should_run_check(check):- result = {"check_type": check["check_type"], "ran": True, "timestamp": datetime.now().isoformat()}- results.append(result)- check["last_run"] = datetime.now()-- self.last_run = datetime.now()- return results-- def trigger_check_on_event(self, event: str) -> list[dict[str, Any]]:- """Trigger checks configured for a specific event.-- Args:- event: Event name (e.g., "save", "sync")-- Returns:- List of triggered check results- """- results = []-- for check in self.scheduled_checks:- if event in check["on_events"]:- result = {- "check_type": check["check_type"],- "triggered_by": event,- "timestamp": datetime.now().isoformat(),- }- results.append(result)- check["last_run"] = datetime.now()-- return resultsdiff --git a/packages/model-checker/src/model_checker/rooms.py b/packages/model-checker/src/model_checker/rooms.pydeleted file mode 100644index 5e7400a..0000000--- a/packages/model-checker/src/model_checker/rooms.py+++ /dev/null@@ -1,279 +0,0 @@-"""Room and space validation (Scaffold 6) + Documentation validation (Scaffold 7)."""--from __future__ import annotations--from dataclasses import dataclass-from typing import Any---@dataclass-class RoomIssue:- """Room or documentation validation issue."""-- element_id: str | int- element_type: str- issue_type: str- description: str- location: dict[str, float] | None = None- severity: str = "medium"---# SCAFFOLD 6: Room and Space Validation--class RoomValidator:- """Validator for rooms and spaces."""-- def __init__(self) -> None:- """Initialize room validator."""- self.issues: list[RoomIssue] = []-- # Task 6.1: Room boundary checker- def validate_room_boundaries(self, rooms: list[dict[str, Any]]) -> list[RoomIssue]:- """Validate room boundaries."""- issues = []-- for room in rooms:- # Check if room is bound- if not room.get("is_bound", True):- issue = RoomIssue(- element_id=room["id"],- element_type="room",- issue_type="unbound",- description=f"Room '{room.get('name', room['id'])}' is not bound",- severity="high",- )- issues.append(issue)- self.issues.append(issue)-- # Check for overlapping rooms- # (simplified - would need actual boundary geometry)- if room.get("overlaps_with"):- issue = RoomIssue(- element_id=room["id"],- element_type="room",- issue_type="overlapping",- description=f"Room overlaps with {room['overlaps_with']}",- severity="critical",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- # Task 6.2: Area calculation validation- def validate_room_areas(- self,- rooms: list[dict[str, Any]],- min_area: float = 5.0, # m²- max_area: float = 500.0, # m²- ) -> list[RoomIssue]:- """Validate room areas."""- issues = []-- for room in rooms:- area = room.get("area", 0)- required_area = room.get("required_area")-- # Check minimum area- if area < min_area:- issue = RoomIssue(- element_id=room["id"],- element_type="room",- issue_type="area_too_small",- description=f"Room area {area:.1f}m² is below minimum {min_area}m²",- )- issues.append(issue)- self.issues.append(issue)-- # Check maximum area- if area > max_area:- issue = RoomIssue(- element_id=room["id"],- element_type="room",- issue_type="area_too_large",- description=f"Room area {area:.1f}m² exceeds maximum {max_area}m²",- )- issues.append(issue)- self.issues.append(issue)-- # Check against required area- if required_area and abs(area - required_area) / required_area > 0.1: # 10% tolerance- issue = RoomIssue(- element_id=room["id"],- element_type="room",- issue_type="area_mismatch",- description=f"Room area {area:.1f}m² differs from required {required_area:.1f}m²",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- # Task 6.3: Occupancy and egress validation- def validate_occupancy(- self, rooms: list[dict[str, Any]], max_occupant_load_factor: float = 10.0- ) -> list[RoomIssue]:- """Validate occupancy loads and egress."""- issues = []-- for room in rooms:- area = room.get("area", 0)- occupant_load = area / max_occupant_load_factor-- # Check exit access- has_exit = room.get("has_exit_access", False)- if not has_exit and occupant_load > 1:- issue = RoomIssue(- element_id=room["id"],- element_type="room",- issue_type="no_exit_access",- description=f"Room with {occupant_load:.0f} occupants has no exit access",- severity="critical",- )- issues.append(issue)- self.issues.append(issue)-- # Check exit width (750mm per 50 occupants)- required_exit_width = (occupant_load / 50) * 750- actual_exit_width = room.get("exit_width", 0)-- if actual_exit_width < required_exit_width:- issue = RoomIssue(- element_id=room["id"],- element_type="room",- issue_type="insufficient_exit_width",- description=f"Exit width {actual_exit_width}mm insufficient for {occupant_load:.0f} occupants (need {required_exit_width:.0f}mm)",- severity="high",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def get_issues(self) -> list[RoomIssue]:- """Get all room issues."""- return self.issues-- def clear_issues(self) -> None:- """Clear all issues."""- self.issues = []---# SCAFFOLD 7: Documentation Completeness--class DocumentationValidator:- """Validator for documentation completeness."""-- def __init__(self) -> None:- """Initialize documentation validator."""- self.issues: list[RoomIssue] = []-- # Task 7.1: View completeness checker- def validate_view_coverage(- self, elements: list[dict[str, Any]], views: list[dict[str, Any]]- ) -> list[RoomIssue]:- """Validate that all elements appear in required views."""- issues = []-- for element in elements:- element_views = element.get("visible_in_views", [])- required_view_types = element.get("required_view_types", ["floor_plan"])-- for view_type in required_view_types:- has_view_type = any(- view["id"] in element_views and view.get("type") == view_type- for view in views- )-- if not has_view_type:- issue = RoomIssue(- element_id=element["id"],- element_type=element.get("type", "element"),- issue_type="missing_from_view",- description=f"Element not shown in any {view_type} view",- severity="medium",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- # Task 7.2: Sheet validation- def validate_sheets(self, sheets: list[dict[str, Any]]) -> list[RoomIssue]:- """Validate sheets for completeness."""- issues = []-- for sheet in sheets:- # Check for titleblock- if not sheet.get("has_titleblock"):- issue = RoomIssue(- element_id=sheet["id"],- element_type="sheet",- issue_type="missing_titleblock",- description=f"Sheet {sheet.get('number', sheet['id'])} has no titleblock",- severity="high",- )- issues.append(issue)- self.issues.append(issue)-- # Check for placed views- viewports = sheet.get("viewports", [])- if len(viewports) == 0:- issue = RoomIssue(- element_id=sheet["id"],- element_type="sheet",- issue_type="no_views",- description=f"Sheet {sheet.get('number', sheet['id'])} has no views placed",- severity="high",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- # Task 7.3: Revision tracking validation- def validate_revisions(- self, sheets: list[dict[str, Any]], revisions: list[dict[str, Any]]- ) -> list[RoomIssue]:- """Validate revision tracking."""- issues = []-- revision_ids = {rev["id"] for rev in revisions}-- for sheet in sheets:- sheet_revisions = sheet.get("revisions", [])-- for rev_id in sheet_revisions:- if rev_id not in revision_ids:- issue = RoomIssue(- element_id=sheet["id"],- element_type="sheet",- issue_type="invalid_revision",- description=f"Sheet references invalid revision {rev_id}",- severity="medium",- )- issues.append(issue)- self.issues.append(issue)-- # Check for revision clouds- has_clouds = sheet.get("has_revision_clouds", False)- if sheet_revisions and not has_clouds:- issue = RoomIssue(- element_id=sheet["id"],- element_type="sheet",- issue_type="missing_revision_clouds",- description="Sheet has revisions but no revision clouds",- severity="low",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def get_issues(self) -> list[RoomIssue]:- """Get all documentation issues."""- return self.issues-- def clear_issues(self) -> None:- """Clear all issues."""- self.issues = []diff --git a/packages/model-checker/src/model_checker/rule_engine.py b/packages/model-checker/src/model_checker/rule_engine.pydeleted file mode 100644index 4bf9280..0000000--- a/packages/model-checker/src/model_checker/rule_engine.py+++ /dev/null@@ -1,125 +0,0 @@-"""Rule engine for model checking."""--from __future__ import annotations--from dataclasses import dataclass-from enum import Enum-from typing import Any, Callable---class RuleSeverity(Enum):- """Severity levels for validation issues."""-- CRITICAL = "critical"- HIGH = "high"- MEDIUM = "medium"- LOW = "low"- INFO = "info"---@dataclass-class Rule:- """A validation rule that can be executed against model elements."""-- id: str- name: str- description: str- category: str- severity: RuleSeverity- check_function: Callable[[Any], bool]-- def execute(self, element: Any) -> bool:- """Execute the rule's check function against an element.-- Args:- element: The element to check-- Returns:- True if the element passes the rule, False otherwise- """- return self.check_function(element)---class RuleEngine:- """Engine for registering and executing validation rules."""-- def __init__(self) -> None:- """Initialize the rule engine."""- self.rules: dict[str, Rule] = {}- self.rules_by_category: dict[str, list[Rule]] = {}-- def register_rule(self, rule: Rule) -> None:- """Register a new validation rule.-- Args:- rule: The rule to register- """- self.rules[rule.id] = rule-- if rule.category not in self.rules_by_category:- self.rules_by_category[rule.category] = []- self.rules_by_category[rule.category].append(rule)-- def get_rule(self, rule_id: str) -> Rule | None:- """Get a rule by its ID.-- Args:- rule_id: The ID of the rule to retrieve-- Returns:- The rule if found, None otherwise- """- return self.rules.get(rule_id)-- def get_rules_by_category(self, category: str) -> list[Rule]:- """Get all rules in a specific category.-- Args:- category: The category to filter by-- Returns:- List of rules in the category- """- return self.rules_by_category.get(category, [])-- def execute_rule(self, rule_id: str, element: Any) -> bool:- """Execute a specific rule against an element.-- Args:- rule_id: The ID of the rule to execute- element: The element to check-- Returns:- True if the element passes the rule, False otherwise-- Raises:- KeyError: If the rule_id is not found- """- rule = self.rules.get(rule_id)- if rule is None:- raise KeyError(f"Rule not found: {rule_id}")- return rule.execute(element)-- def execute_all_rules(self, element: Any) -> dict[str, bool]:- """Execute all registered rules against an element.-- Args:- element: The element to check-- Returns:- Dictionary mapping rule IDs to pass/fail results- """- return {rule_id: rule.execute(element) for rule_id, rule in self.rules.items()}-- def execute_category_rules(self, category: str, element: Any) -> dict[str, bool]:- """Execute all rules in a category against an element.-- Args:- category: The category of rules to execute- element: The element to check-- Returns:- Dictionary mapping rule IDs to pass/fail results- """- rules = self.get_rules_by_category(category)- return {rule.id: rule.execute(element) for rule in rules}diff --git a/packages/model-checker/src/model_checker/standards.py b/packages/model-checker/src/model_checker/standards.pydeleted file mode 100644index 773bf8b..0000000--- a/packages/model-checker/src/model_checker/standards.py+++ /dev/null@@ -1,581 +0,0 @@-"""Standards compliance checking for BIM models."""--from __future__ import annotations--import re-from dataclasses import dataclass-from typing import Any, Callable---@dataclass-class NamingRule:- """A naming convention rule."""-- id: str- name: str- category: str- pattern: str- description: str- compiled_pattern: re.Pattern | None = None-- def __post_init__(self) -> None:- """Compile the regex pattern after initialization."""- if self.compiled_pattern is None:- self.compiled_pattern = re.compile(self.pattern)-- def matches(self, name: str) -> bool:- """Check if a name matches this naming rule.-- Args:- name: The name to check-- Returns:- True if name matches the pattern, False otherwise- """- if self.compiled_pattern is None:- return False- return bool(self.compiled_pattern.match(name))---class NamingConventionValidator:- """Validator for checking naming conventions."""-- def __init__(self) -> None:- """Initialize the naming convention validator."""- self.rules: dict[str, NamingRule] = {}- self.violations: list[dict[str, Any]] = []-- def add_rule(self, rule: NamingRule) -> None:- """Add a naming rule.-- Args:- rule: The naming rule to add- """- self.rules[rule.id] = rule-- def add_view_naming_rules(self) -> None:- """Add standard view naming rules."""- # Floor plans: FP-L01, FP-L02, FP-ROOF- self.add_rule(- NamingRule(- id="view_floor_plan",- name="Floor Plan Naming",- category="views",- pattern=r"^FP-[A-Z0-9]+$",- description="Floor plans must be named FP-XXXX",- )- )-- # Sections: SEC-A, SEC-B, SEC-1- self.add_rule(- NamingRule(- id="view_section",- name="Section Naming",- category="views",- pattern=r"^SEC-[A-Z0-9]+$",- description="Sections must be named SEC-X",- )- )-- # 3D Views: 3D-ARCH, 3D-STRUCT, 3D-MEP- self.add_rule(- NamingRule(- id="view_3d",- name="3D View Naming",- category="views",- pattern=r"^3D-[A-Z]+$",- description="3D views must be named 3D-XXXX",- )- )-- def add_sheet_naming_rules(self) -> None:- """Add standard sheet naming rules."""- # Sheets: A-101, M-201, E-301- self.add_rule(- NamingRule(- id="sheet_number",- name="Sheet Number Format",- category="sheets",- pattern=r"^[A-Z]-\d{3}$",- description="Sheet numbers must be X-NNN format",- )- )-- def add_family_naming_rules(self) -> None:- """Add standard family naming rules."""- # Walls: W-EXT-200, W-INT-100- self.add_rule(- NamingRule(- id="family_wall",- name="Wall Family Naming",- category="families",- pattern=r"^W-[A-Z]+-\d+$",- description="Wall families must be named W-TYPE-WIDTH",- )- )-- # Doors: D-SINGLE-900, D-DOUBLE-1800- self.add_rule(- NamingRule(- id="family_door",- name="Door Family Naming",- category="families",- pattern=r"^D-[A-Z]+-\d+$",- description="Door families must be named D-TYPE-WIDTH",- )- )-- # Windows: W-FIXED-1200, W-CASEMENT-900- self.add_rule(- NamingRule(- id="family_window",- name="Window Family Naming",- category="families",- pattern=r"^WN-[A-Z]+-\d+$",- description="Window families must be named WN-TYPE-WIDTH",- )- )-- def validate_name(- self, name: str, element_type: str, rule_id: str | None = None- ) -> tuple[bool, str | None]:- """Validate a name against rules.-- Args:- name: The name to validate- element_type: Type of element (e.g., 'view', 'sheet', 'family')- rule_id: Specific rule ID to check (optional)-- Returns:- Tuple of (is_valid, error_message)- """- if rule_id:- rule = self.rules.get(rule_id)- if rule and rule.matches(name):- return True, None- if rule:- return False, rule.description- return False, f"Rule {rule_id} not found"-- # Check all rules for this element type- for rule in self.rules.values():- if element_type in rule.id and rule.matches(name):- return True, None-- # No matching rule found- return False, f"No naming rule matched for {element_type}"-- def validate_element(- self,- element_id: str | int,- element_name: str,- element_type: str,- rule_id: str | None = None,- ) -> bool:- """Validate an element's name and record violations.-- Args:- element_id: ID of the element- element_name: Name of the element- element_type: Type of element- rule_id: Specific rule to check (optional)-- Returns:- True if valid, False if violation found- """- is_valid, error_message = self.validate_name(element_name, element_type, rule_id)-- if not is_valid:- self.violations.append(- {- "element_id": element_id,- "element_name": element_name,- "element_type": element_type,- "rule_id": rule_id,- "error": error_message,- }- )-- return is_valid-- def get_violations(self) -> list[dict[str, Any]]:- """Get all naming convention violations.-- Returns:- List of violation dictionaries- """- return self.violations-- def get_violations_by_type(self, element_type: str) -> list[dict[str, Any]]:- """Get violations for a specific element type.-- Args:- element_type: Type of element to filter by-- Returns:- List of violations for that type- """- return [v for v in self.violations if v["element_type"] == element_type]-- def clear_violations(self) -> None:- """Clear all recorded violations."""- self.violations = []-- def get_violation_count(self) -> int:- """Get total number of violations.-- Returns:- Count of violations- """- return len(self.violations)---@dataclass-class ParameterRule:- """Rule for parameter validation."""-- id: str- name: str- parameter_name: str- required: bool = True- value_type: str | None = None- allowed_values: list[Any] | None = None- min_value: float | None = None- max_value: float | None = None- pattern: str | None = None- validator_function: Callable[[Any], bool] | None = None-- def validate_value(self, value: Any) -> tuple[bool, str | None]:- """Validate a parameter value.-- Args:- value: The value to validate-- Returns:- Tuple of (is_valid, error_message)- """- # Check if required and missing- if self.required and (value is None or value == ""):- return False, f"Required parameter '{self.parameter_name}' is missing"-- # If not required and missing, that's okay- if value is None or value == "":- return True, None-- # Type validation- if self.value_type:- expected_type = self._get_python_type(self.value_type)- if expected_type and not isinstance(value, expected_type):- return (- False,- f"Parameter '{self.parameter_name}' must be {self.value_type}",- )-- # Allowed values validation- if self.allowed_values and value not in self.allowed_values:- return (- False,- f"Parameter '{self.parameter_name}' must be one of {self.allowed_values}",- )-- # Numeric range validation- if self.min_value is not None and isinstance(value, (int, float)):- if value < self.min_value:- return (- False,- f"Parameter '{self.parameter_name}' must be >= {self.min_value}",- )-- if self.max_value is not None and isinstance(value, (int, float)):- if value > self.max_value:- return (- False,- f"Parameter '{self.parameter_name}' must be <= {self.max_value}",- )-- # Pattern validation for strings- if self.pattern and isinstance(value, str):- if not re.match(self.pattern, value):- return (- False,- f"Parameter '{self.parameter_name}' does not match pattern {self.pattern}",- )-- # Custom validator function- if self.validator_function:- if not self.validator_function(value):- return (- False,- f"Parameter '{self.parameter_name}' failed custom validation",- )-- return True, None-- def _get_python_type(self, type_name: str) -> type | None:- """Convert type name string to Python type.-- Args:- type_name: String name of type-- Returns:- Python type object or None- """- type_map = {- "string": str,- "int": int,- "float": float,- "bool": bool,- "number": (int, float),- }- return type_map.get(type_name.lower())---@dataclass-class LevelValidationIssue:- """Issue found during level validation."""-- level_id: str | int- level_name: str- issue_type: str- description: str- elevation: float | None = None---class LevelGridValidator:- """Validator for levels and grids."""-- def __init__(self) -> None:- """Initialize the level/grid validator."""- self.issues: list[LevelValidationIssue] = []-- def validate_level_naming(- self, levels: list[dict[str, Any]], pattern: str = r"^L\d{2}$"- ) -> list[LevelValidationIssue]:- """Validate level naming conventions.-- Args:- levels: List of level dictionaries with 'id', 'name', 'elevation'- pattern: Regex pattern for level names (default: L01, L02, etc.)-- Returns:- List of validation issues- """- issues = []- compiled_pattern = re.compile(pattern)-- for level in levels:- if not compiled_pattern.match(level["name"]):- issue = LevelValidationIssue(- level_id=level["id"],- level_name=level["name"],- issue_type="naming",- description=f"Level name '{level['name']}' does not match pattern {pattern}",- elevation=level.get("elevation"),- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def validate_level_spacing(- self,- levels: list[dict[str, Any]],- min_spacing: float = 3000.0,- max_spacing: float = 5000.0,- ) -> list[LevelValidationIssue]:- """Validate spacing between levels.-- Args:- levels: List of level dictionaries with 'id', 'name', 'elevation'- min_spacing: Minimum allowed spacing in mm- max_spacing: Maximum allowed spacing in mm-- Returns:- List of validation issues- """- issues = []-- # Sort levels by elevation- sorted_levels = sorted(levels, key=lambda x: x["elevation"])-- for i in range(len(sorted_levels) - 1):- level1 = sorted_levels[i]- level2 = sorted_levels[i + 1]-- spacing = level2["elevation"] - level1["elevation"]-- if spacing < min_spacing:- issue = LevelValidationIssue(- level_id=level2["id"],- level_name=level2["name"],- issue_type="spacing_too_small",- description=f"Level spacing {spacing:.0f}mm is below minimum {min_spacing:.0f}mm",- elevation=level2["elevation"],- )- issues.append(issue)- self.issues.append(issue)-- if spacing > max_spacing:- issue = LevelValidationIssue(- level_id=level2["id"],- level_name=level2["name"],- issue_type="spacing_too_large",- description=f"Level spacing {spacing:.0f}mm exceeds maximum {max_spacing:.0f}mm",- elevation=level2["elevation"],- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def validate_grid_naming(- self, grids: list[dict[str, Any]]- ) -> list[LevelValidationIssue]:- """Validate grid naming conventions.-- Grids should be named with letters (A, B, C) or numbers (1, 2, 3).-- Args:- grids: List of grid dictionaries with 'id', 'name'-- Returns:- List of validation issues- """- issues = []-- # Valid patterns: single letter A-Z or number 1-99- letter_pattern = re.compile(r"^[A-Z]$")- number_pattern = re.compile(r"^\d{1,2}$")-- for grid in grids:- name = grid["name"]- if not letter_pattern.match(name) and not number_pattern.match(name):- issue = LevelValidationIssue(- level_id=grid["id"],- level_name=name,- issue_type="grid_naming",- description=f"Grid name '{name}' should be single letter or 1-2 digit number",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def validate_grid_spacing(- self,- grids: list[dict[str, Any]],- min_spacing: float = 3000.0,- max_spacing: float = 12000.0,- ) -> list[LevelValidationIssue]:- """Validate spacing between parallel grids.-- Args:- grids: List of grid dictionaries with 'id', 'name', 'position'- min_spacing: Minimum allowed spacing in mm- max_spacing: Maximum allowed spacing in mm-- Returns:- List of validation issues- """- issues = []-- # Group grids by orientation (horizontal vs vertical)- horizontal = [g for g in grids if g.get("orientation") == "horizontal"]- vertical = [g for g in grids if g.get("orientation") == "vertical"]-- # Check horizontal grid spacing- issues.extend(- self._check_grid_group_spacing(horizontal, min_spacing, max_spacing, "horizontal")- )-- # Check vertical grid spacing- issues.extend(- self._check_grid_group_spacing(vertical, min_spacing, max_spacing, "vertical")- )-- return issues-- def _check_grid_group_spacing(- self,- grids: list[dict[str, Any]],- min_spacing: float,- max_spacing: float,- orientation: str,- ) -> list[LevelValidationIssue]:- """Check spacing for a group of parallel grids.-- Args:- grids: List of parallel grids- min_spacing: Minimum spacing- max_spacing: Maximum spacing- orientation: Grid orientation-- Returns:- List of issues- """- issues = []-- if len(grids) < 2:- return issues-- # Sort by position- sorted_grids = sorted(grids, key=lambda x: x["position"])-- for i in range(len(sorted_grids) - 1):- grid1 = sorted_grids[i]- grid2 = sorted_grids[i + 1]-- spacing = abs(grid2["position"] - grid1["position"])-- if spacing < min_spacing:- issue = LevelValidationIssue(- level_id=grid2["id"],- level_name=grid2["name"],- issue_type="grid_spacing_too_small",- description=f"{orientation.capitalize()} grid spacing {spacing:.0f}mm is below minimum {min_spacing:.0f}mm",- )- issues.append(issue)- self.issues.append(issue)-- if spacing > max_spacing:- issue = LevelValidationIssue(- level_id=grid2["id"],- level_name=grid2["name"],- issue_type="grid_spacing_too_large",- description=f"{orientation.capitalize()} grid spacing {spacing:.0f}mm exceeds maximum {max_spacing:.0f}mm",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def get_issues(self) -> list[LevelValidationIssue]:- """Get all validation issues.-- Returns:- List of all issues- """- return self.issues-- def get_issues_by_type(self, issue_type: str) -> list[LevelValidationIssue]:- """Get issues of a specific type.-- Args:- issue_type: Type of issue to filter by-- Returns:- List of issues of that type- """- return [issue for issue in self.issues if issue.issue_type == issue_type]-- def clear_issues(self) -> None:- """Clear all recorded issues."""- self.issues = []-- def get_issue_count(self) -> int:- """Get total number of issues.-- Returns:- Count of issues- """- return len(self.issues)diff --git a/packages/model-checker/src/model_checker/structural.py b/packages/model-checker/src/model_checker/structural.pydeleted file mode 100644index 5f7b3fe..0000000--- a/packages/model-checker/src/model_checker/structural.py+++ /dev/null@@ -1,242 +0,0 @@-"""Structural integrity validation."""--from __future__ import annotations--from dataclasses import dataclass-from typing import Any---@dataclass-class StructuralIssue:- """Structural validation issue."""-- element_id: str | int- element_type: str- issue_type: str- description: str- location: dict[str, float] | None = None- severity: str = "high"---class StructuralValidator:- """Validator for structural integrity."""-- def __init__(self) -> None:- """Initialize structural validator."""- self.issues: list[StructuralIssue] = []-- # Task 5.1: Column-beam connections- def validate_beam_connections(- self, beams: list[dict[str, Any]], columns: list[dict[str, Any]]- ) -> list[StructuralIssue]:- """Validate beam-column connections."""- issues = []-- for beam in beams:- start_connected = False- end_connected = False-- start_pt = beam.get("start_point")- end_pt = beam.get("end_point")-- if not start_pt or not end_pt:- continue-- # Check if beam ends connect to columns- for column in columns:- col_location = column.get("location")- if not col_location:- continue-- # Check start connection (ignore Z - beams connect horizontally)- if self._points_near_horizontal(start_pt, col_location, tolerance=100):- start_connected = True-- # Check end connection (ignore Z - beams connect horizontally)- if self._points_near_horizontal(end_pt, col_location, tolerance=100):- end_connected = True-- if not start_connected:- issue = StructuralIssue(- element_id=beam["id"],- element_type="beam",- issue_type="unconnected_start",- description="Beam start is not connected to a column",- location=start_pt,- severity="critical",- )- issues.append(issue)- self.issues.append(issue)-- if not end_connected:- issue = StructuralIssue(- element_id=beam["id"],- element_type="beam",- issue_type="unconnected_end",- description="Beam end is not connected to a column",- location=end_pt,- severity="critical",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- # Task 5.2: Foundation validation- def validate_foundations(- self, columns: list[dict[str, Any]], foundations: list[dict[str, Any]]- ) -> list[StructuralIssue]:- """Validate that all columns have foundations."""- issues = []-- for column in columns:- col_location = column.get("base_point")- if not col_location:- continue-- has_foundation = False-- for foundation in foundations:- found_location = foundation.get("location")- if not found_location:- continue-- if self._points_near_horizontal(col_location, found_location, tolerance=200):- has_foundation = True- break-- if not has_foundation:- issue = StructuralIssue(- element_id=column["id"],- element_type="column",- issue_type="missing_foundation",- description=f"Column {column.get('name', column['id'])} has no foundation",- location=col_location,- severity="critical",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- # Task 5.3: Load path validation- def validate_load_path(- self,- roof_elements: list[dict[str, Any]],- beams: list[dict[str, Any]],- columns: list[dict[str, Any]],- foundations: list[dict[str, Any]],- ) -> list[StructuralIssue]:- """Validate continuous load path from roof to foundation."""- issues = []-- # Check roof elements have supporting beams- for roof in roof_elements:- roof_location = roof.get("location")- if not roof_location:- continue-- has_support = any(- self._element_supports(beam, roof_location) for beam in beams- )-- if not has_support:- issue = StructuralIssue(- element_id=roof["id"],- element_type="roof",- issue_type="no_support",- description="Roof element has no supporting beam",- location=roof_location,- severity="critical",- )- issues.append(issue)- self.issues.append(issue)-- # Check beams have supporting columns (already done in validate_beam_connections)-- # Check columns have foundations (already done in validate_foundations)-- # Check for broken load path- unsupported_columns = []- for column in columns:- base = column.get("base_point")- if not base:- continue-- has_foundation = any(- self._points_near_horizontal(base, f.get("location", {}), tolerance=200)- for f in foundations- if f.get("location")- )-- if not has_foundation:- unsupported_columns.append(column["id"])-- if unsupported_columns:- issue = StructuralIssue(- element_id="system",- element_type="structural_system",- issue_type="broken_load_path",- description=f"Broken load path: {len(unsupported_columns)} columns without foundations",- severity="critical",- )- issues.append(issue)- self.issues.append(issue)-- return issues-- def _points_near(- self, point1: dict[str, float], point2: dict[str, float], tolerance: float = 100.0- ) -> bool:- """Check if two points are within tolerance (3D distance)."""- dx = point1.get("x", 0) - point2.get("x", 0)- dy = point1.get("y", 0) - point2.get("y", 0)- dz = point1.get("z", 0) - point2.get("z", 0)-- distance = (dx**2 + dy**2 + dz**2) ** 0.5- return distance <= tolerance-- def _points_near_horizontal(- self, point1: dict[str, float], point2: dict[str, float], tolerance: float = 100.0- ) -> bool:- """Check if two points are within tolerance (horizontal distance only, ignoring Z)."""- dx = point1.get("x", 0) - point2.get("x", 0)- dy = point1.get("y", 0) - point2.get("y", 0)-- distance = (dx**2 + dy**2) ** 0.5- return distance <= tolerance-- def _element_supports(- self, beam: dict[str, Any], point: dict[str, float], tolerance: float = 300.0- ) -> bool:- """Check if beam supports a point."""- start = beam.get("start_point")- end = beam.get("end_point")-- if not start or not end:- return False-- # Check if point is near the beam line (simplified)- return self._points_near(point, start, tolerance) or self._points_near(- point, end, tolerance- )-- def get_issues(self) -> list[StructuralIssue]:- """Get all structural issues."""- return self.issues-- def get_issues_by_severity(self, severity: str) -> list[StructuralIssue]:- """Get issues by severity."""- return [issue for issue in self.issues if issue.severity == severity]-- def get_critical_issues(self) -> list[StructuralIssue]:- """Get critical structural issues."""- return self.get_issues_by_severity("critical")-- def clear_issues(self) -> None:- """Clear all issues."""- self.issues = []-- def get_issue_count(self) -> int:- """Get total issue count."""- return len(self.issues)diff --git a/packages/model-checker/src/model_checker/validator.py b/packages/model-checker/src/model_checker/validator.pydeleted file mode 100644index c41c1e6..0000000--- a/packages/model-checker/src/model_checker/validator.py+++ /dev/null@@ -1,180 +0,0 @@-"""Validator for executing checks and generating reports."""--from __future__ import annotations--from dataclasses import dataclass, field-from datetime import datetime-from typing import Any--from .rule_engine import Rule, RuleSeverity---@dataclass-class ValidationIssue:- """A validation issue found during model checking."""-- rule_id: str- rule_name: str- severity: RuleSeverity- category: str- element_id: str | int | None- description: str- location: dict[str, Any] | None = None- timestamp: datetime = field(default_factory=datetime.now)-- def to_dict(self) -> dict[str, Any]:- """Convert the issue to a dictionary.-- Returns:- Dictionary representation of the issue- """- return {- "rule_id": self.rule_id,- "rule_name": self.rule_name,- "severity": self.severity.value,- "category": self.category,- "element_id": self.element_id,- "description": self.description,- "location": self.location,- "timestamp": self.timestamp.isoformat(),- }---@dataclass-class ValidationReport:- """Report containing all validation issues found."""-- project_name: str- timestamp: datetime = field(default_factory=datetime.now)- issues: list[ValidationIssue] = field(default_factory=list)- total_elements_checked: int = 0- rules_executed: int = 0-- def add_issue(self, issue: ValidationIssue) -> None:- """Add a validation issue to the report.-- Args:- issue: The issue to add- """- self.issues.append(issue)-- def get_issues_by_severity(self, severity: RuleSeverity) -> list[ValidationIssue]:- """Get all issues of a specific severity.-- Args:- severity: The severity level to filter by-- Returns:- List of issues with the specified severity- """- return [issue for issue in self.issues if issue.severity == severity]-- def get_issues_by_category(self, category: str) -> list[ValidationIssue]:- """Get all issues in a specific category.-- Args:- category: The category to filter by-- Returns:- List of issues in the specified category- """- return [issue for issue in self.issues if issue.category == category]-- def get_critical_count(self) -> int:- """Get the count of critical issues.-- Returns:- Number of critical issues- """- return len(self.get_issues_by_severity(RuleSeverity.CRITICAL))-- def get_high_count(self) -> int:- """Get the count of high severity issues.-- Returns:- Number of high severity issues- """- return len(self.get_issues_by_severity(RuleSeverity.HIGH))-- def get_total_issues(self) -> int:- """Get the total count of all issues.-- Returns:- Total number of issues- """- return len(self.issues)-- def to_dict(self) -> dict[str, Any]:- """Convert the report to a dictionary.-- Returns:- Dictionary representation of the report- """- return {- "project_name": self.project_name,- "timestamp": self.timestamp.isoformat(),- "total_elements_checked": self.total_elements_checked,- "rules_executed": self.rules_executed,- "total_issues": self.get_total_issues(),- "critical_issues": self.get_critical_count(),- "high_issues": self.get_high_count(),- "issues": [issue.to_dict() for issue in self.issues],- }---class Validator:- """Main validator class for executing checks and generating reports."""-- def __init__(self, rule_engine: Any) -> None:- """Initialize the validator with a rule engine.-- Args:- rule_engine: The rule engine to use for validation- """- self.rule_engine = rule_engine- self.current_report: ValidationReport | None = None-- def create_report(self, project_name: str) -> ValidationReport:- """Create a new validation report.-- Args:- project_name: The name of the project being validated-- Returns:- A new validation report- """- self.current_report = ValidationReport(project_name=project_name)- return self.current_report-- def validate_element(- self,- element: Any,- element_id: str | int,- rules: list[Rule],- ) -> list[ValidationIssue]:- """Validate an element against a list of rules.-- Args:- element: The element to validate- element_id: The ID of the element- rules: List of rules to execute-- Returns:- List of validation issues found- """- issues = []- for rule in rules:- passed = rule.execute(element)- if not passed:- issue = ValidationIssue(- rule_id=rule.id,- rule_name=rule.name,- severity=rule.severity,- category=rule.category,- element_id=element_id,- description=f"{rule.name}: {rule.description}",- )- issues.append(issue)- if self.current_report:- self.current_report.add_issue(issue)- return issuesdiff --git a/packages/model-checker/tests/test_clash_detection.py b/packages/model-checker/tests/test_clash_detection.pydeleted file mode 100644index 3fff4de..0000000--- a/packages/model-checker/tests/test_clash_detection.py+++ /dev/null@@ -1,335 +0,0 @@-"""Test clash detection functionality."""--import pytest--from model_checker.clash_detection import BoundingBox, ClashDetector, ClashResult---def test_create_bounding_box():- """Test creating a bounding box."""- bbox = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=3000.0- )-- assert bbox.min_x == 0.0- assert bbox.max_z == 3000.0---def test_bounding_box_from_dict():- """Test creating bounding box from dictionary."""- data = {- "min": {"x": 100.0, "y": 200.0, "z": 0.0},- "max": {"x": 500.0, "y": 600.0, "z": 3000.0},- }-- bbox = BoundingBox.from_dict(data)-- assert bbox.min_x == 100.0- assert bbox.min_y == 200.0- assert bbox.min_z == 0.0- assert bbox.max_x == 500.0- assert bbox.max_y == 600.0- assert bbox.max_z == 3000.0---def test_bounding_box_intersects():- """Test bounding box intersection detection."""- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=3000.0- )-- # Overlapping box- bbox2 = BoundingBox(- min_x=500.0, min_y=500.0, min_z=1000.0, max_x=1500.0, max_y=1500.0, max_z=4000.0- )-- assert bbox1.intersects(bbox2) is True- assert bbox2.intersects(bbox1) is True---def test_bounding_box_no_intersection():- """Test bounding boxes that don't intersect."""- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=3000.0- )-- # Separated box- bbox2 = BoundingBox(- min_x=2000.0, min_y=2000.0, min_z=0.0, max_x=3000.0, max_y=3000.0, max_z=3000.0- )-- assert bbox1.intersects(bbox2) is False- assert bbox2.intersects(bbox1) is False---def test_bounding_box_volume():- """Test bounding box volume calculation."""- bbox = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=2000.0, max_z=3000.0- )-- volume = bbox.get_volume()- assert volume == 1000.0 * 2000.0 * 3000.0---def test_intersection_volume():- """Test intersection volume calculation."""- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=1000.0- )-- bbox2 = BoundingBox(- min_x=500.0, min_y=500.0, min_z=500.0, max_x=1500.0, max_y=1500.0, max_z=1500.0- )-- # Overlap is 500x500x500- volume = bbox1.get_intersection_volume(bbox2)- assert volume == 500.0 * 500.0 * 500.0---def test_no_intersection_volume():- """Test intersection volume when boxes don't intersect."""- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=1000.0- )-- bbox2 = BoundingBox(- min_x=2000.0, min_y=2000.0, min_z=2000.0, max_x=3000.0, max_y=3000.0, max_z=3000.0- )-- volume = bbox1.get_intersection_volume(bbox2)- assert volume == 0.0---def test_bounding_box_center():- """Test getting center point of bounding box."""- bbox = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=2000.0, max_z=3000.0- )-- center = bbox.get_center()- assert center == (500.0, 1000.0, 1500.0)---def test_create_clash_result():- """Test creating a clash result."""- clash = ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="bounding_box",- intersection_volume=125000.0,- location={"x": 500.0, "y": 500.0, "z": 1500.0},- severity="high",- )-- assert clash.element_id_1 == "wall_1"- assert clash.element_id_2 == "beam_1"- assert clash.clash_type == "bounding_box"- assert clash.severity == "high"---def test_clash_result_to_dict():- """Test converting clash result to dictionary."""- clash = ClashResult(- element_id_1=123,- element_id_2=456,- clash_type="precise",- intersection_volume=50000.0,- location={"x": 100.0, "y": 200.0, "z": 300.0},- severity="medium",- )-- data = clash.to_dict()-- assert data["element_id_1"] == 123- assert data["element_id_2"] == 456- assert data["clash_type"] == "precise"- assert data["intersection_volume"] == 50000.0- assert data["location"] == {"x": 100.0, "y": 200.0, "z": 300.0}- assert data["severity"] == "medium"---def test_create_clash_detector():- """Test creating a clash detector."""- detector = ClashDetector()- assert detector.tolerance == 0.0- assert len(detector.clashes) == 0---def test_detect_clash():- """Test detecting a clash between two bounding boxes."""- detector = ClashDetector()-- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=3000.0- )-- bbox2 = BoundingBox(- min_x=500.0, min_y=500.0, min_z=1000.0, max_x=1500.0, max_y=1500.0, max_z=4000.0- )-- clash = detector.check_bounding_box_clash("elem_1", bbox1, "elem_2", bbox2)-- assert clash is not None- assert clash.element_id_1 == "elem_1"- assert clash.element_id_2 == "elem_2"- assert clash.clash_type == "bounding_box"- assert clash.intersection_volume > 0- assert clash.location is not None---def test_no_clash_detected():- """Test when no clash is detected."""- detector = ClashDetector()-- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=3000.0- )-- bbox2 = BoundingBox(- min_x=2000.0, min_y=2000.0, min_z=0.0, max_x=3000.0, max_y=3000.0, max_z=3000.0- )-- clash = detector.check_bounding_box_clash("elem_1", bbox1, "elem_2", bbox2)-- assert clash is None- assert len(detector.clashes) == 0---def test_check_multiple_elements():- """Test checking clashes between multiple elements."""- detector = ClashDetector()-- elements = [- {- "id": "wall_1",- "bounding_box": {- "min": {"x": 0.0, "y": 0.0, "z": 0.0},- "max": {"x": 1000.0, "y": 1000.0, "z": 3000.0},- },- },- {- "id": "beam_1",- "bounding_box": {- "min": {"x": 500.0, "y": 500.0, "z": 1000.0},- "max": {"x": 1500.0, "y": 1500.0, "z": 4000.0},- },- },- {- "id": "column_1",- "bounding_box": {- "min": {"x": 5000.0, "y": 5000.0, "z": 0.0},- "max": {"x": 5500.0, "y": 5500.0, "z": 3000.0},- },- },- ]-- clashes = detector.check_multiple_elements(elements)-- # Should find 1 clash (wall_1 and beam_1)- assert len(clashes) == 1- assert clashes[0].element_id_1 == "wall_1"- assert clashes[0].element_id_2 == "beam_1"---def test_severity_calculation():- """Test clash severity calculation."""- detector = ClashDetector()-- # Critical: > 1 m³ = 1,000,000,000 mm³- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=2000.0, max_y=2000.0, max_z=2000.0- )- bbox2 = BoundingBox(- min_x=1000.0, min_y=1000.0, min_z=1000.0, max_x=3000.0, max_y=3000.0, max_z=3000.0- )-- clash = detector.check_bounding_box_clash("e1", bbox1, "e2", bbox2)- assert clash.severity == "critical"---def test_get_clashes_by_severity():- """Test filtering clashes by severity."""- detector = ClashDetector()-- # Create clashes with different severities- bbox_critical_1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=2000.0, max_y=2000.0, max_z=2000.0- )- bbox_critical_2 = BoundingBox(- min_x=1000.0, min_y=1000.0, min_z=1000.0, max_x=3000.0, max_y=3000.0, max_z=3000.0- )-- bbox_low_1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=100.0, max_y=100.0, max_z=100.0- )- bbox_low_2 = BoundingBox(- min_x=50.0, min_y=50.0, min_z=50.0, max_x=150.0, max_y=150.0, max_z=150.0- )-- detector.check_bounding_box_clash("e1", bbox_critical_1, "e2", bbox_critical_2)- detector.check_bounding_box_clash("e3", bbox_low_1, "e4", bbox_low_2)-- critical = detector.get_clashes_by_severity("critical")- low = detector.get_clashes_by_severity("low")-- assert len(critical) == 1- assert len(low) == 1---def test_get_critical_clashes():- """Test getting only critical clashes."""- detector = ClashDetector()-- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=2000.0, max_y=2000.0, max_z=2000.0- )- bbox2 = BoundingBox(- min_x=1000.0, min_y=1000.0, min_z=1000.0, max_x=3000.0, max_y=3000.0, max_z=3000.0- )-- detector.check_bounding_box_clash("e1", bbox1, "e2", bbox2)-- critical = detector.get_critical_clashes()- assert len(critical) == 1- assert critical[0].severity == "critical"---def test_get_total_clashes():- """Test getting total clash count."""- detector = ClashDetector()-- elements = [- {- "id": f"elem_{i}",- "bounding_box": {- "min": {"x": float(i * 500), "y": 0.0, "z": 0.0},- "max": {"x": float(i * 500 + 1000), "y": 1000.0, "z": 3000.0},- },- }- for i in range(5)- ]-- detector.check_multiple_elements(elements)- total = detector.get_total_clashes()-- # Elements 0-1, 1-2, 2-3, 3-4 overlap (4 clashes)- assert total == 4---def test_clear_clashes():- """Test clearing stored clashes."""- detector = ClashDetector()-- bbox1 = BoundingBox(- min_x=0.0, min_y=0.0, min_z=0.0, max_x=1000.0, max_y=1000.0, max_z=3000.0- )- bbox2 = BoundingBox(- min_x=500.0, min_y=500.0, min_z=1000.0, max_x=1500.0, max_y=1500.0, max_z=4000.0- )-- detector.check_bounding_box_clash("e1", bbox1, "e2", bbox2)- assert len(detector.clashes) == 1-- detector.clear_clashes()- assert len(detector.clashes) == 0diff --git a/packages/model-checker/tests/test_clash_report.py b/packages/model-checker/tests/test_clash_report.pydeleted file mode 100644index 75fa273..0000000--- a/packages/model-checker/tests/test_clash_report.py+++ /dev/null@@ -1,472 +0,0 @@-"""Test clash visualization report generation."""--import json-import tempfile-from pathlib import Path--import pytest--from model_checker.clash_detection import ClashResult-from model_checker.clash_report import ClashReportBuilder, ClashVisualizationReport---def test_create_clash_report():- """Test creating a clash visualization report."""- report = ClashVisualizationReport(project_name="Test Project")-- assert report.project_name == "Test Project"- assert report.get_clash_count() == 0- assert len(report.clashes) == 0---def test_add_clash_to_report():- """Test adding a clash to the report."""- report = ClashVisualizationReport(project_name="Test")-- clash = ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="bounding_box",- intersection_volume=125000.0,- location={"x": 500.0, "y": 500.0, "z": 1500.0},- severity="high",- )-- report.add_clash(clash)-- assert report.get_clash_count() == 1- assert len(report.clashes) == 1---def test_clash_matrix():- """Test clash matrix generation."""- report = ClashVisualizationReport(project_name="Test")-- clash1 = ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="bounding_box",- severity="high",- )-- clash2 = ClashResult(- element_id_1="wall_1",- element_id_2="column_1",- clash_type="bounding_box",- severity="medium",- )-- report.add_clash(clash1)- report.add_clash(clash2)-- assert "wall_1" in report.clash_matrix- assert "beam_1" in report.clash_matrix- assert "column_1" in report.clash_matrix-- assert "beam_1" in report.clash_matrix["wall_1"]- assert "column_1" in report.clash_matrix["wall_1"]- assert "wall_1" in report.clash_matrix["beam_1"]---def test_get_clashes_by_severity():- """Test filtering clashes by severity."""- report = ClashVisualizationReport(project_name="Test")-- critical_clash = ClashResult(- element_id_1="e1",- element_id_2="e2",- clash_type="precise",- severity="critical",- )-- high_clash = ClashResult(- element_id_1="e3",- element_id_2="e4",- clash_type="precise",- severity="high",- )-- low_clash = ClashResult(- element_id_1="e5",- element_id_2="e6",- clash_type="bounding_box",- severity="low",- )-- report.add_clash(critical_clash)- report.add_clash(high_clash)- report.add_clash(low_clash)-- critical = report.get_clashes_by_severity("critical")- high = report.get_clashes_by_severity("high")- low = report.get_clashes_by_severity("low")-- assert len(critical) == 1- assert len(high) == 1- assert len(low) == 1---def test_get_clash_counts():- """Test getting clash counts by severity."""- report = ClashVisualizationReport(project_name="Test")-- for i in range(3):- report.add_clash(- ClashResult(- element_id_1=f"c{i}_1",- element_id_2=f"c{i}_2",- clash_type="precise",- severity="critical",- )- )-- for i in range(2):- report.add_clash(- ClashResult(- element_id_1=f"h{i}_1",- element_id_2=f"h{i}_2",- clash_type="bounding_box",- severity="high",- )- )-- assert report.get_clash_count() == 5- assert report.get_critical_count() == 3- assert report.get_high_count() == 2---def test_get_elements_with_clashes():- """Test getting list of elements involved in clashes."""- report = ClashVisualizationReport(project_name="Test")-- report.add_clash(- ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="precise",- severity="high",- )- )-- report.add_clash(- ClashResult(- element_id_1="wall_1",- element_id_2="column_1",- clash_type="precise",- severity="medium",- )- )-- elements = report.get_elements_with_clashes()-- assert len(elements) == 3- assert "wall_1" in elements- assert "beam_1" in elements- assert "column_1" in elements---def test_get_most_problematic_elements():- """Test getting elements with most clashes."""- report = ClashVisualizationReport(project_name="Test")-- # wall_1 clashes with 3 elements- for i in range(3):- report.add_clash(- ClashResult(- element_id_1="wall_1",- element_id_2=f"elem_{i}",- clash_type="precise",- severity="high",- )- )-- # beam_1 clashes with 1 element- report.add_clash(- ClashResult(- element_id_1="beam_1",- element_id_2="elem_5",- clash_type="bounding_box",- severity="low",- )- )-- problematic = report.get_most_problematic_elements(limit=3)-- assert len(problematic) <= 3- assert problematic[0][0] == "wall_1"- assert problematic[0][1] == 3---def test_report_to_dict():- """Test converting report to dictionary."""- report = ClashVisualizationReport(project_name="Sample Project")- report.total_elements_checked = 100-- clash = ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="bounding_box",- intersection_volume=50000.0,- location={"x": 100.0, "y": 200.0, "z": 300.0},- severity="medium",- )-- report.add_clash(clash)-- data = report.to_dict()-- assert data["project_name"] == "Sample Project"- assert data["summary"]["total_clashes"] == 1- assert data["summary"]["elements_checked"] == 100- assert len(data["clashes"]) == 1- assert data["clashes"][0]["element_id_1"] == "wall_1"- assert data["clashes"][0]["intersection_volume"] == 50000.0---def test_report_to_json():- """Test converting report to JSON string."""- report = ClashVisualizationReport(project_name="Test Project")-- clash = ClashResult(- element_id_1=123,- element_id_2=456,- clash_type="precise",- severity="high",- )-- report.add_clash(clash)-- json_str = report.to_json()-- # Verify it's valid JSON- data = json.loads(json_str)- assert data["project_name"] == "Test Project"- assert len(data["clashes"]) == 1---def test_save_to_file():- """Test saving report to JSON file."""- report = ClashVisualizationReport(project_name="Test Project")- report.total_elements_checked = 50-- clash = ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="bounding_box",- severity="critical",- )-- report.add_clash(clash)-- with tempfile.TemporaryDirectory() as tmpdir:- filepath = Path(tmpdir) / "clash_report.json"- report.save_to_file(str(filepath))-- assert filepath.exists()-- # Read and verify- with open(filepath) as f:- data = json.load(f)-- assert data["project_name"] == "Test Project"- assert data["summary"]["total_clashes"] == 1---def test_get_clash_pairs():- """Test getting clash pairs."""- report = ClashVisualizationReport(project_name="Test")-- report.add_clash(- ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="precise",- severity="high",- )- )-- report.add_clash(- ClashResult(- element_id_1="column_1",- element_id_2="slab_1",- clash_type="bounding_box",- severity="medium",- )- )-- pairs = report.get_clash_pairs()-- assert len(pairs) == 2- assert ("wall_1", "beam_1") in pairs- assert ("column_1", "slab_1") in pairs---def test_get_clash_locations():- """Test getting clash locations."""- report = ClashVisualizationReport(project_name="Test")-- report.add_clash(- ClashResult(- element_id_1="e1",- element_id_2="e2",- clash_type="precise",- severity="high",- location={"x": 100.0, "y": 200.0, "z": 300.0},- )- )-- report.add_clash(- ClashResult(- element_id_1="e3",- element_id_2="e4",- clash_type="bounding_box",- severity="medium",- location={"x": 500.0, "y": 600.0, "z": 700.0},- )- )-- locations = report.get_clash_locations()-- assert len(locations) == 2- assert {"x": 100.0, "y": 200.0, "z": 300.0} in locations- assert {"x": 500.0, "y": 600.0, "z": 700.0} in locations---def test_generate_visualization_data():- """Test generating visualization data."""- report = ClashVisualizationReport(project_name="Test")-- report.add_clash(- ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="precise",- severity="critical",- intersection_volume=1000000.0,- location={"x": 100.0, "y": 200.0, "z": 300.0},- )- )-- viz_data = report.generate_visualization_data()-- assert "nodes" in viz_data- assert "edges" in viz_data- assert len(viz_data["nodes"]) == 2- assert len(viz_data["edges"]) == 1-- # Check node structure- node_ids = [node["id"] for node in viz_data["nodes"]]- assert "wall_1" in node_ids- assert "beam_1" in node_ids-- # Check edge structure- edge = viz_data["edges"][0]- assert edge["source"] == "wall_1"- assert edge["target"] == "beam_1"- assert edge["severity"] == "critical"- assert edge["volume"] == 1000000.0---def test_clash_report_builder():- """Test using ClashReportBuilder."""- builder = ClashReportBuilder("Office Building")-- clashes = [- ClashResult(- element_id_1="wall_1",- element_id_2="beam_1",- clash_type="precise",- severity="high",- ),- ClashResult(- element_id_1="wall_2",- element_id_2="column_1",- clash_type="bounding_box",- severity="medium",- ),- ]-- report = builder.add_clashes(clashes).set_elements_checked(150).build()-- assert report.project_name == "Office Building"- assert report.get_clash_count() == 2- assert report.total_elements_checked == 150---def test_builder_method_chaining():- """Test builder method chaining."""- clashes = [- ClashResult(- element_id_1="e1",- element_id_2="e2",- clash_type="precise",- severity="critical",- )- ]-- report = (- ClashReportBuilder("Test")- .add_clashes(clashes)- .set_elements_checked(50)- .build()- )-- assert report.get_clash_count() == 1- assert report.total_elements_checked == 50---def test_complete_workflow():- """Test complete clash report workflow."""- # Create report- builder = ClashReportBuilder("Commercial Tower Project")-- # Add multiple clashes- clashes = [- ClashResult(- element_id_1="wall_ext_1",- element_id_2="beam_str_5",- clash_type="precise_geometry",- intersection_volume=500000000.0,- location={"x": 5000.0, "y": 3000.0, "z": 12000.0},- severity="critical",- ),- ClashResult(- element_id_1="wall_ext_1",- element_id_2="duct_mep_3",- clash_type="bounding_box",- intersection_volume=50000000.0,- location={"x": 5200.0, "y": 3100.0, "z": 11500.0},- severity="high",- ),- ClashResult(- element_id_1="column_str_2",- element_id_2="pipe_mep_7",- clash_type="precise_geometry",- intersection_volume=5000000.0,- location={"x": 2000.0, "y": 2000.0, "z": 8000.0},- severity="medium",- ),- ]-- report = builder.add_clashes(clashes).set_elements_checked(250).build()-- # Verify summary- assert report.get_clash_count() == 3- assert report.get_critical_count() == 1- assert report.get_high_count() == 1-- # Check most problematic element- problematic = report.get_most_problematic_elements(limit=1)- assert problematic[0][0] == "wall_ext_1" # Has 2 clashes- assert problematic[0][1] == 2-- # Generate and verify JSON- data = report.to_dict()- assert data["summary"]["total_clashes"] == 3- assert data["summary"]["critical_clashes"] == 1- assert len(data["most_problematic_elements"]) > 0-- # Generate visualization data- viz_data = report.generate_visualization_data()- assert len(viz_data["nodes"]) == 5 # 5 unique elements- assert len(viz_data["edges"]) == 3 # 3 clashesdiff --git a/packages/model-checker/tests/test_imports.py b/packages/model-checker/tests/test_imports.pydeleted file mode 100644index de214ab..0000000--- a/packages/model-checker/tests/test_imports.py+++ /dev/null@@ -1,36 +0,0 @@-"""Test that all model checker modules can be imported successfully."""---def test_import_rule_engine():- """Test importing rule_engine module."""- from model_checker import rule_engine- assert hasattr(rule_engine, 'RuleEngine')- assert hasattr(rule_engine, 'Rule')- assert hasattr(rule_engine, 'RuleSeverity')---def test_import_validator():- """Test importing validator module."""- from model_checker import validator- assert hasattr(validator, 'Validator')- assert hasattr(validator, 'ValidationReport')- assert hasattr(validator, 'ValidationIssue')---def test_import_from_package():- """Test importing from package root."""- from model_checker import (- Rule,- RuleEngine,- RuleSeverity,- ValidationIssue,- ValidationReport,- Validator,- )-- assert Rule is not None- assert RuleEngine is not None- assert RuleSeverity is not None- assert ValidationIssue is not None- assert ValidationReport is not None- assert Validator is not Nonediff --git a/packages/model-checker/tests/test_level_grid.py b/packages/model-checker/tests/test_level_grid.pydeleted file mode 100644index 0b7b17c..0000000--- a/packages/model-checker/tests/test_level_grid.py+++ /dev/null@@ -1,327 +0,0 @@-"""Test level and grid validation."""--import pytest--from model_checker.standards import LevelGridValidator, LevelValidationIssue---def test_create_level_grid_validator():- """Test creating level/grid validator."""- validator = LevelGridValidator()- assert len(validator.issues) == 0---def test_validate_level_naming_valid():- """Test validating correct level naming."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "L01", "elevation": 0.0},- {"id": "level_2", "name": "L02", "elevation": 3000.0},- {"id": "level_3", "name": "L03", "elevation": 6000.0},- ]-- issues = validator.validate_level_naming(levels)- assert len(issues) == 0---def test_validate_level_naming_invalid():- """Test detecting invalid level names."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "Level 01", "elevation": 0.0},- {"id": "level_2", "name": "Floor 2", "elevation": 3000.0},- {"id": "level_3", "name": "L03", "elevation": 6000.0}, # Valid- ]-- issues = validator.validate_level_naming(levels)- assert len(issues) == 2- assert issues[0].level_name == "Level 01"- assert issues[0].issue_type == "naming"---def test_validate_level_naming_custom_pattern():- """Test level naming with custom pattern."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "FL-01", "elevation": 0.0},- {"id": "level_2", "name": "FL-02", "elevation": 3000.0},- ]-- # Should fail default pattern- issues = validator.validate_level_naming(levels)- assert len(issues) == 2-- # Should pass custom pattern- validator.clear_issues()- issues = validator.validate_level_naming(levels, pattern=r"^FL-\d{2}$")- assert len(issues) == 0---def test_validate_level_spacing_valid():- """Test validating correct level spacing."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "L01", "elevation": 0.0},- {"id": "level_2", "name": "L02", "elevation": 3500.0},- {"id": "level_3", "name": "L03", "elevation": 7000.0},- ]-- # Default spacing 3000-5000mm- issues = validator.validate_level_spacing(levels)- assert len(issues) == 0---def test_validate_level_spacing_too_small():- """Test detecting levels that are too close together."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "L01", "elevation": 0.0},- {"id": "level_2", "name": "L02", "elevation": 2000.0}, # Only 2000mm spacing- ]-- issues = validator.validate_level_spacing(levels, min_spacing=3000.0)- assert len(issues) == 1- assert issues[0].issue_type == "spacing_too_small"- assert issues[0].level_name == "L02"---def test_validate_level_spacing_too_large():- """Test detecting levels that are too far apart."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "L01", "elevation": 0.0},- {"id": "level_2", "name": "L02", "elevation": 6000.0}, # 6000mm spacing- ]-- issues = validator.validate_level_spacing(levels, max_spacing=5000.0)- assert len(issues) == 1- assert issues[0].issue_type == "spacing_too_large"---def test_validate_level_spacing_multiple_levels():- """Test spacing validation with multiple levels."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "L01", "elevation": 0.0},- {"id": "level_2", "name": "L02", "elevation": 2500.0}, # Too small- {"id": "level_3", "name": "L03", "elevation": 6000.0}, # OK- {"id": "level_4", "name": "L04", "elevation": 12000.0}, # Too large- ]-- issues = validator.validate_level_spacing(levels, min_spacing=3000.0, max_spacing=5000.0)- assert len(issues) == 2---def test_validate_grid_naming_valid():- """Test validating correct grid names."""- validator = LevelGridValidator()-- grids = [- {"id": "grid_1", "name": "A"},- {"id": "grid_2", "name": "B"},- {"id": "grid_3", "name": "1"},- {"id": "grid_4", "name": "2"},- ]-- issues = validator.validate_grid_naming(grids)- assert len(issues) == 0---def test_validate_grid_naming_invalid():- """Test detecting invalid grid names."""- validator = LevelGridValidator()-- grids = [- {"id": "grid_1", "name": "A"}, # Valid- {"id": "grid_2", "name": "Grid-B"}, # Invalid- {"id": "grid_3", "name": "1"}, # Valid- {"id": "grid_4", "name": "100"}, # Invalid (3 digits)- ]-- issues = validator.validate_grid_naming(grids)- assert len(issues) == 2- assert issues[0].level_name == "Grid-B"- assert issues[1].level_name == "100"---def test_validate_grid_spacing_horizontal():- """Test horizontal grid spacing validation."""- validator = LevelGridValidator()-- grids = [- {"id": "grid_1", "name": "1", "orientation": "horizontal", "position": 0.0},- {"id": "grid_2", "name": "2", "orientation": "horizontal", "position": 6000.0},- {"id": "grid_3", "name": "3", "orientation": "horizontal", "position": 12000.0},- ]-- issues = validator.validate_grid_spacing(grids, min_spacing=3000.0, max_spacing=12000.0)- assert len(issues) == 0---def test_validate_grid_spacing_vertical():- """Test vertical grid spacing validation."""- validator = LevelGridValidator()-- grids = [- {"id": "grid_a", "name": "A", "orientation": "vertical", "position": 0.0},- {"id": "grid_b", "name": "B", "orientation": "vertical", "position": 8000.0},- ]-- issues = validator.validate_grid_spacing(grids, min_spacing=3000.0, max_spacing=12000.0)- assert len(issues) == 0---def test_validate_grid_spacing_too_small():- """Test detecting grids that are too close."""- validator = LevelGridValidator()-- grids = [- {"id": "grid_1", "name": "1", "orientation": "horizontal", "position": 0.0},- {"id": "grid_2", "name": "2", "orientation": "horizontal", "position": 2000.0},- ]-- issues = validator.validate_grid_spacing(grids, min_spacing=3000.0)- assert len(issues) == 1- assert issues[0].issue_type == "grid_spacing_too_small"---def test_validate_grid_spacing_too_large():- """Test detecting grids that are too far apart."""- validator = LevelGridValidator()-- grids = [- {"id": "grid_1", "name": "1", "orientation": "horizontal", "position": 0.0},- {"id": "grid_2", "name": "2", "orientation": "horizontal", "position": 15000.0},- ]-- issues = validator.validate_grid_spacing(grids, max_spacing=12000.0)- assert len(issues) == 1- assert issues[0].issue_type == "grid_spacing_too_large"---def test_validate_mixed_grid_orientations():- """Test validating grids with mixed orientations."""- validator = LevelGridValidator()-- grids = [- # Horizontal grids- {"id": "grid_1", "name": "1", "orientation": "horizontal", "position": 0.0},- {"id": "grid_2", "name": "2", "orientation": "horizontal", "position": 6000.0},- # Vertical grids- {"id": "grid_a", "name": "A", "orientation": "vertical", "position": 0.0},- {"id": "grid_b", "name": "B", "orientation": "vertical", "position": 8000.0},- ]-- issues = validator.validate_grid_spacing(grids, min_spacing=3000.0, max_spacing=12000.0)- assert len(issues) == 0---def test_get_issues():- """Test getting all issues."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "Bad Name", "elevation": 0.0},- {"id": "level_2", "name": "L02", "elevation": 2000.0},- ]-- validator.validate_level_naming(levels)- validator.validate_level_spacing(levels, min_spacing=3000.0)-- issues = validator.get_issues()- assert len(issues) == 2 # 1 naming + 1 spacing---def test_get_issues_by_type():- """Test filtering issues by type."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "Bad Name", "elevation": 0.0},- {"id": "level_2", "name": "L02", "elevation": 2000.0},- ]-- validator.validate_level_naming(levels)- validator.validate_level_spacing(levels, min_spacing=3000.0)-- naming_issues = validator.get_issues_by_type("naming")- spacing_issues = validator.get_issues_by_type("spacing_too_small")-- assert len(naming_issues) == 1- assert len(spacing_issues) == 1---def test_clear_issues():- """Test clearing issues."""- validator = LevelGridValidator()-- levels = [{"id": "level_1", "name": "Bad Name", "elevation": 0.0}]-- validator.validate_level_naming(levels)- assert len(validator.issues) > 0-- validator.clear_issues()- assert len(validator.issues) == 0---def test_get_issue_count():- """Test getting issue count."""- validator = LevelGridValidator()-- levels = [- {"id": "level_1", "name": "Bad Name 1", "elevation": 0.0},- {"id": "level_2", "name": "Bad Name 2", "elevation": 3000.0},- {"id": "level_3", "name": "Bad Name 3", "elevation": 6000.0},- ]-- validator.validate_level_naming(levels)- assert validator.get_issue_count() == 3---def test_complete_validation_workflow():- """Test complete level and grid validation workflow."""- validator = LevelGridValidator()-- # Define building levels- levels = [- {"id": "level_b1", "name": "L-B1", "elevation": -3000.0}, # Bad name- {"id": "level_g", "name": "L00", "elevation": 0.0}, # OK- {"id": "level_1", "name": "L01", "elevation": 4000.0}, # OK- {"id": "level_2", "name": "L02", "elevation": 8000.0}, # OK- {"id": "level_roof", "name": "Roof", "elevation": 12000.0}, # Bad name- ]-- # Define grids- grids = [- {"id": "grid_1", "name": "1", "orientation": "horizontal", "position": 0.0},- {"id": "grid_2", "name": "2", "orientation": "horizontal", "position": 2000.0}, # Too close- {"id": "grid_3", "name": "3", "orientation": "horizontal", "position": 8000.0},- {"id": "grid_a", "name": "A", "orientation": "vertical", "position": 0.0},- {"id": "grid_b", "name": "B-North", "orientation": "vertical", "position": 10000.0}, # Bad name- ]-- # Run validations- validator.validate_level_naming(levels)- validator.validate_level_spacing(levels, min_spacing=3000.0, max_spacing=5000.0)- validator.validate_grid_naming(grids)- validator.validate_grid_spacing(grids, min_spacing=3000.0, max_spacing=12000.0)-- # Check results- total_issues = validator.get_issue_count()- assert total_issues > 0-- naming_issues = validator.get_issues_by_type("naming")- assert len(naming_issues) == 2 # L-B1 and Roof-- grid_naming_issues = validator.get_issues_by_type("grid_naming")- assert len(grid_naming_issues) == 1 # B-North-- spacing_issues = validator.get_issues_by_type("grid_spacing_too_small")- assert len(spacing_issues) == 1 # Grid 2diff --git a/packages/model-checker/tests/test_mep.py b/packages/model-checker/tests/test_mep.pydeleted file mode 100644index fdadd24..0000000--- a/packages/model-checker/tests/test_mep.py+++ /dev/null@@ -1,426 +0,0 @@-"""Test MEP connectivity validation."""--import pytest--from model_checker.mep import MEPConnectivityIssue, MEPConnectivityValidator---def test_create_mep_validator():- """Test creating MEP connectivity validator."""- validator = MEPConnectivityValidator()- assert len(validator.issues) == 0---def test_validate_duct_connections_valid():- """Test validating properly connected ducts."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply Air", "type": "duct"}]-- ducts = [- {- "id": "duct_1",- "system_id": "sys_1",- "start_connector": {"connected": True},- "end_connector": {"connected": True},- },- {- "id": "duct_2",- "system_id": "sys_1",- "start_connector": {"connected": True},- "end_connector": {"connected": True},- },- ]-- issues = validator.validate_duct_connections(ducts, systems)- assert len(issues) == 0---def test_validate_duct_no_system():- """Test detecting ducts not in any system."""- validator = MEPConnectivityValidator()-- systems = []- ducts = [- {- "id": "duct_1",- "start_connector": {"connected": True},- "end_connector": {"connected": True},- }- ]-- issues = validator.validate_duct_connections(ducts, systems)- assert len(issues) == 1- assert issues[0].issue_type == "no_system"---def test_validate_duct_invalid_system():- """Test detecting ducts with invalid system references."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply Air", "type": "duct"}]-- ducts = [- {- "id": "duct_1",- "system_id": "sys_999", # Invalid system ID- "start_connector": {"connected": True},- "end_connector": {"connected": True},- }- ]-- issues = validator.validate_duct_connections(ducts, systems)- assert len(issues) == 1- assert issues[0].issue_type == "invalid_system"---def test_validate_duct_disconnected_start():- """Test detecting ducts with disconnected start connector."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply Air", "type": "duct"}]-- ducts = [- {- "id": "duct_1",- "system_id": "sys_1",- "start_connector": {"connected": False},- "end_connector": {"connected": True},- }- ]-- issues = validator.validate_duct_connections(ducts, systems)- assert len(issues) == 1- assert issues[0].issue_type == "disconnected_start"- assert issues[0].system_name == "Supply Air"---def test_validate_duct_disconnected_end():- """Test detecting ducts with disconnected end connector."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Return Air", "type": "duct"}]-- ducts = [- {- "id": "duct_1",- "system_id": "sys_1",- "start_connector": {"connected": True},- "end_connector": {"connected": False},- }- ]-- issues = validator.validate_duct_connections(ducts, systems)- assert len(issues) == 1- assert issues[0].issue_type == "disconnected_end"---def test_validate_duct_both_disconnected():- """Test detecting ducts with both connectors disconnected."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply Air", "type": "duct"}]-- ducts = [- {- "id": "duct_1",- "system_id": "sys_1",- "start_connector": {"connected": False},- "end_connector": {"connected": False},- }- ]-- issues = validator.validate_duct_connections(ducts, systems)- assert len(issues) == 2 # Both start and end issues---def test_validate_pipe_connections_valid():- """Test validating properly connected pipes."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Domestic Cold Water", "type": "pipe"}]-- pipes = [- {- "id": "pipe_1",- "system_id": "sys_1",- "connectors": [{"connected": True}, {"connected": True}],- }- ]-- issues = validator.validate_pipe_connections(pipes, systems)- assert len(issues) == 0---def test_validate_pipe_no_system():- """Test detecting pipes not in any system."""- validator = MEPConnectivityValidator()-- systems = []- pipes = [{"id": "pipe_1", "connectors": [{"connected": True}, {"connected": True}]}]-- issues = validator.validate_pipe_connections(pipes, systems)- assert len(issues) == 1- assert issues[0].issue_type == "no_system"---def test_validate_pipe_multiple_disconnected():- """Test detecting pipes with multiple disconnected connectors."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Hot Water", "type": "pipe"}]-- pipes = [- {- "id": "pipe_1",- "system_id": "sys_1",- "connectors": [{"connected": False}, {"connected": False}],- }- ]-- issues = validator.validate_pipe_connections(pipes, systems)- assert len(issues) == 1- assert issues[0].issue_type == "multiple_disconnected"---def test_validate_system_equipment_valid():- """Test validating properly connected equipment."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply Air", "type": "duct"}]-- equipment = [- {"id": "at_1", "type": "air_terminal", "system_id": "sys_1"},- {"id": "at_2", "type": "air_terminal", "system_id": "sys_1"},- ]-- issues = validator.validate_system_equipment(equipment, systems)- assert len(issues) == 0---def test_validate_equipment_no_system():- """Test detecting equipment not connected to any system."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply Air", "type": "duct"}]-- equipment = [{"id": "at_1", "type": "air_terminal"}] # No system_id-- issues = validator.validate_system_equipment(equipment, systems)- assert len(issues) == 1- assert issues[0].issue_type == "no_system"---def test_validate_equipment_invalid_system():- """Test detecting equipment with invalid system reference."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply Air", "type": "duct"}]-- equipment = [{"id": "at_1", "type": "air_terminal", "system_id": "sys_999"}]-- issues = validator.validate_system_equipment(equipment, systems)- assert len(issues) == 1- assert issues[0].issue_type == "invalid_system"---def test_find_isolated_elements():- """Test finding isolated MEP elements."""- validator = MEPConnectivityValidator()-- elements = [- {- "id": "elem_1",- "type": "duct",- "connectors": [{"connected": False}, {"connected": False}],- },- {- "id": "elem_2",- "type": "pipe",- "connectors": [{"connected": True}, {"connected": True}],- },- ]-- issues = validator.find_isolated_elements(elements)- assert len(issues) == 1- assert issues[0].element_id == "elem_1"- assert issues[0].issue_type == "isolated"---def test_find_elements_no_connectors():- """Test finding elements with no connectors."""- validator = MEPConnectivityValidator()-- elements = [- {"id": "elem_1", "type": "duct", "connectors": []},- {"id": "elem_2", "type": "pipe"}, # No connectors field- ]-- issues = validator.find_isolated_elements(elements)- assert len(issues) == 2- assert all(issue.issue_type == "no_connectors" for issue in issues)---def test_get_issues():- """Test getting all issues."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply", "type": "duct"}]- ducts = [{"id": "duct_1"}] # No system_id-- validator.validate_duct_connections(ducts, systems)- issues = validator.get_issues()-- assert len(issues) == 1---def test_get_issues_by_type():- """Test filtering issues by type."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply", "type": "duct"}]-- ducts = [- {"id": "duct_1"}, # No system- {- "id": "duct_2",- "system_id": "sys_1",- "start_connector": {"connected": False},- "end_connector": {"connected": True},- }, # Disconnected start- ]-- validator.validate_duct_connections(ducts, systems)-- no_system_issues = validator.get_issues_by_type("no_system")- disconnected_issues = validator.get_issues_by_type("disconnected_start")-- assert len(no_system_issues) == 1- assert len(disconnected_issues) == 1---def test_get_issues_by_system():- """Test filtering issues by system name."""- validator = MEPConnectivityValidator()-- systems = [- {"id": "sys_1", "name": "Supply Air", "type": "duct"},- {"id": "sys_2", "name": "Return Air", "type": "duct"},- ]-- ducts = [- {- "id": "duct_1",- "system_id": "sys_1",- "start_connector": {"connected": False},- "end_connector": {"connected": True},- },- {- "id": "duct_2",- "system_id": "sys_2",- "start_connector": {"connected": False},- "end_connector": {"connected": True},- },- ]-- validator.validate_duct_connections(ducts, systems)-- supply_issues = validator.get_issues_by_system("Supply Air")- return_issues = validator.get_issues_by_system("Return Air")-- assert len(supply_issues) == 1- assert len(return_issues) == 1---def test_clear_issues():- """Test clearing issues."""- validator = MEPConnectivityValidator()-- systems = []- ducts = [{"id": "duct_1"}]-- validator.validate_duct_connections(ducts, systems)- assert len(validator.issues) > 0-- validator.clear_issues()- assert len(validator.issues) == 0---def test_get_issue_count():- """Test getting issue count."""- validator = MEPConnectivityValidator()-- systems = [{"id": "sys_1", "name": "Supply", "type": "duct"}]- ducts = [- {"id": "duct_1"},- {"id": "duct_2"},- {"id": "duct_3"},- ]-- validator.validate_duct_connections(ducts, systems)- assert validator.get_issue_count() == 3---def test_complete_mep_workflow():- """Test complete MEP connectivity validation workflow."""- validator = MEPConnectivityValidator()-- # Define MEP systems- systems = [- {"id": "hvac_supply", "name": "Supply Air System", "type": "duct"},- {"id": "hvac_return", "name": "Return Air System", "type": "duct"},- {"id": "dhw", "name": "Domestic Hot Water", "type": "pipe"},- ]-- # Define ducts- ducts = [- {- "id": "duct_1",- "system_id": "hvac_supply",- "start_connector": {"connected": True},- "end_connector": {"connected": True},- },- {- "id": "duct_2",- "system_id": "hvac_supply",- "start_connector": {"connected": False}, # Issue- "end_connector": {"connected": True},- },- {"id": "duct_3"}, # No system - Issue- ]-- # Define pipes- pipes = [- {- "id": "pipe_1",- "system_id": "dhw",- "connectors": [{"connected": True}, {"connected": True}],- },- {- "id": "pipe_2",- "system_id": "dhw",- "connectors": [{"connected": False}, {"connected": False}], # Issue- },- ]-- # Define equipment- equipment = [- {"id": "at_1", "type": "air_terminal", "system_id": "hvac_supply"},- {"id": "at_2", "type": "air_terminal"}, # No system - Issue- {"id": "fix_1", "type": "fixture", "system_id": "dhw"},- ]-- # Run validations- validator.validate_duct_connections(ducts, systems)- validator.validate_pipe_connections(pipes, systems)- validator.validate_system_equipment(equipment, systems)-- # Check results- total_issues = validator.get_issue_count()- assert total_issues == 4 # 2 duct + 1 pipe + 1 equipment-- supply_issues = validator.get_issues_by_system("Supply Air System")- assert len(supply_issues) == 1 # duct_2 disconnected start-- no_system_issues = validator.get_issues_by_type("no_system")- assert len(no_system_issues) == 2 # duct_3 and at_2diff --git a/packages/model-checker/tests/test_mep_sizing.py b/packages/model-checker/tests/test_mep_sizing.pydeleted file mode 100644index 7ae3699..0000000--- a/packages/model-checker/tests/test_mep_sizing.py+++ /dev/null@@ -1,186 +0,0 @@-"""Test MEP sizing and clearance validation."""--import pytest--from model_checker.mep import MEPClearanceValidator, MEPSizingValidator---# Sizing Tests-def test_validate_duct_sizing_valid():- """Test validating properly sized ducts."""- validator = MEPSizingValidator()-- ducts = [- {"id": "duct_1", "width": 500, "height": 300, "velocity": 8.0},- {"id": "duct_2", "width": 400, "height": 400, "velocity": 9.5},- ]-- issues = validator.validate_duct_sizing(ducts, max_velocity=10.0)- assert len(issues) == 0---def test_validate_duct_undersized():- """Test detecting undersized ducts."""- validator = MEPSizingValidator()-- ducts = [{"id": "duct_1", "width": 50, "height": 50, "velocity": 5.0}]-- issues = validator.validate_duct_sizing(ducts, min_size=100.0)- assert len(issues) == 1- assert issues[0].issue_type == "undersized"---def test_validate_duct_oversized():- """Test detecting oversized ducts."""- validator = MEPSizingValidator()-- ducts = [{"id": "duct_1", "width": 2500, "height": 1500, "velocity": 5.0}]-- issues = validator.validate_duct_sizing(ducts, max_size=2000.0)- assert len(issues) == 1- assert issues[0].issue_type == "oversized"---def test_validate_duct_excessive_velocity():- """Test detecting excessive duct velocity."""- validator = MEPSizingValidator()-- ducts = [{"id": "duct_1", "width": 300, "height": 300, "velocity": 15.0}]-- issues = validator.validate_duct_sizing(ducts, max_velocity=10.0)- assert len(issues) == 1- assert issues[0].issue_type == "excessive_velocity"---def test_validate_pipe_sizing_valid():- """Test validating properly sized pipes."""- validator = MEPSizingValidator()-- pipes = [- {"id": "pipe_1", "diameter": 50, "velocity": 2.0},- {"id": "pipe_2", "diameter": 100, "velocity": 2.5},- ]-- issues = validator.validate_pipe_sizing(pipes, max_velocity=3.0)- assert len(issues) == 0---def test_validate_pipe_undersized():- """Test detecting undersized pipes."""- validator = MEPSizingValidator()-- pipes = [{"id": "pipe_1", "diameter": 10, "velocity": 2.0}]-- issues = validator.validate_pipe_sizing(pipes, min_diameter=15.0)- assert len(issues) == 1- assert issues[0].issue_type == "undersized"---def test_validate_pipe_oversized():- """Test detecting oversized pipes."""- validator = MEPSizingValidator()-- pipes = [{"id": "pipe_1", "diameter": 800, "velocity": 1.0}]-- issues = validator.validate_pipe_sizing(pipes, max_diameter=600.0)- assert len(issues) == 1- assert issues[0].issue_type == "oversized"---def test_validate_pipe_excessive_velocity():- """Test detecting excessive pipe velocity."""- validator = MEPSizingValidator()-- pipes = [{"id": "pipe_1", "diameter": 25, "velocity": 5.0}]-- issues = validator.validate_pipe_sizing(pipes, max_velocity=3.0)- assert len(issues) == 1- assert issues[0].issue_type == "excessive_velocity"---# Clearance Tests-def test_validate_headroom_clearance_valid():- """Test validating proper headroom clearance."""- validator = MEPClearanceValidator()-- elements = [- {"id": "duct_1", "type": "duct", "elevation": 2500, "height": 300},- {"id": "pipe_1", "type": "pipe", "elevation": 2400, "height": 100},- ]-- issues = validator.validate_headroom_clearance(elements, min_clearance=2100.0)- assert len(issues) == 0---def test_validate_headroom_insufficient():- """Test detecting insufficient headroom."""- validator = MEPClearanceValidator()-- elements = [- {"id": "duct_1", "type": "duct", "elevation": 2200, "height": 400}- ] # Bottom at 2000mm-- issues = validator.validate_headroom_clearance(elements, min_clearance=2100.0)- assert len(issues) == 1- assert issues[0].issue_type == "insufficient_headroom"---def test_validate_access_clearance_valid():- """Test validating proper access clearance."""- validator = MEPClearanceValidator()-- equipment = [- {"id": "ahu_1", "type": "air_handler", "access_clearance": 800},- {"id": "pump_1", "type": "pump", "access_clearance": 1000},- ]-- issues = validator.validate_access_clearance(equipment, min_access_clearance=600.0)- assert len(issues) == 0---def test_validate_access_insufficient():- """Test detecting insufficient access clearance."""- validator = MEPClearanceValidator()-- equipment = [{"id": "ahu_1", "type": "air_handler", "access_clearance": 400}]-- issues = validator.validate_access_clearance(equipment, min_access_clearance=600.0)- assert len(issues) == 1- assert issues[0].issue_type == "insufficient_access"---def test_complete_mep_sizing_workflow():- """Test complete MEP sizing and clearance validation."""- sizing_validator = MEPSizingValidator()- clearance_validator = MEPClearanceValidator()-- # Validate duct sizing- ducts = [- {"id": "duct_1", "width": 500, "height": 300, "velocity": 8.0}, # OK- {"id": "duct_2", "width": 50, "height": 50, "velocity": 5.0}, # Undersized- {"id": "duct_3", "width": 600, "height": 400, "velocity": 12.0}, # Excessive velocity- ]-- # Validate pipe sizing- pipes = [- {"id": "pipe_1", "diameter": 50, "velocity": 2.0}, # OK- {"id": "pipe_2", "diameter": 10, "velocity": 1.5}, # Undersized- {"id": "pipe_3", "diameter": 100, "velocity": 4.0}, # Excessive velocity- ]-- # Validate clearances- elements = [- {"id": "duct_4", "type": "duct", "elevation": 2200, "height": 400}, # Insufficient headroom- ]-- equipment = [- {"id": "ahu_1", "type": "air_handler", "access_clearance": 400} # Insufficient access- ]-- sizing_validator.validate_duct_sizing(ducts)- sizing_validator.validate_pipe_sizing(pipes)- clearance_validator.validate_headroom_clearance(elements)- clearance_validator.validate_access_clearance(equipment)-- assert len(sizing_validator.get_issues()) == 4 # 2 ducts + 2 pipes- assert len(clearance_validator.get_issues()) == 2 # 1 headroom + 1 accessdiff --git a/packages/model-checker/tests/test_precise_clash.py b/packages/model-checker/tests/test_precise_clash.pydeleted file mode 100644index 84595e5..0000000--- a/packages/model-checker/tests/test_precise_clash.py+++ /dev/null@@ -1,332 +0,0 @@-"""Test precise geometry clash detection."""--import pytest--from model_checker.clash_detection import ClashDetector, PreciseGeometry---def test_create_precise_geometry():- """Test creating precise geometry from data."""- geometry_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 0.0},- {"x": 0.0, "y": 1000.0, "z": 0.0},- ],- "faces": [[0, 1, 2, 3]],- }-- geom = PreciseGeometry(geometry_data)-- assert len(geom.vertices) == 4- assert len(geom.faces) == 1- assert geom.vertices[0] == (0.0, 0.0, 0.0)- assert geom.vertices[2] == (1000.0, 1000.0, 0.0)---def test_precise_geometry_bounding_box():- """Test getting bounding box from precise geometry."""- geometry_data = {- "vertices": [- {"x": 100.0, "y": 200.0, "z": 300.0},- {"x": 500.0, "y": 600.0, "z": 700.0},- {"x": 150.0, "y": 250.0, "z": 350.0},- ],- }-- geom = PreciseGeometry(geometry_data)- bbox = geom.get_bounding_box()-- assert bbox.min_x == 100.0- assert bbox.min_y == 200.0- assert bbox.min_z == 300.0- assert bbox.max_x == 500.0- assert bbox.max_y == 600.0- assert bbox.max_z == 700.0---def test_precise_geometry_empty():- """Test precise geometry with no vertices."""- geometry_data = {}- geom = PreciseGeometry(geometry_data)-- bbox = geom.get_bounding_box()- assert bbox.min_x == 0- assert bbox.max_x == 0---def test_point_in_bbox():- """Test point-in-bounding-box check."""- geometry_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 1000.0},- ],- }-- geom = PreciseGeometry(geometry_data)- bbox = geom.get_bounding_box()-- # Point inside- assert geom._point_in_bbox((500.0, 500.0, 500.0), bbox) is True-- # Point outside- assert geom._point_in_bbox((1500.0, 1500.0, 1500.0), bbox) is False-- # Point on boundary (should be False with strict < check)- assert geom._point_in_bbox((0.0, 0.0, 0.0), bbox) is False---def test_precise_geometry_intersects():- """Test precise geometry intersection detection."""- # Geometry 1: cube from 0,0,0 to 1000,1000,1000- geom1_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 0.0},- {"x": 0.0, "y": 1000.0, "z": 0.0},- {"x": 0.0, "y": 0.0, "z": 1000.0},- {"x": 1000.0, "y": 0.0, "z": 1000.0},- {"x": 1000.0, "y": 1000.0, "z": 1000.0},- {"x": 0.0, "y": 1000.0, "z": 1000.0},- ],- }-- # Geometry 2: cube from 500,500,500 to 1500,1500,1500 (overlapping)- geom2_data = {- "vertices": [- {"x": 500.0, "y": 500.0, "z": 500.0},- {"x": 1500.0, "y": 500.0, "z": 500.0},- {"x": 1500.0, "y": 1500.0, "z": 500.0},- {"x": 500.0, "y": 1500.0, "z": 500.0},- {"x": 500.0, "y": 500.0, "z": 1500.0},- {"x": 1500.0, "y": 500.0, "z": 1500.0},- {"x": 1500.0, "y": 1500.0, "z": 1500.0},- {"x": 500.0, "y": 1500.0, "z": 1500.0},- ],- }-- geom1 = PreciseGeometry(geom1_data)- geom2 = PreciseGeometry(geom2_data)-- assert geom1.intersects_with(geom2) is True- assert geom2.intersects_with(geom1) is True---def test_precise_geometry_no_intersection():- """Test precise geometry with no intersection."""- # Geometry 1: cube from 0,0,0 to 1000,1000,1000- geom1_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 1000.0},- ],- }-- # Geometry 2: cube from 2000,2000,2000 to 3000,3000,3000 (separated)- geom2_data = {- "vertices": [- {"x": 2000.0, "y": 2000.0, "z": 2000.0},- {"x": 3000.0, "y": 3000.0, "z": 3000.0},- ],- }-- geom1 = PreciseGeometry(geom1_data)- geom2 = PreciseGeometry(geom2_data)-- assert geom1.intersects_with(geom2) is False- assert geom2.intersects_with(geom1) is False---def test_check_precise_clash():- """Test precise clash detection."""- detector = ClashDetector()-- # Overlapping geometries- geom1_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 1000.0},- ],- }-- geom2_data = {- "vertices": [- {"x": 500.0, "y": 500.0, "z": 500.0},- {"x": 1500.0, "y": 1500.0, "z": 1500.0},- ],- }-- geom1 = PreciseGeometry(geom1_data)- geom2 = PreciseGeometry(geom2_data)-- clash = detector.check_precise_clash("wall_1", geom1, "beam_1", geom2)-- assert clash is not None- assert clash.element_id_1 == "wall_1"- assert clash.element_id_2 == "beam_1"- assert clash.clash_type == "precise_geometry"- assert clash.intersection_volume > 0- assert clash.location is not None---def test_check_precise_clash_no_intersection():- """Test precise clash with no intersection."""- detector = ClashDetector()-- geom1_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 1000.0},- ],- }-- geom2_data = {- "vertices": [- {"x": 2000.0, "y": 2000.0, "z": 2000.0},- {"x": 3000.0, "y": 3000.0, "z": 3000.0},- ],- }-- geom1 = PreciseGeometry(geom1_data)- geom2 = PreciseGeometry(geom2_data)-- clash = detector.check_precise_clash("elem_1", geom1, "elem_2", geom2)-- assert clash is None---def test_check_precise_multiple_elements():- """Test precise clash detection for multiple elements."""- detector = ClashDetector()-- elements = [- {- "id": "wall_1",- "geometry": {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 3000.0},- ],- },- },- {- "id": "beam_1",- "geometry": {- "vertices": [- {"x": 500.0, "y": 500.0, "z": 1000.0},- {"x": 1500.0, "y": 1500.0, "z": 2000.0},- ],- },- },- {- "id": "column_1",- "geometry": {- "vertices": [- {"x": 5000.0, "y": 5000.0, "z": 0.0},- {"x": 5500.0, "y": 5500.0, "z": 3000.0},- ],- },- },- ]-- clashes = detector.check_precise_multiple_elements(elements)-- # Should find 1 clash (wall_1 and beam_1)- assert len(clashes) == 1- assert clashes[0].element_id_1 == "wall_1"- assert clashes[0].element_id_2 == "beam_1"- assert clashes[0].clash_type == "precise_geometry"---def test_precise_clash_severity():- """Test severity calculation for precise clashes."""- detector = ClashDetector()-- # Large intersection- geom1_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 2000.0, "y": 2000.0, "z": 2000.0},- ],- }-- geom2_data = {- "vertices": [- {"x": 1000.0, "y": 1000.0, "z": 1000.0},- {"x": 3000.0, "y": 3000.0, "z": 3000.0},- ],- }-- geom1 = PreciseGeometry(geom1_data)- geom2 = PreciseGeometry(geom2_data)-- clash = detector.check_precise_clash("e1", geom1, "e2", geom2)-- # 1000³ mm³ = 1 m³ = critical- assert clash.severity == "critical"---def test_mixed_precise_and_bbox_clashes():- """Test detector can handle both precise and bounding box clashes."""- from model_checker.clash_detection import BoundingBox-- detector = ClashDetector()-- # Add bbox clash- bbox1 = BoundingBox(0, 0, 0, 1000, 1000, 1000)- bbox2 = BoundingBox(500, 500, 500, 1500, 1500, 1500)- detector.check_bounding_box_clash("e1", bbox1, "e2", bbox2)-- # Add precise clash (overlapping cubes)- geom1_data = {- "vertices": [- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 1000.0, "z": 1000.0},- ]- }- geom2_data = {- "vertices": [- {"x": 500.0, "y": 500.0, "z": 500.0},- {"x": 1500.0, "y": 1500.0, "z": 1500.0},- ]- }- geom1 = PreciseGeometry(geom1_data)- geom2 = PreciseGeometry(geom2_data)- detector.check_precise_clash("e3", geom1, "e4", geom2)-- assert detector.get_total_clashes() == 2- assert len(detector.clashes) == 2---def test_precise_geometry_complex_shape():- """Test precise geometry with complex shape."""- # L-shaped geometry- geom_data = {- "vertices": [- # Bottom horizontal part- {"x": 0.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 0.0, "z": 0.0},- {"x": 1000.0, "y": 200.0, "z": 0.0},- {"x": 0.0, "y": 200.0, "z": 0.0},- # Vertical part- {"x": 0.0, "y": 200.0, "z": 0.0},- {"x": 200.0, "y": 200.0, "z": 0.0},- {"x": 200.0, "y": 800.0, "z": 0.0},- {"x": 0.0, "y": 800.0, "z": 0.0},- ],- "faces": [[0, 1, 2, 3], [4, 5, 6, 7]],- }-- geom = PreciseGeometry(geom_data)-- assert len(geom.vertices) == 8- assert len(geom.faces) == 2-- bbox = geom.get_bounding_box()- assert bbox.min_x == 0.0- assert bbox.max_x == 1000.0- assert bbox.min_y == 0.0- assert bbox.max_y == 800.0diff --git a/packages/model-checker/tests/test_reporting_and_cli.py b/packages/model-checker/tests/test_reporting_and_cli.pydeleted file mode 100644index 434ad61..0000000--- a/packages/model-checker/tests/test_reporting_and_cli.py+++ /dev/null@@ -1,247 +0,0 @@-"""Test reporting and CLI features (Scaffolds 8 & 9)."""--import tempfile-from pathlib import Path--from model_checker.reporting import (- AutomatedCheckRunner,- HTMLReportGenerator,- IssuePrioritizer,- ModelCheckerCLI,- ReportExporter,-)---# SCAFFOLD 8 TESTS: Reporting--def test_html_report_generator():- """Test HTML report generation."""- generator = HTMLReportGenerator("Test Project")-- issues = [- {- "element_id": "wall_1",- "element_type": "wall",- "issue_type": "undersized",- "description": "Wall too thin",- "severity": "critical",- }- ]-- generator.add_issues(issues)- html = generator.generate_html()-- assert "Test Project" in html- assert "wall_1" in html- assert "critical" in html---def test_html_report_save():- """Test saving HTML report to file."""- generator = HTMLReportGenerator("Save Test")- generator.add_issues([{"element_id": "test", "severity": "low"}])-- with tempfile.TemporaryDirectory() as tmpdir:- filepath = Path(tmpdir) / "report.html"- generator.save_html(filepath)-- assert filepath.exists()- content = filepath.read_text()- assert "Save Test" in content---def test_issue_prioritizer():- """Test issue prioritization."""- prioritizer = IssuePrioritizer()-- issues = [- {"severity": "low", "description": "Low issue"},- {"severity": "critical", "description": "Critical issue"},- {"severity": "medium", "description": "Medium issue"},- {"severity": "high", "description": "High issue"},- ]-- prioritizer.add_issues(issues)- prioritized = prioritizer.prioritize()-- assert prioritized[0]["severity"] == "critical"- assert prioritized[-1]["severity"] == "low"---def test_issue_prioritizer_top_issues():- """Test getting top priority issues."""- prioritizer = IssuePrioritizer()-- issues = [{"severity": f"issue_{i}"} for i in range(20)]- prioritizer.add_issues(issues)-- top10 = prioritizer.get_top_issues(limit=10)- assert len(top10) == 10---def test_report_exporter_csv():- """Test exporting to CSV."""- exporter = ReportExporter()-- issues = [- {"element_id": "1", "type": "wall", "severity": "high"},- {"element_id": "2", "type": "beam", "severity": "medium"},- ]-- exporter.add_issues(issues)-- with tempfile.TemporaryDirectory() as tmpdir:- filepath = Path(tmpdir) / "issues.csv"- exporter.export_csv(filepath)-- assert filepath.exists()- content = filepath.read_text()- assert "element_id" in content- assert "wall" in content---def test_report_exporter_json():- """Test exporting to JSON."""- exporter = ReportExporter()-- issues = [{"element_id": "wall_1", "severity": "critical"}]- exporter.add_issues(issues)-- with tempfile.TemporaryDirectory() as tmpdir:- filepath = Path(tmpdir) / "issues.json"- exporter.export_json(filepath)-- assert filepath.exists()- import json-- with open(filepath) as f:- data = json.load(f)- assert len(data) == 1---def test_report_exporter_markdown():- """Test exporting to Markdown."""- exporter = ReportExporter()-- issues = [{"element_id": "beam_1", "element_type": "beam", "severity": "high"}]- exporter.add_issues(issues)-- with tempfile.TemporaryDirectory() as tmpdir:- filepath = Path(tmpdir) / "issues.md"- exporter.export_markdown(filepath)-- assert filepath.exists()- content = filepath.read_text()- assert "beam_1" in content- assert "| " in content # Markdown table---# SCAFFOLD 9 TESTS: CLI and Automation--def test_cli_run_checks():- """Test CLI check running."""- cli = ModelCheckerCLI()-- results = cli.run_checks("test_project.rvt", checks=["clash", "naming"])-- assert results["project"] == "test_project.rvt"- assert "clash" in results["checks_run"]- assert "timestamp" in results---def test_cli_format_text():- """Test CLI text formatting."""- cli = ModelCheckerCLI()- cli.run_checks("test.rvt")-- output = cli.format_output(format="text")-- assert "test.rvt" in output- assert "Total Issues" in output---def test_cli_format_json():- """Test CLI JSON formatting."""- cli = ModelCheckerCLI()- cli.run_checks("test.rvt")-- output = cli.format_output(format="json")-- import json-- data = json.loads(output)- assert data["project"] == "test.rvt"---def test_automated_check_runner():- """Test automated check scheduling."""- runner = AutomatedCheckRunner()-- runner.schedule_check("clash_detection", interval_hours=24.0)- runner.schedule_check("naming_validation", on_events=["save"])-- assert len(runner.scheduled_checks) == 2---def test_scheduled_check_running():- """Test running scheduled checks."""- runner = AutomatedCheckRunner()-- runner.schedule_check("test_check", interval_hours=0.001) # Very short interval-- results = runner.run_scheduled_checks()-- assert len(results) == 1- assert results[0]["check_type"] == "test_check"---def test_event_triggered_checks():- """Test event-triggered checks."""- runner = AutomatedCheckRunner()-- runner.schedule_check("on_save_check", on_events=["save"])- runner.schedule_check("on_sync_check", on_events=["sync"])-- results = runner.trigger_check_on_event("save")-- assert len(results) == 1- assert results[0]["triggered_by"] == "save"---def test_complete_reporting_workflow():- """Test complete reporting workflow."""- # Generate issues- issues = [- {"element_id": "wall_1", "severity": "critical", "description": "Critical wall issue"},- {"element_id": "beam_1", "severity": "high", "description": "High beam issue"},- {"element_id": "door_1", "severity": "medium", "description": "Medium door issue"},- ]-- # Prioritize- prioritizer = IssuePrioritizer()- prioritizer.add_issues(issues)- top_issues = prioritizer.get_top_issues(limit=2)-- assert len(top_issues) == 2- assert top_issues[0]["severity"] == "critical"-- # Generate HTML report- html_gen = HTMLReportGenerator("Complete Workflow Test")- html_gen.add_issues(issues)- html = html_gen.generate_html()-- assert "wall_1" in html- assert "Critical wall issue" in html-- # Export to multiple formats- exporter = ReportExporter()- exporter.add_issues(issues)-- with tempfile.TemporaryDirectory() as tmpdir:- exporter.export_csv(Path(tmpdir) / "issues.csv")- exporter.export_json(Path(tmpdir) / "issues.json")- exporter.export_markdown(Path(tmpdir) / "issues.md")-- assert (Path(tmpdir) / "issues.csv").exists()- assert (Path(tmpdir) / "issues.json").exists()- assert (Path(tmpdir) / "issues.md").exists()diff --git a/packages/model-checker/tests/test_rooms_and_docs.py b/packages/model-checker/tests/test_rooms_and_docs.pydeleted file mode 100644index d6d624e..0000000--- a/packages/model-checker/tests/test_rooms_and_docs.py+++ /dev/null@@ -1,135 +0,0 @@-"""Test room and documentation validation (Scaffolds 6 & 7)."""--from model_checker.rooms import DocumentationValidator, RoomValidator---# SCAFFOLD 6 TESTS: Rooms--def test_validate_room_boundaries():- """Test room boundary validation."""- validator = RoomValidator()-- rooms = [- {"id": "room_1", "name": "Office 1", "is_bound": True},- {"id": "room_2", "name": "Office 2", "is_bound": False}, # Unbound- {"id": "room_3", "name": "Office 3", "is_bound": True, "overlaps_with": "room_1"}, # Overlapping- ]-- issues = validator.validate_room_boundaries(rooms)- assert len(issues) == 2 # 1 unbound + 1 overlapping---def test_validate_room_areas():- """Test room area validation."""- validator = RoomValidator()-- rooms = [- {"id": "room_1", "area": 3.0}, # Too small- {"id": "room_2", "area": 600.0}, # Too large- {"id": "room_3", "area": 50.0, "required_area": 60.0}, # Mismatch (>10%)- {"id": "room_4", "area": 100.0, "required_area": 105.0}, # OK (within 10%)- ]-- issues = validator.validate_room_areas(rooms, min_area=5.0, max_area=500.0)- assert len(issues) == 3 # Too small, too large, mismatch---def test_validate_occupancy():- """Test occupancy and egress validation."""- validator = RoomValidator()-- rooms = [- {"id": "room_1", "area": 100.0, "has_exit_access": True, "exit_width": 1500}, # OK- {"id": "room_2", "area": 50.0, "has_exit_access": False, "exit_width": 0}, # No exit- {"id": "room_3", "area": 200.0, "has_exit_access": True, "exit_width": 900}, # Insufficient width- ]-- issues = validator.validate_occupancy(rooms, max_occupant_load_factor=10.0)- assert len(issues) >= 2 # No exit + insufficient width---# SCAFFOLD 7 TESTS: Documentation--def test_validate_view_coverage():- """Test view coverage validation."""- validator = DocumentationValidator()-- views = [- {"id": "view_1", "type": "floor_plan"},- {"id": "view_2", "type": "section"},- ]-- elements = [- {"id": "elem_1", "type": "wall", "visible_in_views": ["view_1"], "required_view_types": ["floor_plan"]}, # OK- {"id": "elem_2", "type": "beam", "visible_in_views": [], "required_view_types": ["floor_plan"]}, # Missing- ]-- issues = validator.validate_view_coverage(elements, views)- assert len(issues) == 1 # elem_2 not in floor plan---def test_validate_sheets():- """Test sheet validation."""- validator = DocumentationValidator()-- sheets = [- {"id": "sheet_1", "number": "A-101", "has_titleblock": True, "viewports": ["vp_1"]}, # OK- {"id": "sheet_2", "number": "A-102", "has_titleblock": False, "viewports": []}, # No titleblock, no views- {"id": "sheet_3", "number": "A-103", "has_titleblock": True, "viewports": []}, # No views- ]-- issues = validator.validate_sheets(sheets)- assert len(issues) == 3 # sheet_2: 2 issues, sheet_3: 1 issue---def test_validate_revisions():- """Test revision tracking validation."""- validator = DocumentationValidator()-- revisions = [- {"id": "rev_1", "description": "Initial Issue"},- {"id": "rev_2", "description": "Design Development"},- ]-- sheets = [- {"id": "sheet_1", "revisions": ["rev_1"], "has_revision_clouds": True}, # OK- {"id": "sheet_2", "revisions": ["rev_999"], "has_revision_clouds": False}, # Invalid revision- {"id": "sheet_3", "revisions": ["rev_2"], "has_revision_clouds": False}, # Missing clouds- ]-- issues = validator.validate_revisions(sheets, revisions)- assert len(issues) == 3 # sheet_2: invalid revision + missing clouds, sheet_3: missing clouds---def test_complete_room_workflow():- """Test complete room validation workflow."""- validator = RoomValidator()-- rooms = [- {"id": "office_1", "name": "Office", "is_bound": True, "area": 25.0, "has_exit_access": True, "exit_width": 900},- {"id": "conf_1", "name": "Conference", "is_bound": False, "area": 2.0, "has_exit_access": False, "exit_width": 0},- ]-- validator.validate_room_boundaries(rooms)- validator.validate_room_areas(rooms, min_area=5.0)- validator.validate_occupancy(rooms)-- issues = validator.get_issues()- assert len(issues) >= 3 # Unbound, too small area, no exit---def test_complete_documentation_workflow():- """Test complete documentation validation workflow."""- validator = DocumentationValidator()-- views = [{"id": "view_1", "type": "floor_plan"}]- elements = [{"id": "elem_1", "visible_in_views": [], "required_view_types": ["floor_plan"]}]- sheets = [{"id": "sheet_1", "number": "A-101", "has_titleblock": False, "viewports": []}]- revisions = []-- validator.validate_view_coverage(elements, views)- validator.validate_sheets(sheets)- validator.validate_revisions(sheets, revisions)-- issues = validator.get_issues()- assert len(issues) >= 3 # Missing from view + no titleblock + no viewsdiff --git a/packages/model-checker/tests/test_rule_engine.py b/packages/model-checker/tests/test_rule_engine.pydeleted file mode 100644index 9e14da5..0000000--- a/packages/model-checker/tests/test_rule_engine.py+++ /dev/null@@ -1,305 +0,0 @@-"""Test the rule engine functionality."""--import pytest--from model_checker import Rule, RuleEngine, RuleSeverity---def test_create_rule():- """Test creating a basic rule."""- rule = Rule(- id="test_rule_1",- name="Test Rule",- description="A test rule",- category="testing",- severity=RuleSeverity.HIGH,- check_function=lambda x: x > 0,- )-- assert rule.id == "test_rule_1"- assert rule.name == "Test Rule"- assert rule.severity == RuleSeverity.HIGH- assert rule.category == "testing"---def test_rule_execute():- """Test executing a rule's check function."""- rule = Rule(- id="positive_check",- name="Positive Number Check",- description="Checks if number is positive",- category="math",- severity=RuleSeverity.MEDIUM,- check_function=lambda x: x > 0,- )-- assert rule.execute(5) is True- assert rule.execute(-3) is False- assert rule.execute(0) is False---def test_rule_engine_initialization():- """Test creating a rule engine."""- engine = RuleEngine()- assert len(engine.rules) == 0- assert len(engine.rules_by_category) == 0---def test_register_rule():- """Test registering a rule with the engine."""- engine = RuleEngine()- rule = Rule(- id="rule_1",- name="Rule 1",- description="First rule",- category="test",- severity=RuleSeverity.LOW,- check_function=lambda x: True,- )-- engine.register_rule(rule)-- assert len(engine.rules) == 1- assert "rule_1" in engine.rules- assert engine.rules["rule_1"] == rule---def test_register_multiple_rules():- """Test registering multiple rules."""- engine = RuleEngine()-- rule1 = Rule(- id="rule_1",- name="Rule 1",- description="First rule",- category="geometry",- severity=RuleSeverity.HIGH,- check_function=lambda x: x > 0,- )-- rule2 = Rule(- id="rule_2",- name="Rule 2",- description="Second rule",- category="naming",- severity=RuleSeverity.MEDIUM,- check_function=lambda x: len(x) > 5,- )-- engine.register_rule(rule1)- engine.register_rule(rule2)-- assert len(engine.rules) == 2- assert "rule_1" in engine.rules- assert "rule_2" in engine.rules---def test_get_rule():- """Test retrieving a rule by ID."""- engine = RuleEngine()- rule = Rule(- id="test_rule",- name="Test Rule",- description="A test",- category="test",- severity=RuleSeverity.INFO,- check_function=lambda x: x,- )-- engine.register_rule(rule)-- retrieved = engine.get_rule("test_rule")- assert retrieved == rule-- not_found = engine.get_rule("nonexistent")- assert not_found is None---def test_rules_by_category():- """Test categorizing rules."""- engine = RuleEngine()-- geometry_rule = Rule(- id="geo_1",- name="Geometry Rule 1",- description="Check geometry",- category="geometry",- severity=RuleSeverity.HIGH,- check_function=lambda x: True,- )-- naming_rule = Rule(- id="name_1",- name="Naming Rule 1",- description="Check naming",- category="naming",- severity=RuleSeverity.MEDIUM,- check_function=lambda x: True,- )-- engine.register_rule(geometry_rule)- engine.register_rule(naming_rule)-- geometry_rules = engine.get_rules_by_category("geometry")- naming_rules = engine.get_rules_by_category("naming")-- assert len(geometry_rules) == 1- assert geometry_rules[0] == geometry_rule- assert len(naming_rules) == 1- assert naming_rules[0] == naming_rule---def test_execute_rule():- """Test executing a specific rule."""- engine = RuleEngine()-- rule = Rule(- id="length_check",- name="Length Check",- description="Check if string length > 3",- category="validation",- severity=RuleSeverity.LOW,- check_function=lambda x: len(x) > 3,- )-- engine.register_rule(rule)-- assert engine.execute_rule("length_check", "hello") is True- assert engine.execute_rule("length_check", "hi") is False---def test_execute_nonexistent_rule():- """Test executing a rule that doesn't exist."""- engine = RuleEngine()-- with pytest.raises(KeyError, match="Rule not found"):- engine.execute_rule("nonexistent", "data")---def test_execute_all_rules():- """Test executing all registered rules."""- engine = RuleEngine()-- rule1 = Rule(- id="rule_1",- name="Positive Check",- description="Check positive",- category="math",- severity=RuleSeverity.HIGH,- check_function=lambda x: x > 0,- )-- rule2 = Rule(- id="rule_2",- name="Even Check",- description="Check even",- category="math",- severity=RuleSeverity.MEDIUM,- check_function=lambda x: x % 2 == 0,- )-- engine.register_rule(rule1)- engine.register_rule(rule2)-- results = engine.execute_all_rules(4)-- assert results["rule_1"] is True # 4 > 0- assert results["rule_2"] is True # 4 is even-- results2 = engine.execute_all_rules(-3)-- assert results2["rule_1"] is False # -3 is not positive- assert results2["rule_2"] is False # -3 is not even---def test_execute_category_rules():- """Test executing all rules in a category."""- engine = RuleEngine()-- geo_rule1 = Rule(- id="geo_1",- name="Area Check",- description="Check area",- category="geometry",- severity=RuleSeverity.HIGH,- check_function=lambda x: x > 0,- )-- geo_rule2 = Rule(- id="geo_2",- name="Volume Check",- description="Check volume",- category="geometry",- severity=RuleSeverity.HIGH,- check_function=lambda x: x < 1000,- )-- name_rule = Rule(- id="name_1",- name="Name Length",- description="Check name",- category="naming",- severity=RuleSeverity.LOW,- check_function=lambda x: True,- )-- engine.register_rule(geo_rule1)- engine.register_rule(geo_rule2)- engine.register_rule(name_rule)-- results = engine.execute_category_rules("geometry", 500)-- assert len(results) == 2- assert results["geo_1"] is True # 500 > 0- assert results["geo_2"] is True # 500 < 1000- assert "name_1" not in results # naming rule not executed---def test_complete_workflow():- """Test a complete rule engine workflow."""- # Create engine- engine = RuleEngine()-- # Define rules for wall validation- min_height_rule = Rule(- id="wall_min_height",- name="Minimum Wall Height",- description="Wall height must be at least 2400mm",- category="walls",- severity=RuleSeverity.CRITICAL,- check_function=lambda wall: wall.get("height", 0) >= 2400,- )-- max_length_rule = Rule(- id="wall_max_length",- name="Maximum Wall Length",- description="Wall length should not exceed 12000mm",- category="walls",- severity=RuleSeverity.MEDIUM,- check_function=lambda wall: wall.get("length", 0) <= 12000,- )-- # Register rules- engine.register_rule(min_height_rule)- engine.register_rule(max_length_rule)-- # Test valid wall- valid_wall = {"height": 3000, "length": 6000}- results = engine.execute_category_rules("walls", valid_wall)-- assert results["wall_min_height"] is True- assert results["wall_max_length"] is True-- # Test invalid wall (too short)- invalid_wall = {"height": 2000, "length": 6000}- results2 = engine.execute_category_rules("walls", invalid_wall)-- assert results2["wall_min_height"] is False- assert results2["wall_max_length"] is True-- # Test invalid wall (too long)- invalid_wall2 = {"height": 3000, "length": 15000}- results3 = engine.execute_category_rules("walls", invalid_wall2)-- assert results3["wall_min_height"] is True- assert results3["wall_max_length"] is Falsediff --git a/packages/model-checker/tests/test_standards.py b/packages/model-checker/tests/test_standards.pydeleted file mode 100644index 7bd2493..0000000--- a/packages/model-checker/tests/test_standards.py+++ /dev/null@@ -1,402 +0,0 @@-"""Test standards compliance checking."""--import pytest--from model_checker.standards import (- NamingConventionValidator,- NamingRule,- ParameterRule,-)---def test_create_naming_rule():- """Test creating a naming rule."""- rule = NamingRule(- id="test_rule",- name="Test Rule",- category="views",- pattern=r"^FP-\d+$",- description="Floor plans must be FP-NNN",- )-- assert rule.id == "test_rule"- assert rule.name == "Test Rule"- assert rule.pattern == r"^FP-\d+$"- assert rule.compiled_pattern is not None---def test_naming_rule_matches():- """Test naming rule pattern matching."""- rule = NamingRule(- id="floor_plan",- name="Floor Plan",- category="views",- pattern=r"^FP-L\d{2}$",- description="Floor plan naming",- )-- assert rule.matches("FP-L01") is True- assert rule.matches("FP-L10") is True- assert rule.matches("FP-ROOF") is False- assert rule.matches("SEC-A") is False---def test_create_naming_validator():- """Test creating naming convention validator."""- validator = NamingConventionValidator()-- assert len(validator.rules) == 0- assert len(validator.violations) == 0---def test_add_naming_rule():- """Test adding a naming rule."""- validator = NamingConventionValidator()-- rule = NamingRule(- id="sheet_rule",- name="Sheet Naming",- category="sheets",- pattern=r"^A-\d{3}$",- description="Architectural sheets",- )-- validator.add_rule(rule)-- assert len(validator.rules) == 1- assert "sheet_rule" in validator.rules---def test_add_view_naming_rules():- """Test adding standard view naming rules."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()-- assert len(validator.rules) > 0- assert "view_floor_plan" in validator.rules- assert "view_section" in validator.rules- assert "view_3d" in validator.rules---def test_add_sheet_naming_rules():- """Test adding standard sheet naming rules."""- validator = NamingConventionValidator()- validator.add_sheet_naming_rules()-- assert "sheet_number" in validator.rules---def test_add_family_naming_rules():- """Test adding standard family naming rules."""- validator = NamingConventionValidator()- validator.add_family_naming_rules()-- assert "family_wall" in validator.rules- assert "family_door" in validator.rules- assert "family_window" in validator.rules---def test_validate_name_with_specific_rule():- """Test validating a name with a specific rule."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()-- # Valid floor plan name- is_valid, error = validator.validate_name("FP-L01", "view", "view_floor_plan")- assert is_valid is True- assert error is None-- # Invalid floor plan name- is_valid, error = validator.validate_name("FloorPlan-01", "view", "view_floor_plan")- assert is_valid is False- assert error is not None---def test_validate_name_any_rule():- """Test validating a name against any matching rule."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()-- # Valid section name- is_valid, error = validator.validate_name("SEC-A", "view")- assert is_valid is True-- # Invalid name- is_valid, error = validator.validate_name("RandomName", "view")- assert is_valid is False---def test_validate_element():- """Test validating an element and recording violations."""- validator = NamingConventionValidator()- validator.add_sheet_naming_rules()-- # Valid sheet- is_valid = validator.validate_element(- element_id="sheet_1", element_name="A-101", element_type="sheet", rule_id="sheet_number"- )- assert is_valid is True- assert len(validator.violations) == 0-- # Invalid sheet- is_valid = validator.validate_element(- element_id="sheet_2",- element_name="Arch-Sheet-1",- element_type="sheet",- rule_id="sheet_number",- )- assert is_valid is False- assert len(validator.violations) == 1---def test_get_violations():- """Test getting all violations."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()-- validator.validate_element("view_1", "BadName1", "view")- validator.validate_element("view_2", "BadName2", "view")-- violations = validator.get_violations()- assert len(violations) == 2---def test_get_violations_by_type():- """Test getting violations by element type."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()- validator.add_sheet_naming_rules()-- validator.validate_element("view_1", "BadView", "view")- validator.validate_element("sheet_1", "BadSheet", "sheet")-- view_violations = validator.get_violations_by_type("view")- sheet_violations = validator.get_violations_by_type("sheet")-- assert len(view_violations) == 1- assert len(sheet_violations) == 1---def test_clear_violations():- """Test clearing violations."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()-- validator.validate_element("view_1", "BadName", "view")- assert len(validator.violations) > 0-- validator.clear_violations()- assert len(validator.violations) == 0---def test_get_violation_count():- """Test getting violation count."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()-- for i in range(5):- validator.validate_element(f"view_{i}", f"BadName{i}", "view")-- assert validator.get_violation_count() == 5---def test_view_naming_patterns():- """Test various view naming patterns."""- validator = NamingConventionValidator()- validator.add_view_naming_rules()-- # Floor plans- assert validator.validate_name("FP-L01", "view", "view_floor_plan")[0] is True- assert validator.validate_name("FP-ROOF", "view", "view_floor_plan")[0] is True- assert validator.validate_name("FP-B1", "view", "view_floor_plan")[0] is True-- # Sections- assert validator.validate_name("SEC-A", "view", "view_section")[0] is True- assert validator.validate_name("SEC-1", "view", "view_section")[0] is True-- # 3D Views- assert validator.validate_name("3D-ARCH", "view", "view_3d")[0] is True- assert validator.validate_name("3D-STRUCT", "view", "view_3d")[0] is True---def test_sheet_naming_patterns():- """Test sheet naming patterns."""- validator = NamingConventionValidator()- validator.add_sheet_naming_rules()-- # Valid sheets- assert validator.validate_name("A-101", "sheet", "sheet_number")[0] is True- assert validator.validate_name("M-201", "sheet", "sheet_number")[0] is True- assert validator.validate_name("E-301", "sheet", "sheet_number")[0] is True-- # Invalid sheets- assert validator.validate_name("A101", "sheet", "sheet_number")[0] is False- assert validator.validate_name("Arch-101", "sheet", "sheet_number")[0] is False---def test_family_naming_patterns():- """Test family naming patterns."""- validator = NamingConventionValidator()- validator.add_family_naming_rules()-- # Walls- assert validator.validate_name("W-EXT-200", "family", "family_wall")[0] is True- assert validator.validate_name("W-INT-100", "family", "family_wall")[0] is True-- # Doors- assert validator.validate_name("D-SINGLE-900", "family", "family_door")[0] is True- assert validator.validate_name("D-DOUBLE-1800", "family", "family_door")[0] is True-- # Windows- assert validator.validate_name("WN-FIXED-1200", "family", "family_window")[0] is True- assert validator.validate_name("WN-CASEMENT-900", "family", "family_window")[0] is True---def test_create_parameter_rule():- """Test creating a parameter rule."""- rule = ParameterRule(- id="mark_required",- name="Mark Parameter",- parameter_name="Mark",- required=True,- )-- assert rule.id == "mark_required"- assert rule.parameter_name == "Mark"- assert rule.required is True---def test_parameter_required_validation():- """Test required parameter validation."""- rule = ParameterRule(- id="mark_required",- name="Mark Required",- parameter_name="Mark",- required=True,- )-- # Missing value- is_valid, error = rule.validate_value(None)- assert is_valid is False- assert "missing" in error.lower()-- # Empty string- is_valid, error = rule.validate_value("")- assert is_valid is False-- # Valid value- is_valid, error = rule.validate_value("W-101")- assert is_valid is True---def test_parameter_optional_validation():- """Test optional parameter validation."""- rule = ParameterRule(- id="comment_optional",- name="Comment Optional",- parameter_name="Comments",- required=False,- )-- # Missing value is okay- is_valid, error = rule.validate_value(None)- assert is_valid is True---def test_parameter_type_validation():- """Test parameter type validation."""- rule = ParameterRule(- id="height_number",- name="Height Number",- parameter_name="Height",- value_type="float",- )-- # Valid float- is_valid, error = rule.validate_value(3000.0)- assert is_valid is True-- # Invalid type (string)- is_valid, error = rule.validate_value("3000")- assert is_valid is False---def test_parameter_allowed_values():- """Test parameter allowed values validation."""- rule = ParameterRule(- id="fire_rating",- name="Fire Rating",- parameter_name="Fire Rating",- allowed_values=["1HR", "2HR", "3HR", "None"],- )-- # Valid value- is_valid, error = rule.validate_value("2HR")- assert is_valid is True-- # Invalid value- is_valid, error = rule.validate_value("4HR")- assert is_valid is False---def test_parameter_numeric_range():- """Test parameter numeric range validation."""- rule = ParameterRule(- id="wall_height",- name="Wall Height Range",- parameter_name="Height",- min_value=2400.0,- max_value=6000.0,- )-- # Valid value- is_valid, error = rule.validate_value(3000.0)- assert is_valid is True-- # Too low- is_valid, error = rule.validate_value(2000.0)- assert is_valid is False-- # Too high- is_valid, error = rule.validate_value(7000.0)- assert is_valid is False---def test_parameter_pattern_validation():- """Test parameter pattern validation."""- rule = ParameterRule(- id="mark_pattern",- name="Mark Pattern",- parameter_name="Mark",- pattern=r"^[A-Z]-\d{3}$",- )-- # Valid pattern- is_valid, error = rule.validate_value("A-101")- assert is_valid is True-- # Invalid pattern- is_valid, error = rule.validate_value("Wall-1")- assert is_valid is False---def test_parameter_custom_validator():- """Test parameter custom validator function."""-- def is_even(value):- return isinstance(value, int) and value % 2 == 0-- rule = ParameterRule(- id="even_number",- name="Even Number",- parameter_name="Count",- validator_function=is_even,- )-- # Valid (even)- is_valid, error = rule.validate_value(4)- assert is_valid is True-- # Invalid (odd)- is_valid, error = rule.validate_value(3)- assert is_valid is Falsediff --git a/packages/model-checker/tests/test_structural.py b/packages/model-checker/tests/test_structural.pydeleted file mode 100644index 7ccd412..0000000--- a/packages/model-checker/tests/test_structural.py+++ /dev/null@@ -1,201 +0,0 @@-"""Test structural validation."""--import pytest--from model_checker.structural import StructuralValidator---def test_validate_beam_connections_valid():- """Test validating properly connected beams."""- validator = StructuralValidator()-- columns = [- {"id": "col_1", "location": {"x": 0, "y": 0, "z": 0}},- {"id": "col_2", "location": {"x": 6000, "y": 0, "z": 0}},- ]-- beams = [- {- "id": "beam_1",- "start_point": {"x": 0, "y": 0, "z": 3000},- "end_point": {"x": 6000, "y": 0, "z": 3000},- }- ]-- issues = validator.validate_beam_connections(beams, columns)- assert len(issues) == 0---def test_validate_beam_unconnected_start():- """Test detecting beam with unconnected start."""- validator = StructuralValidator()-- columns = [{"id": "col_1", "location": {"x": 6000, "y": 0, "z": 0}}]-- beams = [- {- "id": "beam_1",- "start_point": {"x": 0, "y": 0, "z": 3000}, # No column here- "end_point": {"x": 6000, "y": 0, "z": 3000},- }- ]-- issues = validator.validate_beam_connections(beams, columns)- assert len(issues) == 1- assert issues[0].issue_type == "unconnected_start"- assert issues[0].severity == "critical"---def test_validate_beam_both_unconnected():- """Test detecting beam with both ends unconnected."""- validator = StructuralValidator()-- columns = []- beams = [- {- "id": "beam_1",- "start_point": {"x": 0, "y": 0, "z": 3000},- "end_point": {"x": 6000, "y": 0, "z": 3000},- }- ]-- issues = validator.validate_beam_connections(beams, columns)- assert len(issues) == 2 # Both start and end---def test_validate_foundations_valid():- """Test validating columns with foundations."""- validator = StructuralValidator()-- columns = [- {"id": "col_1", "name": "C1", "base_point": {"x": 0, "y": 0, "z": 0}},- {"id": "col_2", "name": "C2", "base_point": {"x": 6000, "y": 0, "z": 0}},- ]-- foundations = [- {"id": "found_1", "location": {"x": 0, "y": 0, "z": -500}},- {"id": "found_2", "location": {"x": 6000, "y": 0, "z": -500}},- ]-- issues = validator.validate_foundations(columns, foundations)- assert len(issues) == 0---def test_validate_foundations_missing():- """Test detecting columns without foundations."""- validator = StructuralValidator()-- columns = [- {"id": "col_1", "name": "C1", "base_point": {"x": 0, "y": 0, "z": 0}},- {"id": "col_2", "name": "C2", "base_point": {"x": 6000, "y": 0, "z": 0}},- ]-- foundations = [- {"id": "found_1", "location": {"x": 0, "y": 0, "z": -500}} # Only one foundation- ]-- issues = validator.validate_foundations(columns, foundations)- assert len(issues) == 1- assert issues[0].issue_type == "missing_foundation"- assert issues[0].element_id == "col_2"---def test_validate_load_path_complete():- """Test validating complete load path."""- validator = StructuralValidator()-- roof_elements = [{"id": "roof_1", "location": {"x": 3000, "y": 0, "z": 6000}}]-- beams = [- {- "id": "beam_1",- "start_point": {"x": 0, "y": 0, "z": 3000},- "end_point": {"x": 6000, "y": 0, "z": 3000},- }- ]-- columns = [- {"id": "col_1", "base_point": {"x": 0, "y": 0, "z": 0}},- {"id": "col_2", "base_point": {"x": 6000, "y": 0, "z": 0}},- ]-- foundations = [- {"id": "found_1", "location": {"x": 0, "y": 0, "z": -500}},- {"id": "found_2", "location": {"x": 6000, "y": 0, "z": -500}},- ]-- issues = validator.validate_load_path(roof_elements, beams, columns, foundations)- # May have some issues depending on simplified geometry matching- assert isinstance(issues, list)---def test_validate_load_path_broken():- """Test detecting broken load path."""- validator = StructuralValidator()-- roof_elements = []- beams = []- columns = [{"id": "col_1", "base_point": {"x": 0, "y": 0, "z": 0}}]- foundations = [] # No foundations-- issues = validator.validate_load_path(roof_elements, beams, columns, foundations)- broken_path_issues = [i for i in issues if i.issue_type == "broken_load_path"]- assert len(broken_path_issues) > 0---def test_get_critical_issues():- """Test getting critical issues."""- validator = StructuralValidator()-- columns = [{"id": "col_1", "base_point": {"x": 0, "y": 0, "z": 0}}]- foundations = []-- validator.validate_foundations(columns, foundations)-- critical = validator.get_critical_issues()- assert len(critical) == 1- assert critical[0].severity == "critical"---def test_complete_structural_workflow():- """Test complete structural validation."""- validator = StructuralValidator()-- # Building structure- columns = [- {"id": "col_1", "name": "C1", "location": {"x": 0, "y": 0, "z": 0}, "base_point": {"x": 0, "y": 0, "z": 0}},- {"id": "col_2", "name": "C2", "location": {"x": 6000, "y": 0, "z": 0}, "base_point": {"x": 6000, "y": 0, "z": 0}},- {"id": "col_3", "name": "C3", "location": {"x": 12000, "y": 0, "z": 0}, "base_point": {"x": 12000, "y": 0, "z": 0}},- ]-- beams = [- {- "id": "beam_1",- "start_point": {"x": 0, "y": 0, "z": 3000},- "end_point": {"x": 6000, "y": 0, "z": 3000},- },- {- "id": "beam_2",- "start_point": {"x": 6000, "y": 0, "z": 3000},- "end_point": {"x": 18000, "y": 0, "z": 3000}, # Extends beyond col_3- },- ]-- foundations = [- {"id": "found_1", "location": {"x": 0, "y": 0, "z": -500}},- {"id": "found_2", "location": {"x": 6000, "y": 0, "z": -500}},- # Missing foundation for col_3- ]-- roof_elements = [{"id": "roof_1", "location": {"x": 3000, "y": 0, "z": 6000}}]-- # Run all validations- validator.validate_beam_connections(beams, columns)- validator.validate_foundations(columns, foundations)- validator.validate_load_path(roof_elements, beams, columns, foundations)-- total_issues = validator.get_issue_count()- assert total_issues >= 2 # At minimum: beam_2 unconnected end + col_3 missing foundation-- critical_issues = validator.get_critical_issues()- assert len(critical_issues) >= 2diff --git a/packages/model-checker/tests/test_validator.py b/packages/model-checker/tests/test_validator.pydeleted file mode 100644index 6febd1d..0000000--- a/packages/model-checker/tests/test_validator.py+++ /dev/null@@ -1,412 +0,0 @@-"""Test the validator and report functionality."""--from datetime import datetime--import pytest--from model_checker import (- Rule,- RuleEngine,- RuleSeverity,- ValidationIssue,- ValidationReport,- Validator,-)---def test_create_validation_issue():- """Test creating a validation issue."""- issue = ValidationIssue(- rule_id="test_rule",- rule_name="Test Rule",- severity=RuleSeverity.HIGH,- category="testing",- element_id="elem_123",- description="Test issue description",- )-- assert issue.rule_id == "test_rule"- assert issue.rule_name == "Test Rule"- assert issue.severity == RuleSeverity.HIGH- assert issue.category == "testing"- assert issue.element_id == "elem_123"- assert issue.description == "Test issue description"- assert isinstance(issue.timestamp, datetime)---def test_validation_issue_to_dict():- """Test converting validation issue to dictionary."""- issue = ValidationIssue(- rule_id="wall_height",- rule_name="Wall Height Check",- severity=RuleSeverity.CRITICAL,- category="geometry",- element_id=12345,- description="Wall height below minimum",- location={"x": 100, "y": 200, "z": 0},- )-- data = issue.to_dict()-- assert data["rule_id"] == "wall_height"- assert data["rule_name"] == "Wall Height Check"- assert data["severity"] == "critical"- assert data["category"] == "geometry"- assert data["element_id"] == 12345- assert data["description"] == "Wall height below minimum"- assert data["location"] == {"x": 100, "y": 200, "z": 0}- assert "timestamp" in data---def test_create_validation_report():- """Test creating a validation report."""- report = ValidationReport(project_name="Test Project")-- assert report.project_name == "Test Project"- assert isinstance(report.timestamp, datetime)- assert len(report.issues) == 0- assert report.total_elements_checked == 0- assert report.rules_executed == 0---def test_add_issue_to_report():- """Test adding issues to a report."""- report = ValidationReport(project_name="Test Project")-- issue1 = ValidationIssue(- rule_id="rule_1",- rule_name="Rule 1",- severity=RuleSeverity.HIGH,- category="test",- element_id="elem_1",- description="Issue 1",- )-- issue2 = ValidationIssue(- rule_id="rule_2",- rule_name="Rule 2",- severity=RuleSeverity.MEDIUM,- category="test",- element_id="elem_2",- description="Issue 2",- )-- report.add_issue(issue1)- report.add_issue(issue2)-- assert len(report.issues) == 2- assert report.issues[0] == issue1- assert report.issues[1] == issue2---def test_get_issues_by_severity():- """Test filtering issues by severity."""- report = ValidationReport(project_name="Test")-- critical_issue = ValidationIssue(- rule_id="r1",- rule_name="Critical Rule",- severity=RuleSeverity.CRITICAL,- category="test",- element_id="e1",- description="Critical issue",- )-- high_issue = ValidationIssue(- rule_id="r2",- rule_name="High Rule",- severity=RuleSeverity.HIGH,- category="test",- element_id="e2",- description="High issue",- )-- low_issue = ValidationIssue(- rule_id="r3",- rule_name="Low Rule",- severity=RuleSeverity.LOW,- category="test",- element_id="e3",- description="Low issue",- )-- report.add_issue(critical_issue)- report.add_issue(high_issue)- report.add_issue(low_issue)-- critical_issues = report.get_issues_by_severity(RuleSeverity.CRITICAL)- high_issues = report.get_issues_by_severity(RuleSeverity.HIGH)- low_issues = report.get_issues_by_severity(RuleSeverity.LOW)-- assert len(critical_issues) == 1- assert critical_issues[0] == critical_issue- assert len(high_issues) == 1- assert high_issues[0] == high_issue- assert len(low_issues) == 1- assert low_issues[0] == low_issue---def test_get_issues_by_category():- """Test filtering issues by category."""- report = ValidationReport(project_name="Test")-- geometry_issue = ValidationIssue(- rule_id="g1",- rule_name="Geometry Rule",- severity=RuleSeverity.HIGH,- category="geometry",- element_id="e1",- description="Geometry issue",- )-- naming_issue = ValidationIssue(- rule_id="n1",- rule_name="Naming Rule",- severity=RuleSeverity.MEDIUM,- category="naming",- element_id="e2",- description="Naming issue",- )-- report.add_issue(geometry_issue)- report.add_issue(naming_issue)-- geometry_issues = report.get_issues_by_category("geometry")- naming_issues = report.get_issues_by_category("naming")-- assert len(geometry_issues) == 1- assert geometry_issues[0] == geometry_issue- assert len(naming_issues) == 1- assert naming_issues[0] == naming_issue---def test_report_counts():- """Test report counting methods."""- report = ValidationReport(project_name="Test")-- # Add various severity issues- for i in range(3):- report.add_issue(- ValidationIssue(- rule_id=f"c{i}",- rule_name="Critical",- severity=RuleSeverity.CRITICAL,- category="test",- element_id=f"e{i}",- description="Critical",- )- )-- for i in range(2):- report.add_issue(- ValidationIssue(- rule_id=f"h{i}",- rule_name="High",- severity=RuleSeverity.HIGH,- category="test",- element_id=f"e{i}",- description="High",- )- )-- report.add_issue(- ValidationIssue(- rule_id="m1",- rule_name="Medium",- severity=RuleSeverity.MEDIUM,- category="test",- element_id="e1",- description="Medium",- )- )-- assert report.get_critical_count() == 3- assert report.get_high_count() == 2- assert report.get_total_issues() == 6---def test_validation_report_to_dict():- """Test converting validation report to dictionary."""- report = ValidationReport(project_name="Sample Project")- report.total_elements_checked = 100- report.rules_executed = 25-- issue = ValidationIssue(- rule_id="test_rule",- rule_name="Test Rule",- severity=RuleSeverity.HIGH,- category="test",- element_id="elem_1",- description="Test issue",- )-- report.add_issue(issue)-- data = report.to_dict()-- assert data["project_name"] == "Sample Project"- assert data["total_elements_checked"] == 100- assert data["rules_executed"] == 25- assert data["total_issues"] == 1- assert data["critical_issues"] == 0- assert data["high_issues"] == 1- assert len(data["issues"]) == 1- assert "timestamp" in data---def test_create_validator():- """Test creating a validator."""- engine = RuleEngine()- validator = Validator(engine)-- assert validator.rule_engine == engine- assert validator.current_report is None---def test_validator_create_report():- """Test validator creating a report."""- engine = RuleEngine()- validator = Validator(engine)-- report = validator.create_report("My Project")-- assert report.project_name == "My Project"- assert validator.current_report == report---def test_validate_element():- """Test validating an element against rules."""- engine = RuleEngine()- validator = Validator(engine)- validator.create_report("Test Project")-- # Create rules- min_height_rule = Rule(- id="min_height",- name="Minimum Height",- description="Height must be >= 2400",- category="geometry",- severity=RuleSeverity.CRITICAL,- check_function=lambda elem: elem.get("height", 0) >= 2400,- )-- max_width_rule = Rule(- id="max_width",- name="Maximum Width",- description="Width must be <= 1000",- category="geometry",- severity=RuleSeverity.HIGH,- check_function=lambda elem: elem.get("width", 0) <= 1000,- )-- # Validate valid element- valid_element = {"height": 3000, "width": 800}- issues = validator.validate_element(- valid_element, "elem_1", [min_height_rule, max_width_rule]- )-- assert len(issues) == 0-- # Validate invalid element- invalid_element = {"height": 2000, "width": 1200}- issues = validator.validate_element(- invalid_element, "elem_2", [min_height_rule, max_width_rule]- )-- assert len(issues) == 2- assert issues[0].rule_id == "min_height"- assert issues[0].severity == RuleSeverity.CRITICAL- assert issues[1].rule_id == "max_width"- assert issues[1].severity == RuleSeverity.HIGH---def test_validator_adds_to_report():- """Test that validator adds issues to current report."""- engine = RuleEngine()- validator = Validator(engine)- report = validator.create_report("Test Project")-- rule = Rule(- id="test_rule",- name="Test Rule",- description="Test",- category="test",- severity=RuleSeverity.MEDIUM,- check_function=lambda elem: elem > 10,- )-- validator.validate_element(5, "elem_1", [rule])-- assert len(report.issues) == 1- assert report.issues[0].rule_id == "test_rule"---def test_complete_validation_workflow():- """Test complete validation workflow with report generation."""- # Setup- engine = RuleEngine()- validator = Validator(engine)-- # Create report- report = validator.create_report("Office Building Project")- report.total_elements_checked = 5- report.rules_executed = 3-- # Define rules for wall validation- min_height_rule = Rule(- id="wall_min_height",- name="Minimum Wall Height",- description="Wall height must be at least 2400mm",- category="walls",- severity=RuleSeverity.CRITICAL,- check_function=lambda wall: wall.get("height", 0) >= 2400,- )-- max_length_rule = Rule(- id="wall_max_length",- name="Maximum Wall Length",- description="Wall length should not exceed 12000mm",- category="walls",- severity=RuleSeverity.HIGH,- check_function=lambda wall: wall.get("length", 0) <= 12000,- )-- naming_rule = Rule(- id="wall_naming",- name="Wall Naming Convention",- description="Wall name should start with 'W-'",- category="naming",- severity=RuleSeverity.MEDIUM,- check_function=lambda wall: wall.get("name", "").startswith("W-"),- )-- rules = [min_height_rule, max_length_rule, naming_rule]-- # Validate elements- walls = [- {"id": "wall_1", "height": 3000, "length": 6000, "name": "W-Exterior-001"}, # Valid- {"id": "wall_2", "height": 2000, "length": 5000, "name": "W-Interior-002"}, # Too short- {"id": "wall_3", "height": 2800, "length": 15000, "name": "Wall-003"}, # Too long, bad name- {"id": "wall_4", "height": 2500, "length": 8000, "name": "Interior"}, # Bad name- ]-- for wall in walls:- validator.validate_element(wall, wall["id"], rules)-- # Verify report- assert report.get_total_issues() == 4 # 1 height + 1 length + 2 naming issues- assert report.get_critical_count() == 1 # wall_2 height- assert report.get_high_count() == 1 # wall_3 length-- wall_issues = report.get_issues_by_category("walls")- naming_issues = report.get_issues_by_category("naming")-- assert len(wall_issues) == 2- assert len(naming_issues) == 2-- # Convert to dict- report_dict = report.to_dict()- assert report_dict["project_name"] == "Office Building Project"- assert report_dict["total_issues"] == 4- assert report_dict["critical_issues"] == 1- assert report_dict["high_issues"] == 1