coding-client 1.21.2__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (109) hide show
  1. coding_client/__init__.py +1 -0
  2. coding_client/api/__init__.py +19 -0
  3. coding_client/api/exception_handlers.py +158 -0
  4. coding_client/api/logging_setup.py +44 -0
  5. coding_client/api/metrics.py +40 -0
  6. coding_client/api/openapi_config.py +124 -0
  7. coding_client/api/request_logging.py +60 -0
  8. coding_client/api/validation.py +150 -0
  9. coding_client/auth/__init__.py +78 -0
  10. coding_client/auth/_default_tenant.py +132 -0
  11. coding_client/auth/_header_trust.py +98 -0
  12. coding_client/auth/_onbehalf.py +315 -0
  13. coding_client/auth/_trusted_networks.py +94 -0
  14. coding_client/auth/dependencies.py +61 -0
  15. coding_client/auth/middleware.py +445 -0
  16. coding_client/auth/models.py +83 -0
  17. coding_client/auth/outbound.py +137 -0
  18. coding_client/auth/rbac.py +21 -0
  19. coding_client/auth/rbac_coding.py +5 -0
  20. coding_client/auth/tenant.py +650 -0
  21. coding_client/auth/websocket.py +148 -0
  22. coding_client/clients/__init__.py +24 -0
  23. coding_client/clients/base.py +131 -0
  24. coding_client/clients/coding_ai.py +33 -0
  25. coding_client/clients/coding_analysis.py +36 -0
  26. coding_client/clients/coding_containers.py +45 -0
  27. coding_client/clients/coding_github.py +127 -0
  28. coding_client/clients/coding_realtime.py +127 -0
  29. coding_client/clients/coding_security.py +51 -0
  30. coding_client/clients/coding_testing.py +31 -0
  31. coding_client/clients/coding_workspaces.py +265 -0
  32. coding_client/config/__init__.py +12 -0
  33. coding_client/config/base_settings.py +61 -0
  34. coding_client/config/yaml_config_loader.py +172 -0
  35. coding_client/db/__init__.py +42 -0
  36. coding_client/db/db_types.py +122 -0
  37. coding_client/db/exceptions.py +59 -0
  38. coding_client/db/postgres_connection.py +572 -0
  39. coding_client/db/tenant_query_helper.py +417 -0
  40. coding_client/db_init.py +49 -0
  41. coding_client/exceptions/__init__.py +67 -0
  42. coding_client/exceptions/api_exceptions.py +395 -0
  43. coding_client/exceptions/pydantic_ai_exceptions.py +533 -0
  44. coding_client/interfaces/__init__.py +22 -0
  45. coding_client/interfaces/cache_interface.py +179 -0
  46. coding_client/interfaces/container_interface.py +49 -0
  47. coding_client/interfaces/docker_interface.py +283 -0
  48. coding_client/interfaces/graph_interface.py +28 -0
  49. coding_client/interfaces/security_interface.py +72 -0
  50. coding_client/interfaces/webhook_interface.py +67 -0
  51. coding_client/llm/__init__.py +54 -0
  52. coding_client/llm/base_agent.py +195 -0
  53. coding_client/llm/context.py +121 -0
  54. coding_client/llm/responses.py +102 -0
  55. coding_client/llm/routing.py +82 -0
  56. coding_client/llm/settings.py +102 -0
  57. coding_client/models/__init__.py +62 -0
  58. coding_client/models/agent.py +38 -0
  59. coding_client/models/ai_test_failure.py +745 -0
  60. coding_client/models/analysis.py +330 -0
  61. coding_client/models/architecture.py +685 -0
  62. coding_client/models/bug.py +128 -0
  63. coding_client/models/code_graph.py +317 -0
  64. coding_client/models/container.py +241 -0
  65. coding_client/models/core.py +878 -0
  66. coding_client/models/docker_container.py +104 -0
  67. coding_client/models/github.py +293 -0
  68. coding_client/models/logging.py +29 -0
  69. coding_client/models/package_manager.py +257 -0
  70. coding_client/models/pr_validation.py +440 -0
  71. coding_client/models/pydantic_ai.py +395 -0
  72. coding_client/models/repo_scanner.py +249 -0
  73. coding_client/models/responses.py +431 -0
  74. coding_client/models/security.py +185 -0
  75. coding_client/models/static_analysis.py +508 -0
  76. coding_client/models/system.py +48 -0
  77. coding_client/models/test_executor.py +204 -0
  78. coding_client/models/testing.py +673 -0
  79. coding_client/models/testing_config.py +200 -0
  80. coding_client/models/validation.py +127 -0
  81. coding_client/models_init.py +272 -0
  82. coding_client/telemetry.py +195 -0
  83. coding_client/testing.py +180 -0
  84. coding_client/types/__init__.py +130 -0
  85. coding_client/types/constraint_types.py +276 -0
  86. coding_client/types/core_types.py +112 -0
  87. coding_client/types/state_machine.py +443 -0
  88. coding_client/utils/__init__.py +86 -0
  89. coding_client/utils/archive_utils.py +387 -0
  90. coding_client/utils/ast_debug.py +45 -0
  91. coding_client/utils/async_timeout.py +364 -0
  92. coding_client/utils/constants.py +518 -0
  93. coding_client/utils/content_processing.py +326 -0
  94. coding_client/utils/database.py +916 -0
  95. coding_client/utils/encoding_helper.py +222 -0
  96. coding_client/utils/enum_helpers.py +166 -0
  97. coding_client/utils/file_operations.py +177 -0
  98. coding_client/utils/filesystem_ops.py +528 -0
  99. coding_client/utils/http_client.py +562 -0
  100. coding_client/utils/path_utils.py +471 -0
  101. coding_client/utils/profiling.py +421 -0
  102. coding_client/utils/response_builder.py +240 -0
  103. coding_client/utils/retry_helper.py +712 -0
  104. coding_client/utils/security_validation.py +423 -0
  105. coding_client-1.21.2.dist-info/METADATA +234 -0
  106. coding_client-1.21.2.dist-info/RECORD +109 -0
  107. coding_client-1.21.2.dist-info/WHEEL +5 -0
  108. coding_client-1.21.2.dist-info/licenses/LICENSE +201 -0
  109. coding_client-1.21.2.dist-info/top_level.txt +1 -0
