Skip to content

feat(core): migrate tool overflow storage from disk to SQLite#1782

Merged
bug-ops merged 2 commits intomainfrom
tool-overflow-sqlite
Mar 14, 2026
Merged

feat(core): migrate tool overflow storage from disk to SQLite#1782
bug-ops merged 2 commits intomainfrom
tool-overflow-sqlite

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 14, 2026

Closes #1774

Summary

Replaces filesystem-based overflow storage (UUID files in ~/.zeph/overflow/) with a tool_overflow SQLite table. This eliminates absolute path leakage into LLM context (SEC-JIT-03) and makes the database fully self-contained.

  • New tool_overflow SQLite table (migration 031) with ON DELETE CASCADE FK to conversations
  • maybe_summarize_tool_output writes overflow BLOBs to SQLite instead of disk
  • Overflow references use opaque overflow:<uuid> format — no paths in LLM context
  • New read_overflow native tool allows LLM to retrieve full content by UUID; exempted from re-overflow to prevent infinite retrieval loops
  • Conversation-scoped load_overflow (UUID + conversation_id) prevents cross-conversation access
  • max_overflow_bytes cap (default 10 MiB, 0 = unlimited) prevents unbounded BLOB growth
  • Age-based cleanup via cleanup_overflow on startup in runner, daemon, and acp entry points
  • Old crates/zeph-tools/src/overflow.rs and OverflowConfig.dir fully removed

Test plan

  • save_overflow / load_overflow roundtrip
  • extract_overflow_ref parsing with overflow:<uuid> format
  • read_overflow native tool behavior (found, not found, conversation scoping)
  • Age-based eviction / cleanup_overflow correctness
  • S1: read_overflow output exempt from re-overflow pipeline
  • S3: graceful skip when conversation_id is None
  • max_overflow_bytes cap enforced before insert
  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean
  • cargo nextest run --config-file .github/nextest.toml --workspace --features full --lib --bins — 5585 passed

bug-ops added 2 commits March 14, 2026 21:14
Replaces filesystem-based overflow (UUID files in ~/.zeph/overflow/)
with a `tool_overflow` SQLite table, eliminating absolute path leakage
into LLM context (SEC-JIT-03) and making the database self-contained.

Changes:
- Add migration 030_tool_overflow.sql with ON DELETE CASCADE FK to conversations
- Add SqliteStore methods: save_overflow, load_overflow (conversation-scoped),
  cleanup_overflow, overflow_size
- Replace OverflowConfig.dir with retention_days (default 30) and
  max_overflow_bytes cap (default 10 MiB, 0 = unlimited)
- Update reference format from absolute path to opaque overflow:<uuid>
- Add read_overflow native tool for LLM retrieval; exempt from re-overflow
- Spawn age-based cleanup task in runner, daemon, and acp entry points
- Remove crates/zeph-tools/src/overflow.rs (filesystem backend deleted)
- Update debug_dump rendering and docs

Fixes #1774
@bug-ops bug-ops enabled auto-merge (squash) March 14, 2026 20:18
@github-actions github-actions bot added enhancement New feature or request documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes core zeph-core crate dependencies Dependency updates config Configuration file changes size/XL Extra large PR (500+ lines) and removed enhancement New feature or request labels Mar 14, 2026
@bug-ops bug-ops merged commit 8c24e3f into main Mar 14, 2026
19 checks passed
@bug-ops bug-ops deleted the tool-overflow-sqlite branch March 14, 2026 20:26
bug-ops added a commit that referenced this pull request Mar 15, 2026
… migration

OVERFLOW_NOTICE_PREFIX was pointing to the old file-path format
('[full output saved to') while the actual overflow notice format
changed in PR #1782 to '[full output stored as overflow:{uuid}'.
As a result, extract_overflow_ref() always returned None and the JIT
reference was never injected into pruned tool outputs.

- Update OVERFLOW_NOTICE_PREFIX to match current SQLite overflow format
- Update extract_overflow_ref() doc comment (UUID instead of path)
- Update all five JIT reference sites to emit
  '[tool output pruned; use read_overflow {uuid} to retrieve]'
- Update tests in summarization.rs and context/mod.rs to use new format

Closes #1818
bug-ops added a commit that referenced this pull request Mar 15, 2026
… migration (#1826)

OVERFLOW_NOTICE_PREFIX was pointing to the old file-path format
('[full output saved to') while the actual overflow notice format
changed in PR #1782 to '[full output stored as overflow:{uuid}'.
As a result, extract_overflow_ref() always returned None and the JIT
reference was never injected into pruned tool outputs.

- Update OVERFLOW_NOTICE_PREFIX to match current SQLite overflow format
- Update extract_overflow_ref() doc comment (UUID instead of path)
- Update all five JIT reference sites to emit
  '[tool output pruned; use read_overflow {uuid} to retrieve]'
- Update tests in summarization.rs and context/mod.rs to use new format

Closes #1818
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

config Configuration file changes core zeph-core crate dependencies Dependency updates documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(core): migrate tool overflow storage from disk to SQLite

1 participant