-
Notifications
You must be signed in to change notification settings - Fork 2
chore: consolidated refactoring and documentation improvements #92
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
This PR consolidates all refactoring and documentation improvements from PRs #77 and #89. ## Refactoring (from PR #77) ### Timeout Constants - Created centralized cortex_common::timeout module with documented constants - Replaced scattered magic numbers with well-documented constants - Added comprehensive documentation for timeout hierarchy ### Code Quality - Used LazyLock for static regex initialization - Extracted subagent timeout values as named constants - Improved compile-time assertions ## Documentation (from PR #89) ### Timeout Hierarchy Documentation - Added detailed header documentation explaining timeout hierarchy - Documented each timeout constant with its purpose and use case - Established naming conventions for constants vs config fields - Added timeout hierarchy table for quick reference ### Timeout Reference Table | Use Case | Module | Constant | Value | Rationale | |-----------------------------|-----------------------------|-----------------------------|-------|-----------| | Health checks | cortex-common/http_client | HEALTH_CHECK_TIMEOUT | 5s | Quick validation | | Standard HTTP requests | cortex-common/http_client | DEFAULT_TIMEOUT | 30s | Normal API calls | | Connection pool idle | cortex-common/http_client | POOL_IDLE_TIMEOUT | 60s | DNS refresh | | LLM Request (non-streaming) | cortex-exec/runner | DEFAULT_REQUEST_TIMEOUT_SECS| 120s | Model inference | | LLM Streaming total | cortex-common/http_client | STREAMING_TIMEOUT | 300s | Long-running streams | ## Files Modified - src/cortex-common/src/timeout.rs (new) - src/cortex-common/src/http_client.rs - src/cortex-app-server/src/config.rs - src/cortex-exec/src/runner.rs - Multiple other files Closes #77, #89
Greptile OverviewGreptile SummaryConsolidated refactoring from PRs #77 and #89 that centralizes timeout constants and improves documentation across the codebase. Key Changes:
Issues Found:
Confidence Score: 3/5
|
| Filename | Overview |
|---|---|
| src/cortex-common/src/timeout.rs | New centralized timeout constants module with comprehensive documentation and tests |
| src/cortex-common/src/http_client.rs | Added detailed timeout hierarchy documentation and new health check client function |
| src/cortex-engine/src/tools/handlers/batch.rs | Changed timeout semantics from batch-level to tool-level, but left unused timeout_secs field causing confusion |
| src/cortex-common/src/config_substitution.rs | Refactored to use LazyLock for static regex initialization improving performance |
| src/cortex-mcp-client/src/transport.rs | Removed unused reconnection logic and test_connection method |
Sequence Diagram
sequenceDiagram
participant User
participant cortex-exec
participant cortex-common
participant cortex-engine
participant cortex-app-server
Note over cortex-common: New timeout module<br/>centralized constants
User->>cortex-exec: Execute CLI command
cortex-exec->>cortex-common: Import DEFAULT_EXEC_TIMEOUT_SECS (600s)
cortex-exec->>cortex-common: Import DEFAULT_REQUEST_TIMEOUT_SECS (120s)
cortex-exec->>cortex-engine: Execute tool batch
cortex-engine->>cortex-common: Import DEFAULT_BATCH_TIMEOUT_SECS (300s)
Note over cortex-engine: Uses tool_timeout_secs (60s)<br/>per individual tool
cortex-exec->>cortex-app-server: HTTP request to LLM
cortex-app-server->>cortex-common: Use http_client factory
alt Streaming Request
cortex-common->>cortex-common: STREAMING_TIMEOUT (300s)
else Standard Request
cortex-common->>cortex-common: DEFAULT_TIMEOUT (30s)
else Health Check
cortex-common->>cortex-common: HEALTH_CHECK_TIMEOUT (5s)
end
Note over cortex-common: All timeouts now documented<br/>in timeout hierarchy table
cortex-app-server-->>cortex-exec: Response
cortex-exec-->>User: Result
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
5 files reviewed, 1 comment
| /// Optional timeout in seconds for the entire batch (default: 300s). | ||
| #[serde(default)] | ||
| pub timeout_secs: Option<u64>, | ||
| /// Optional timeout in seconds for individual tools (default: 60s). | ||
| /// This prevents a single tool from consuming the entire batch timeout. | ||
| #[serde(default)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
timeout_secs parameter is not used in the implementation - only tool_timeout_secs is used (line 341). Either remove this field or implement batch-level timeout enforcement.
| /// Optional timeout in seconds for the entire batch (default: 300s). | |
| #[serde(default)] | |
| pub timeout_secs: Option<u64>, | |
| /// Optional timeout in seconds for individual tools (default: 60s). | |
| /// This prevents a single tool from consuming the entire batch timeout. | |
| #[serde(default)] | |
| /// Optional timeout in seconds for individual tools (default: 60s). | |
| /// This prevents a single tool from consuming the entire batch timeout. | |
| #[serde(default)] | |
| pub tool_timeout_secs: Option<u64>, |
Prompt To Fix With AI
This is a comment left during a code review.
Path: src/cortex-engine/src/tools/handlers/batch.rs
Line: 46:51
Comment:
`timeout_secs` parameter is not used in the implementation - only `tool_timeout_secs` is used (line 341). Either remove this field or implement batch-level timeout enforcement.
```suggestion
/// Optional timeout in seconds for individual tools (default: 60s).
/// This prevents a single tool from consuming the entire batch timeout.
#[serde(default)]
pub tool_timeout_secs: Option<u64>,
```
How can I resolve this? If you propose a fix, please make it concise.Address Greptile review feedback: The timeout_secs parameter was documented and accepted but never used. Now it properly wraps the entire parallel execution with a batch-level timeout, separate from the per-tool timeout_secs. - Add batch-level timeout wrapper around execute_parallel - Return descriptive error message when batch times out - Add test for batch timeout behavior
Summary
This PR consolidates all refactoring and documentation improvements from PRs #77 and #89.
Refactoring (from PR #77)
Timeout Constants
Code Quality
Documentation (from PR #89)
Timeout Hierarchy Documentation
Timeout Reference Table
Files Modified
Closes #77, #89