From 0c3e21920b4507ecf4bd0b3254ff3277673847ce Mon Sep 17 00:00:00 2001 From: seonghobae <8172694+seonghobae@users.noreply.github.com> Date: Sun, 5 Jul 2026 21:48:54 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9A=A1=20Bolt:=20=EC=84=B1=EB=8A=A5=20?= =?UTF-8?q?=ED=96=A5=EC=83=81=EC=9D=84=20=EC=9C=84=ED=95=9C=20JSON=20dicti?= =?UTF-8?q?onary=20=EC=B6=94=EC=B6=9C=20=EC=9E=AC=EA=B7=80=20=ED=98=B8?= =?UTF-8?q?=EC=B6=9C=20=EC=B5=9C=EC=A0=81=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit scripts/ci/opencode_review_normalize_output.py의 `extract_dicts` 함수에서 매 재귀 호출마다 리스트를 생성하고 `list.extend()`로 병합하던 방식을, 가변 객체(리스트) 참조를 넘겨 in-place `list.append()`로 변경하여 중간 리스트 할당 오버헤드를 제거함. --- .jules/bolt.md | 3 +++ scripts/ci/opencode_review_normalize_output.py | 9 +++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.jules/bolt.md b/.jules/bolt.md index 4bc7051..cb4379d 100644 --- a/.jules/bolt.md +++ b/.jules/bolt.md @@ -28,3 +28,6 @@ ## 2026-07-02 - Credential Masking Security Hole in Subprocess Environments **Learning:** Found a critical missing credential masking pattern in `scripts/ci/noema_review_gate.py`'s `scrub_sensitive_data` which didn't mask `Authorization: Basic` or `Proxy-Authorization: Basic` tokens unlike its analogous helper in `scripts/ci/pr_review_merge_scheduler.py`. This leaves exception messages and logs vulnerable to exposing sensitive credentials when HTTP operations fail. **Action:** When implementing credential masking functions that sanitize tracebacks and log messages, ensure the masking scope includes all relevant headers, particularly `Authorization` and `Proxy-Authorization`. Ensure parity across masking helpers across CI scripts to prevent blind spots. +## 2026-07-06 - Avoid recursive list allocations in JSON extraction +**Learning:** In recursive tree-walking functions like `extract_dicts`, using `results.extend()` on the results of recursive calls allocates many intermediate lists, leading to unnecessary memory overhead and slower execution times, especially on deeply nested JSON objects. +**Action:** Optimize recursive collection functions by passing a single mutable list instance (e.g. `results`) down through the call stack and using `list.append()` or `list.extend()` to mutate it in-place rather than concatenating returned lists. diff --git a/scripts/ci/opencode_review_normalize_output.py b/scripts/ci/opencode_review_normalize_output.py index 88b9318..340476b 100755 --- a/scripts/ci/opencode_review_normalize_output.py +++ b/scripts/ci/opencode_review_normalize_output.py @@ -843,16 +843,17 @@ def valid_control( } -def extract_dicts(obj: Any) -> list[Any]: +def extract_dicts(obj: Any, results: list[Any] | None = None) -> list[Any]: """Recursively extract all dictionaries from a JSON-like object.""" - results = [] + if results is None: + results = [] if isinstance(obj, dict): results.append(obj) for v in obj.values(): - results.extend(extract_dicts(v)) + extract_dicts(v, results) elif isinstance(obj, list): for item in obj: - results.extend(extract_dicts(item)) + extract_dicts(item, results) return results