Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .jules/bolt.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
10 changes: 8 additions & 2 deletions scripts/ci/redact_sensitive_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Comment on lines +109 to +110

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

문자열 누적 최적화의 복잡도 설명을 일관되게 수정해 주세요.

Python 리스트의 append는 분할상환 O(1)이고 최종 join은 O(N)이므로, 기존 방식도 점근적으로 O(N)입니다. 이번 변경의 효과는 O(N²)에서 O(N)으로의 변환이 아니라, 비매칭 구간을 묶어 append 호출과 리스트 항목 수를 줄이는 것입니다.

  • scripts/ci/redact_sensitive_log.py#L109-L110: 인라인 주석을 실제 상수 계수 개선으로 수정해 주세요.
  • .jules/bolt.md#L46-L48: 최적화 지침에서 O(N²) 메모리·실행 시간 주장을 제거해 주세요.
📍 Affects 2 files
  • scripts/ci/redact_sensitive_log.py#L109-L110 (this comment)
  • .jules/bolt.md#L46-L48
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@scripts/ci/redact_sensitive_log.py` around lines 109 - 110, Update the
optimization description at scripts/ci/redact_sensitive_log.py lines 109-110 to
state that batching non-matching spans reduces append calls and list entries,
improving constant factors without claiming an O(N²)-to-O(N) complexity change.
Update .jules/bolt.md lines 46-48 to remove the O(N²) memory and execution-time
claims and describe the same constant-factor optimization.

output.append(text[last_append:cursor])
output.append(replacement)
cursor = next_cursor
last_append = cursor
output.append(text[last_append:])
return "".join(output)


Expand Down
Loading