Skip to content

Conversation

@emesal
Copy link
Owner

@emesal emesal commented Jan 19, 2026

No description provided.

emesal and others added 6 commits January 19, 2026 08:34
* implement MCP connectors as self-contained executables
  - no change to chibi itself(!)
* two example MCP connectors are included:
  - github-mcp -- more extensive python example with guardrails
  - fetch-mcp -- simple bash script mcp example (demonstrates the
    concept)
* tools read parameters from env var instead of stdin
  - current implementation does both, but stdin option will be removed
* the verbosity flag is passed on to tools
* tools are responsible for their own guardrails -- see github-mcp for
  an example
* update web_search tool to use uv
* update all tools to read JSON input from env var
Remove stdin fallback for reading arguments.
@emesal emesal merged commit e500cd1 into main Jan 19, 2026
@emesal emesal deleted the tools-refactor branch January 19, 2026 10:33
emesal added a commit that referenced this pull request Jan 25, 2026
1. New Module: src/safe_io.rs

Created a reusable module providing:
- atomic_write_json() - Write JSON atomically (temp file + fsync +
  rename)
- atomic_write() - Write bytes atomically
- FileLock - RAII file locking wrapper using fs2

This establishes the foundation for Issue #15 (unified safe file
operations).

2. Issue #4: Config Validation (partition.rs:132-172)

Added minimum value guards to StorageConfig methods:
- max_entries() → .max(1) - prevents infinite loops
- max_tokens() → .max(1) - prevents infinite loops
- bytes_per_token() → .max(1) - prevents divide-by-zero
- max_age_seconds() → .max(60) - minimum 1 minute prevents excessive
  rotation

3. Issue #3: Atomic Manifest Writes (partition.rs:439-445)

Replaced direct file write in save_manifest() with
safe_io::atomic_write_json(). This prevents
manifest corruption from crashes during write operations.

4. Issue #2: File Locking (partition.rs:362-368, 489-491, 577-578)

Added file locking to partition write operations:
- Added lock_path() helper returning .transcript.lock
- append_entry() now acquires exclusive lock before writing
- rotate() now acquires exclusive lock before rotating

5. Issue #1: Performance Caching (partition.rs, state/mod.rs)

Made ActiveState public with Clone, added caching support:
- PartitionManager::load_with_cached_state() - load with optional cached
  state
- PartitionManager::active_state() - getter for caching
- AppState.active_state_cache: RefCell<HashMap<String, ActiveState>> -
  per-context cache
- Updated append_to_transcript() to use/update cache
- Cache invalidation in clear_context(), clear_context_by_name(),
  finalize_compaction(), and destroy_context()
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.

2 participants