diff --git a/.jules/bolt.md b/.jules/bolt.md index a86b7aafd..86d592a5c 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -43,3 +43,6 @@ ## 2026-07-09 - Avoid N+1 API blocking in SBOM aggregator **Learning:** The `collect_inventories` function in `scripts/ci/sbom_inventory_aggregator.py` was fetching SBOMs from the GitHub dependency graph synchronously for every repository in the organization. For large organizations (up to 500 repos), this N+1 network/CLI bottleneck significantly stalled the aggregation workflow. **Action:** Use `concurrent.futures.ThreadPoolExecutor` to fetch SBOMs concurrently when multiple repositories are provided, bounded by a `max_workers` limit (e.g., 10) to avoid overwhelming the CLI/API, while preserving the fast serial path for single-item inputs. +## 2026-07-28 - String Parsing Performance - Batch String Appending +**Learning:** For Python string processing or redaction loops, avoiding character-by-character list appends (`output.append(text[cursor])`) prevents massive O(N^2) memory and runtime overhead. +**Action:** Track a `last_append` index and use string slicing to batch-append non-matching blocks (`output.append(text[last_append:cursor])`). Note: On match failures, advance the cursor by 1 to prevent missing valid embedded tokens. diff --git a/scripts/ci/redact_sensitive_log.py b/scripts/ci/redact_sensitive_log.py index cb89fe67b..6b490d059 100644 --- a/scripts/ci/redact_sensitive_log.py +++ b/scripts/ci/redact_sensitive_log.py @@ -99,14 +99,20 @@ def _redact_assignments(text: str) -> str: """Redact sensitive key/value assignments without backtracking regexes.""" output: list[str] = [] cursor = 0 + last_append = 0 while cursor < len(text): match = _consume_sensitive_assignment(text, cursor) if match is None: - output.append(text[cursor]) cursor += 1 continue - replacement, cursor = match + replacement, next_cursor = match + # ⚡ Bolt: Use string slicing to append chunks instead of O(N^2) character-by-character appends + # Impact: Dramatically reduces string parsing time by avoiding unnecessary list appends + output.append(text[last_append:cursor]) output.append(replacement) + cursor = next_cursor + last_append = cursor + output.append(text[last_append:]) return "".join(output)