Skip to content

fix(tui): set spillover root in dedup tests for Nix sandbox builds#1844

Open
barstoolbluz wants to merge 1 commit into
Hmbown:mainfrom
barstoolbluz:fix/nix-build-spillover-tests
Open

fix(tui): set spillover root in dedup tests for Nix sandbox builds#1844
barstoolbluz wants to merge 1 commit into
Hmbown:mainfrom
barstoolbluz:fix/nix-build-spillover-tests

Conversation

@barstoolbluz
Copy link
Copy Markdown

Summary

  • Two tool-result deduplication tests (request_builder_deduplicates_large_identical_tool_results_with_retrieval_hint and cache_inspect_reports_tool_result_budget_metadata) fail under nix build because the sandbox has no writable $HOME
  • The spillover write silently fails, dedup is skipped, and assertions break
  • Adds a temp-dir-backed SpilloverRootGuard (matching the existing pattern in tool_result_retrieval.rs) so the tests pass in both sandboxed and normal environments

Test plan

  • cargo test -p deepseek-tui --bin deepseek-tui -- stream_decoder_tests::request_builder_deduplicates_large stream_decoder_tests::cache_inspect_reports_tool_result passes
  • nix build .# succeeds (tests pass in sandbox)

Two tool-result deduplication tests fail under `nix build` because
the sandbox has no writable $HOME. The spillover write silently fails,
dedup is skipped, and assertions break. Add a temp-dir-backed
SpilloverRootGuard (matching the pattern in tool_result_retrieval.rs)
so the tests pass in sandboxed and normal environments.
Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a SpilloverRootGuard RAII struct and updates unit tests in crates/tui/src/client/chat.rs to use it for managing temporary spillover directories safely with a mutex. The review feedback recommends adding the #[must_use] attribute to the guard to prevent accidental immediate drops and suggests using the SPILLOVER_DIR_NAME constant instead of hardcoded strings to improve maintainability.

use crate::models::{ContentBlockStart, Delta, StreamEvent};
use std::path::PathBuf;

struct SpilloverRootGuard {
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.

medium

RAII guards like SpilloverRootGuard should be marked with #[must_use] to prevent them from being accidentally dropped immediately (e.g., if the caller uses let _ = ... or forgets the binding), which would restore the prior state before the test logic executes.

Suggested change
struct SpilloverRootGuard {
#[must_use]
struct SpilloverRootGuard {

.unwrap_or_else(|err| err.into_inner());
let tmp = tempfile::tempdir().unwrap();
let _guard = SpilloverRootGuard::new(
tmp.path().join(".deepseek").join("tool_outputs"),
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.

medium

Use the SPILLOVER_DIR_NAME constant from crate::tools::truncate instead of hardcoding the string "tool_outputs". This ensures consistency if the directory name is changed in the future.

Suggested change
tmp.path().join(".deepseek").join("tool_outputs"),
tmp.path().join(".deepseek").join(crate::tools::truncate::SPILLOVER_DIR_NAME),

.unwrap_or_else(|err| err.into_inner());
let tmp = tempfile::tempdir().unwrap();
let _guard = SpilloverRootGuard::new(
tmp.path().join(".deepseek").join("tool_outputs"),
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.

medium

Use the SPILLOVER_DIR_NAME constant from crate::tools::truncate instead of hardcoding the string "tool_outputs". This ensures consistency if the directory name is changed in the future.

Suggested change
tmp.path().join(".deepseek").join("tool_outputs"),
tmp.path().join(".deepseek").join(crate::tools::truncate::SPILLOVER_DIR_NAME),

@Hmbown
Copy link
Copy Markdown
Owner

Hmbown commented May 27, 2026

Independent review:

The actual change is the right pattern — a temp-dir-backed SpilloverRootGuard matching tool_result_retrieval.rs. Robust outside Nix: it locks TEST_SPILLOVER_GUARD, swaps the spillover root, and restores on Drop. Works in any sandbox lacking $HOME.

Concerns:

  1. Branch is stale on "deepseek" naming — the actual reverts the CodeWhale rebrand in chat.rs error strings (\deepseek doctor`etc.) and removes thetoolsparameter fromPromptBuilder`. Rebase on current main; only the 34-line test-guard addition should remain.
  2. After rebase, verify it stacks correctly on top of the new requires_reasoning_content + provider_accepts_reasoning_content split that landed since the branch was cut — the diff shows it conflicts with that refactor.
  3. Test name with_tool_result_sha_spillover_root was deleted in favor of SpilloverRootGuard — confirm no other test still calls the old helper after rebase.

The fix itself is correct and the pattern is reusable for any future test that exercises truncate::write_sha_spillover. After rebase this should land cleanly.

v0.8.48 (PR #2256): 1 conflict in crates/tui/src/client/chat.rs — same file PR #2256 touches.

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.

3 participants