Skip to content

refactor: Centralize timeout constants#27

Closed
echobt wants to merge 1 commit intomainfrom
feat/centralize-timeout-constants
Closed

refactor: Centralize timeout constants#27
echobt wants to merge 1 commit intomainfrom
feat/centralize-timeout-constants

Conversation

@echobt
Copy link
Contributor

@echobt echobt commented Feb 4, 2026

Summary

This PR extracts hardcoded timeout values scattered across multiple modules into a centralized TimeoutConfig module in cortex-common. This improves maintainability and consistency across the codebase.

Changes

  • Create src/cortex-common/src/timeout.rs with documented timeout constants
  • Update cortex-exec/src/runner.rs to use centralized constants
  • Update cortex-engine/src/tools/handlers/batch.rs to use centralized constants
  • Export timeout module from cortex-common

Verification

cargo check -p cortex-common -p cortex-exec -p cortex-engine

@greptile-apps
Copy link

greptile-apps bot commented Feb 4, 2026

Greptile Overview

Greptile Summary

Extracted hardcoded timeout constants from multiple modules into a centralized timeout.rs module in cortex-common, improving maintainability and consistency.

Key Changes:

  • Created well-documented timeout.rs with 7 timeout constants and validation tests
  • Replaced DEFAULT_TIMEOUT_SECSDEFAULT_EXEC_TIMEOUT_SECS in cortex-exec/runner.rs
  • Removed duplicate DEFAULT_BATCH_TIMEOUT_SECS from cortex-engine/batch.rs
  • Added cortex-common dependency to cortex-exec package
  • All constants properly re-exported through module public APIs

The refactoring is clean, maintains backward compatibility through re-exports, and includes test coverage to validate timeout value relationships.

Confidence Score: 5/5

  • This PR is safe to merge with no issues found
  • Clean refactoring that improves code organization without changing behavior - all constants retain their original values, proper module structure with tests, and correct dependency management
  • No files require special attention

Important Files Changed

Filename Overview
src/cortex-common/src/timeout.rs New module with well-documented timeout constants and validation tests
src/cortex-exec/src/runner.rs Replaced local timeout constants with centralized imports from cortex-common
src/cortex-engine/src/tools/handlers/batch.rs Removed local constant and imported from cortex-common

Sequence Diagram

sequenceDiagram
    participant Common as cortex-common/timeout
    participant Runner as cortex-exec/runner
    participant Batch as cortex-engine/batch
    participant ModExport as cortex-engine/handlers/mod

    Note over Common: Defines centralized timeout constants
    Common->>Common: DEFAULT_EXEC_TIMEOUT_SECS = 600
    Common->>Common: DEFAULT_REQUEST_TIMEOUT_SECS = 120
    Common->>Common: DEFAULT_BATCH_TIMEOUT_SECS = 300

    Note over Runner: Uses exec & request timeouts
    Runner->>Common: Import DEFAULT_EXEC_TIMEOUT_SECS
    Runner->>Common: Import DEFAULT_REQUEST_TIMEOUT_SECS
    Runner->>Runner: Set ExecOptions defaults
    Runner->>Runner: Apply timeout in run()

    Note over Batch: Uses batch timeout
    Batch->>Common: Import DEFAULT_BATCH_TIMEOUT_SECS
    Batch->>Batch: Apply timeout for parallel tool execution

    Note over ModExport: Re-exports for public API
    ModExport->>Common: Re-export DEFAULT_BATCH_TIMEOUT_SECS
    ModExport->>ModExport: Expose to external consumers
Loading

Copy link

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

3 files reviewed, no comments

Edit Code Review Agent Settings | Greptile

echobt added a commit that referenced this pull request Feb 4, 2026
…it, and documentation

This PR consolidates the following refactoring changes:
- #27: Centralize timeout constants
- #43: Replace magic numbers with documented named constants
- #67: Use LazyLock for static regex initialization
- #68: Extract subagent timeout values as named constants

Key changes:
- Created centralized timeout module with documented constants
- Replaced scattered magic numbers with well-documented constants
- Improved static initialization using LazyLock for regexes
- Added comprehensive documentation for timeout hierarchy
@echobt
Copy link
Contributor Author

echobt commented Feb 4, 2026

Consolidated into #77 - refactor: consolidated code quality improvements - constants, lazy init, and documentation

@echobt echobt closed this Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant