Skip to content

fix: critical bugs in map cache, exec pipeline, and MCP install#5

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-8f19
Draft

fix: critical bugs in map cache, exec pipeline, and MCP install#5
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-investigation-8f19

Conversation

@cursor

@cursor cursor Bot commented Jun 14, 2026

Copy link
Copy Markdown

Summary

Weekly critical bug investigation found 4 high-severity correctness issues in recent code. All have concrete trigger scenarios and minimal fixes with tests.

Bugs fixed

1. Stale ctx map cache on dirty working trees (data correctness)

  • Impact: ctx map returned cached output after uncommitted file edits, serving stale/wrong repo maps to LLMs.
  • Root cause: git_commit_key() hashed only directory paths for dirty repos, ignoring working tree state.
  • Fix: Include git status --porcelain hash in dirty key: dirty-<HEAD>-<wt_hash>.

2. Panic in truncate_lines on UTF-8 boundaries (crash)

  • Impact: ctx exec git blame (and other filters with truncate_lines_at) could panic when a line exceeded the width limit at a multi-byte UTF-8 character.
  • Root cause: Byte-index slice &line[..width] without checking is_char_boundary.
  • Fix: Walk back to nearest char boundary before slicing.

3. MCP config overwrite on ctx install (data loss)

  • Impact: Running ctx install silently replaced a user-configured mcpServers.ctx entry.
  • Root cause: insert_mcp_server only skipped overwrite for entries marked _installer: ctx.
  • Fix: Never overwrite an existing entry with the same name.

4. Failed commands masked as success via on_empty (user-facing breakage)

  • Impact: When a filtered command failed (exit != 0) and output was empty after filtering, on_empty messages like "ok" were returned, hiding failures from agents.
  • Root cause: run_proxy_capture always applied stage 8 (on_empty) regardless of exit code.
  • Fix: Suppress on_empty when exit_code != 0.

Validation

  • Added/updated unit tests for all four fixes
  • cargo fmt --check passes locally
  • Full test suite will run in CI (302+ tests)
Open in Web View Automation 

- git_commit_key: include porcelain status for dirty repos (fixes stale ctx map cache)
- truncate_lines: respect UTF-8 char boundaries (prevents panic in git blame/aws logs)
- insert_mcp_server: skip overwrite when user-owned mcpServers.ctx exists
- run_proxy_capture: suppress on_empty fallback when exit code != 0

Co-authored-by: Jaime Basso <JaimeJunr@users.noreply.github.com>
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