Skip to content

fix: Python docstring detection and snapshot JSON injection (#179)#258

Merged
justrach merged 1 commit intorelease/v0.2.57from
fix/179-bugs-batch
Apr 13, 2026
Merged

fix: Python docstring detection and snapshot JSON injection (#179)#258
justrach merged 1 commit intorelease/v0.2.57from
fix/179-bugs-batch

Conversation

@justrach
Copy link
Copy Markdown
Owner

Summary

From the 8 bugs in #179, 4 were already fixed in prior commits. This PR fixes the remaining 2 actionable ones:

  • Python docstring detection — replaced naive std.mem.count triple-quote check with position-aware std.mem.indexOf logic. Now correctly handles: inline docstrings ("""text"""), opening docstrings with text after ("""starts here), and multi-line docstrings containing def/class lines that shouldn't be indexed as symbols
  • Snapshot JSON injection — replaced raw {s} path interpolation in snapshot.zig with writeJsonEscaped(). Files with ", \, or control characters in paths no longer corrupt the snapshot cache

Already fixed (no changes needed):

  • C/C++ block comment exclusion — .c/.cpp already in the language check
  • u16 file count truncation — already using u32
  • ANSI escape strip — already parsing full CSI sequences
  • Telemetry data race — call_count already std.atomic.Value(u32) with fetchAdd

Not addressed (larger scope):

  • Global mutable active_pair_freq — needs architectural change
  • HTTP unbounded threads — needs thread pool, separate issue

Test plan

  • All existing tests pass
  • New test: inline docstring """text""" does not leak fake symbols
  • New test: multi-line docstring containing def does not produce phantom symbols

🤖 Generated with Claude Code

- Python docstring: replace naive triple-quote count with position-aware
  detection — properly handles inline docstrings ("""text"""), opening
  docstrings with text ("""starts here), and multi-line docstrings
  containing def/class lines
- Snapshot JSON: use writeJsonEscaped for path interpolation in snapshot
  writer — prevents cache corruption for files with ", \, or control
  characters in paths

Note: 4 of 8 bugs from #179 were already fixed in prior commits
(C/C++ block comments, u16 truncation, ANSI strip, telemetry race)

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@justrach justrach merged commit 3473138 into release/v0.2.57 Apr 13, 2026
1 check passed
@justrach justrach mentioned this pull request Apr 13, 2026
@github-actions
Copy link
Copy Markdown

Benchmark Regression Report

Threshold: 10.00%

Tool Base (ns) Head (ns) Delta Status
codedb_bundle 670801 674821 +0.60% OK
codedb_changes 109481 116178 +6.12% OK
codedb_deps 30771 30606 -0.54% OK
codedb_edit 22865 23729 +3.78% OK
codedb_find 142034 151614 +6.74% OK
codedb_hot 151125 151631 +0.33% OK
codedb_outline 476000 477298 +0.27% OK
codedb_read 151274 148726 -1.68% OK
codedb_search 290437 292983 +0.88% OK
codedb_snapshot 4472281 4498362 +0.58% OK
codedb_status 254734 262690 +3.12% OK
codedb_symbol 70201 65795 -6.28% OK
codedb_tree 91080 87544 -3.88% OK
codedb_word 92496 93039 +0.59% OK

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