@@ -0,0 +1,204 @@
1
+ """Test executor validation models for multi-language code validation.
2
+
3
+ This module provides Pydantic models for the test executor validation endpoints,
4
+ ensuring consistent request/response structures across all supported programming
5
+ languages. The models are designed with Pydantic v2/v3 compatibility and support
6
+ validation for Python, JavaScript, TypeScript, Java, Rust, C#, and Go.
7
+
8
+ The validation system uses these models to:
9
+ - Accept code validation requests with language-specific options
10
+ - Provide consistent validation responses across different languages
11
+ - Handle errors gracefully with detailed error information
12
+ - Support language-specific features like class names, project types, etc.
13
+
14
+ Classes:
15
+ CodeValidationRequest: Base request model for code validation with language options
16
+ CodeValidationResponse: Standardized response with validation results
17
+ ValidationErrorResponse: Error response model for validation failures
18
+
19
+ Functions:
20
+ validate_code_size: Check if code size is within acceptable limits
21
+ sanitize_error_output: Clean and truncate error messages for safe output
22
+
23
+ Example:
24
+ ```python
25
+ from test_executor_models import CodeValidationRequest, CodeValidationResponse
26
+
27
+ # Create a validation request
28
+ request = CodeValidationRequest(
29
+ code='console.log("Hello, World!");',
30
+ filename="test.js",
31
+ language_version="ES2022",
32
+ strict_mode=True
33
+ )
34
+
35
+ # Process validation response
36
+ response = CodeValidationResponse(
37
+ validation_id="val-123",
38
+ valid=True,
39
+ errors=[],
40
+ warnings=["Missing semicolon"],
41
+ output="Code is syntactically valid",
42
+ metadata={"ast_nodes": 5}
43
+ )
44
+ ```
45
+ """
46
+
47
+ from typing import Any
48
+
49
+ from pydantic import BaseModel, ConfigDict, Field
50
+
51
+
52
+ class CodeValidationRequest(BaseModel):
53
+ """Request model for code validation endpoints."""
54
+
55
+ model_config = ConfigDict(
56
+ str_strip_whitespace=False, # Preserve code formatting
57
+ validate_default=True,
58
+ use_enum_values=True,
59
+ )
60
+
61
+ code: str = Field(
62
+ ...,
63
+ description="Source code to validate",
64
+ min_length=0, # Allow empty code but require the field
65
+ max_length=1_000_000, # 1MB limit
66
+ )
67
+
68
+ filename: str | None = Field(
69
+ default=None,
70
+ description="Optional filename for context-aware validation",
71
+ )
72
+
73
+ # Language-specific options
74
+ class_name: str | None = Field(
75
+ default=None,
76
+ alias="className",
77
+ description="Class name for Java/C# validation",
78
+ )
79
+
80
+ project_type: str | None = Field(
81
+ default=None,
82
+ alias="projectType",
83
+ description="Project type for C# validation",
84
+ )
85
+
86
+ language_version: str | None = Field(
87
+ default=None,
88
+ alias="languageVersion",
89
+ description="Language version for validation",
90
+ )
91
+
92
+ strict_mode: bool | None = Field(
93
+ default=False,
94
+ alias="strictMode",
95
+ description="Enable strict validation rules",
96
+ )
97
+
98
+
99
+ class CodeValidationResponse(BaseModel):
100
+ """Response model for code validation endpoints."""
101
+
102
+ model_config = ConfigDict(populate_by_name=True, use_enum_values=True)
103
+
104
+ validation_id: str = Field(
105
+ ..., alias="validationId", description="Unique validation request ID"
106
+ )
107
+
108
+ valid: bool = Field(..., description="Whether the code is syntactically valid")
109
+
110
+ errors: list[str] = Field(default_factory=list, description="List of validation errors")
111
+
112
+ warnings: list[str] | None = Field(default=None, description="Optional list of warnings")
113
+
114
+ output: str = Field(default="", description="Additional validation output")
115
+
116
+ metadata: dict[str, Any] | None = Field(default=None, description="Language-specific metadata")
117
+
118
+
119
+ class TestExecutorValidationError(BaseModel):
120
+ """Error response model for validation failures."""
121
+
122
+ model_config = ConfigDict(populate_by_name=True)
123
+
124
+ validation_id: str | None = Field(
125
+ default=None,
126
+ alias="validationId",
127
+ description="Validation ID if available",
128
+ )
129
+
130
+ error: str = Field(..., description="Error message")
131
+
132
+ details: str | None = Field(default=None, description="Detailed error information")
133
+
134
+ code: int | None = Field(default=None, description="Error code")
135
+
136
+
137
+ # Validation utility functions
138
+ def validate_code_size(code: str, max_size: int = 1_000_000) -> bool:
139
+ """Validate that code size is within acceptable limits.
140
+
141
+ Checks if the UTF-8 encoded size of the code string is within the specified
142
+ maximum size limit. This prevents processing of excessively large code files
143
+ that could cause memory or performance issues.
144
+
145
+ Args:
146
+ code (str): Source code string to validate.
147
+ max_size (int, optional): Maximum allowed size in bytes. Defaults to 1MB (1_000_000).
148
+
149
+ Returns:
150
+ bool: True if code size is within limits, False otherwise.
151
+
152
+ Example:
153
+ ```python
154
+ code = "def hello():\\n print('Hello, World!')"
155
+ if validate_code_size(code):
156
+ # Process the code
157
+ pass
158
+ else:
159
+ # Reject as too large
160
+ raise ValueError("Code exceeds maximum size limit")
161
+ ```
162
+ """
163
+ return len(code.encode("utf-8")) <= max_size
164
+
165
+
166
+ def sanitize_error_output(error: str, max_length: int = 1000) -> str:
167
+ """Sanitize and truncate error messages for safe output.
168
+
169
+ Removes sensitive file paths and truncates long error messages to prevent
170
+ information leakage and ensure consistent response sizes. This function
171
+ strips out internal container paths that might reveal system structure.
172
+
173
+ Args:
174
+ error (str): Raw error message to sanitize.
175
+ max_length (int, optional): Maximum length for output. Defaults to 1000.
176
+
177
+ Returns:
178
+ str: Sanitized error message with sensitive paths removed and length limited.
179
+
180
+ Example:
181
+ ```python
182
+ raw_error = "Error in /app/test_workspace/secret_file.py: syntax error"
183
+ clean_error = sanitize_error_output(raw_error)
184
+ # Returns: "Error in secret_file.py: syntax error"
185
+ ```
186
+
187
+ Note:
188
+ The function specifically removes:
189
+ - /app/test_workspace/ paths (internal container structure)
190
+ - /tmp/ paths (temporary file locations)
191
+ - Truncates with "..." if message exceeds max_length
192
+ """
193
+ if not error:
194
+ return ""
195
+
196
+ # Remove sensitive paths
197
+ error = error.replace("/app/test_workspace/", "")
198
+ error = error.replace("/tmp/", "") # nosec B108 — sanitizes path text out of an error string; not temp-file creation
199
+
200
+ # Truncate if too long
201
+ if len(error) > max_length:
202
+ error = error[: max_length - 3] + "..."
203
+
204
+ return error