diff --git a/.jules/bolt.md b/.jules/bolt.md index 91810df..a337772 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -13,6 +13,12 @@ ## 2026-06-14 - Deferring Pathlib Operations in Hot Paths **Learning:** In highly repetitive loops like file scanners (e.g., iterating through thousands of safe files), preemptively calculating `Path.relative_to()` and sanitizing strings adds significant cumulative overhead. Pathlib operations internally parse paths, check parts, and construct new objects, which is extremely expensive when executed on a per-file basis unconditionally. **Action:** Always defer expensive path computations (like converting paths to relative or string sanitization) until *after* the fast-path condition (like a regex match) triggers. This drastically cuts down on unnecessary string operations for clean files. +## 2024-05-18 - Set literal vs Tuple membership check + +**Learning:** In Python, using set literals for constant membership checks (e.g., `in {'CRITICAL', 'HIGH'}`) inside loops or comprehensions is highly efficient because CPython optimizes them into `frozenset` constants at compile time, eliminating runtime instantiation overhead. Using `tuple` for these checks performs an `O(n)` linear search, while a `frozenset` performs an `O(1)` hash lookup. + +**Action:** Prefer set literals `in {"A", "B"}` over tuples `in ("A", "B")` when performing membership checks against constant items, especially in hot paths or tight loops. + ## 2024-06-16 - Parallelize Subprocess CLI Calls **Learning:** Sequential, synchronous execution of `subprocess.run` (like calling the GitHub CLI) across multiple items (like PRs) is a significant I/O bottleneck. **Action:** Use `concurrent.futures.ThreadPoolExecutor` with `functools.partial` and `executor.map` to safely parallelize I/O-bound subprocess executions, significantly reducing overall script runtime. diff --git a/scanner/cli/vibesec.py b/scanner/cli/vibesec.py index ee34f4a..b10592f 100644 --- a/scanner/cli/vibesec.py +++ b/scanner/cli/vibesec.py @@ -419,7 +419,7 @@ def cmd_scan(args): findings.extend(file_findings) _print_scan_results(findings, files_scanned) - return 1 if any(f["severity"] in ("CRITICAL", "HIGH") for f in findings) else 0 + return 1 if any(f["severity"] in {"CRITICAL", "HIGH"} for f in findings) else 0 def cmd_hook(args):