Skip to content

fix: use compaction-specific startup timeout (600s default)#115

Open
danielcherubini wants to merge 1 commit into
mainfrom
fix/compaction-startup-timeout
Open

fix: use compaction-specific startup timeout (600s default)#115
danielcherubini wants to merge 1 commit into
mainfrom
fix/compaction-startup-timeout

Conversation

@danielcherubini

@danielcherubini danielcherubini commented Jun 9, 2026

Copy link
Copy Markdown
Owner

Summary

Fix compaction server startup timeout — first-run uvx dependency install (torch, transformers) can take 5-10 min, which exceeds the proxy's 120s startup timeout.

Changes

  • Add startup_timeout_secs field to CompactionConfig (default: 600s)
  • Update lifecycle to use compaction-specific timeout instead of proxy's
  • Add field to web UI config editor + mirror types

Test plan

  • cargo clippy --workspace -- -D warnings — clean
  • Config tests pass (16/16)
  • Manual test: enable compaction, wait for server to start

Summary by CodeRabbit

  • New Features
    • Added configurable startup timeout for compaction servers in the configuration UI (default: 600 seconds).

@coderabbitai

coderabbitai Bot commented Jun 9, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR adds a new startup_timeout_secs configuration field to CompactionConfig across the codebase, enabling separate timeout control for compaction server startup independent from the proxy timeout. The field defaults to 600 seconds and is wired through configuration serialization, compaction lifecycle startup logic, and web UI controls.

Changes

Compaction Startup Timeout Configuration

Layer / File(s) Summary
Core config definition and defaults
crates/tama-core/src/config/types.rs
CompactionConfig struct gains startup_timeout_secs: u64 field with #[serde(default = "default_compaction_startup_timeout_secs")] (600 second default). CompactionConfig::default() implementation and TOML round-trip test data and assertions updated.
Compaction startup timeout integration
crates/tama-core/src/proxy/lifecycle/mod.rs
Compaction server spawn in spawn_compaction_server and wait-ready helper wait_for_compaction_ready use compaction.startup_timeout_secs instead of proxy.startup_timeout_secs for health-check timeout computation.
Web types and config editor UI
crates/tama-web/src/types/config.rs, crates/tama-web/src/pages/config_editor.rs
WASM mirror CompactionConfig adds startup_timeout_secs field with default function and bidirectional conversion logic between core and mirror types. Web config editor exposes "Startup Timeout (s)" numeric input bound to config.compaction.startup_timeout_secs with u64 parsing.

Possibly Related PRs

  • danielcherubini/tama#113: Modifies web config editor compaction configuration model (CompactionConfig in tama-web), with this PR extending that same UI/config structure to expose the new startup timeout setting.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 25.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: introducing a compaction-specific startup timeout with a 600-second default, addressing the root cause identified in the PR objectives.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/compaction-startup-timeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (4)
crates/tama-core/src/config/types.rs (2)

849-858: ⚡ Quick win

Strengthen default coverage for the new compaction startup timeout.

Line 857 verifies timeout_ms but the defaults test does not assert startup_timeout_secs, so regressions in the new default path can slip through.

Suggested test additions
 #[test]
 fn test_compaction_config_defaults() {
     let config = CompactionConfig::default();
     assert!(!config.enabled);
     assert_eq!(config.server_path, None);
     assert_eq!(config.device, "cpu");
     assert_eq!(config.port, None);
     assert_eq!(config.timeout_ms, 30_000);
+    assert_eq!(config.startup_timeout_secs, 600);
 }
+
+#[test]
+fn test_compaction_config_startup_timeout_default_when_omitted() {
+    let config: CompactionConfig = toml::from_str(
+        r#"
+enabled = true
+"#,
+    )
+    .unwrap();
+    assert_eq!(config.startup_timeout_secs, 600);
+}
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tama-core/src/config/types.rs` around lines 849 - 858, The
test_compaction_config_defaults in CompactionConfig only asserts timeout_ms and
omits asserting the new startup_timeout_secs default; update that test to also
assert the expected default value for CompactionConfig::startup_timeout_secs
(e.g. assert_eq!(config.startup_timeout_secs, <expected_value>)) so regressions
to the startup timeout default are caught.

592-594: ⚡ Quick win

Rename the private helper to match the underscore-prefix convention.

default_compaction_startup_timeout_secs is private and currently violates the private-function naming rule.

Suggested rename
-#[serde(default = "default_compaction_startup_timeout_secs")]
+#[serde(default = "_default_compaction_startup_timeout_secs")]
 pub startup_timeout_secs: u64,

 ...
-startup_timeout_secs: default_compaction_startup_timeout_secs(),
+startup_timeout_secs: _default_compaction_startup_timeout_secs(),

-fn default_compaction_startup_timeout_secs() -> u64 {
+fn _default_compaction_startup_timeout_secs() -> u64 {
     600 // 10 min — first-run dep install (torch, transformers) is slow
 }

As per coding guidelines, "Prefix Rust private functions with _ (e.g., _hf_api())."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tama-core/src/config/types.rs` around lines 592 - 594, The private
helper function default_compaction_startup_timeout_secs should be renamed to
follow the private underscore-prefix rule; rename the function to
_default_compaction_startup_timeout_secs and update all references (e.g., any
#[serde(default = "default_compaction_startup_timeout_secs")] or direct calls)
to use the new name so compilation and attribute links remain correct.

Source: Coding guidelines

crates/tama-web/src/pages/config_editor.rs (1)

147-149: ⚡ Quick win

Rename this private helper to match the underscore-prefix naming convention.

As per coding guidelines, "Prefix Rust private functions with _ (e.g., _hf_api())."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tama-web/src/pages/config_editor.rs` around lines 147 - 149, Rename
the private helper function default_compaction_startup_timeout_secs() to follow
the underscore-prefix convention (e.g.,
_default_compaction_startup_timeout_secs) and update all call sites and
references to that function (tests, modules, or other functions in the crate) to
use the new name; ensure the function signature remains the same and run cargo
fmt/build to verify no remaining references break.

Source: Coding guidelines

crates/tama-web/src/types/config.rs (1)

312-314: ⚡ Quick win

Rename the private default helper to follow the underscore-prefix rule.

This helper is private and should use the configured _ prefix convention.

As per coding guidelines, "Prefix Rust private functions with _ (e.g., _hf_api())."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tama-web/src/types/config.rs` around lines 312 - 314, Rename the
private helper function default_compaction_startup_timeout_secs to follow the
underscore-prefix convention (e.g., _default_compaction_startup_timeout_secs)
and update all references to it (including any serde attributes or calls that
refer to "default_compaction_startup_timeout_secs") so they point to the new
function name; ensure the function signature and return value remain unchanged
and run cargo check/tests to validate no remaining references.

Source: Coding guidelines

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@crates/tama-core/src/proxy/lifecycle/mod.rs`:
- Around line 1299-1301: The assignment to `timeout` using
`std::time::Duration::from_secs(compaction.startup_timeout_secs)` is
misformatted; run the Rust formatter and commit the result: run `cargo fmt
--all` (or `rustfmt`) and reformat `crates/tama-core/src/proxy/lifecycle/mod.rs`
so the `let timeout =
std::time::Duration::from_secs(compaction.startup_timeout_secs);` hunk conforms
to rustfmt style, then stage and push the formatted changes.

---

Nitpick comments:
In `@crates/tama-core/src/config/types.rs`:
- Around line 849-858: The test_compaction_config_defaults in CompactionConfig
only asserts timeout_ms and omits asserting the new startup_timeout_secs
default; update that test to also assert the expected default value for
CompactionConfig::startup_timeout_secs (e.g.
assert_eq!(config.startup_timeout_secs, <expected_value>)) so regressions to the
startup timeout default are caught.
- Around line 592-594: The private helper function
default_compaction_startup_timeout_secs should be renamed to follow the private
underscore-prefix rule; rename the function to
_default_compaction_startup_timeout_secs and update all references (e.g., any
#[serde(default = "default_compaction_startup_timeout_secs")] or direct calls)
to use the new name so compilation and attribute links remain correct.

In `@crates/tama-web/src/pages/config_editor.rs`:
- Around line 147-149: Rename the private helper function
default_compaction_startup_timeout_secs() to follow the underscore-prefix
convention (e.g., _default_compaction_startup_timeout_secs) and update all call
sites and references to that function (tests, modules, or other functions in the
crate) to use the new name; ensure the function signature remains the same and
run cargo fmt/build to verify no remaining references break.

In `@crates/tama-web/src/types/config.rs`:
- Around line 312-314: Rename the private helper function
default_compaction_startup_timeout_secs to follow the underscore-prefix
convention (e.g., _default_compaction_startup_timeout_secs) and update all
references to it (including any serde attributes or calls that refer to
"default_compaction_startup_timeout_secs") so they point to the new function
name; ensure the function signature and return value remain unchanged and run
cargo check/tests to validate no remaining references.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 08df995e-2e20-45a3-8e83-9410b16b6926

📥 Commits

Reviewing files that changed from the base of the PR and between dd1ce36 and 9e4675f.

📒 Files selected for processing (4)
  • crates/tama-core/src/config/types.rs
  • crates/tama-core/src/proxy/lifecycle/mod.rs
  • crates/tama-web/src/pages/config_editor.rs
  • crates/tama-web/src/types/config.rs

Comment on lines +1299 to +1301
// Use compaction-specific timeout (first-run dep install is slow)
let timeout =
std::time::Duration::from_secs(self.config.read().await.proxy.startup_timeout_secs);
std::time::Duration::from_secs(compaction.startup_timeout_secs);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Run rustfmt on this hunk; CI is failing.

cargo fmt --all --check is currently failing for this file around this assignment, so this needs a formatting pass before merge.

As per coding guidelines, "Run cargo fmt --all for code formatting in Rust."

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@crates/tama-core/src/proxy/lifecycle/mod.rs` around lines 1299 - 1301, The
assignment to `timeout` using
`std::time::Duration::from_secs(compaction.startup_timeout_secs)` is
misformatted; run the Rust formatter and commit the result: run `cargo fmt
--all` (or `rustfmt`) and reformat `crates/tama-core/src/proxy/lifecycle/mod.rs`
so the `let timeout =
std::time::Duration::from_secs(compaction.startup_timeout_secs);` hunk conforms
to rustfmt style, then stage and push the formatted changes.

Sources: Coding guidelines, Pipeline failures

First-run uvx dependency install (torch, transformers) can take 5-10 min,
which exceeds the proxy's 120s startup timeout. Added startup_timeout_secs
to CompactionConfig with a 600s default, and updated lifecycle to use it.

Also added the field to the web UI config editor.
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