Skip to content

⚡ Bolt: 단일 루프로 조직 인벤토리 집계 최적화 - #1355

Closed
seonghobae wants to merge 6 commits into
developfrom
bolt/optimize-org-inventory-loop-14541688219511296318
Closed

seonghobae wants to merge 6 commits into
developfrom
bolt/optimize-org-inventory-loop-14541688219511296318

Conversation

@seonghobae

@seonghobae seonghobae commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

💡 What: build_org_inventory 함수에서 동일 리포지토리 목록을 순회하여 여러 리스트 및 Generator를 파생 생성하던 로직을 하나의 명시적 루프로 통합했습니다.

🎯 Why: O(N) 순회가 7번 이상 발생하며 nonforks, forks, primary_languages, default_branches 등을 연산하던 병목을 단일 패스(O(N))로 단축하여 불필요한 배열 메모리 할당 및 Generator 순회 오버헤드를 줄였습니다.

📊 Impact: 여러 번의 O(N) 순회를 하나로 줄임으로써 파싱과 메모리 할당 빈도를 낮추어 constant-factor 성능 향상이 기대됩니다.

🔬 Measurement: 해당 최적화 후 전체 테스트 스위트가 여전히 정상 동작하며(1091/1091), 내부 로직과 Output (OrgInventory 모델 반환 객체) 역시 기존 동작을 완전히 보존하는 것을 확인했습니다.

Exact-head delivery state

  • protected base: develop@2949d30718752ea5915c7713ba227e8c19d9e5bf
  • exact head: 7764372202ab1736987b0ea1f2951765e61b89b3
  • relation: 4 commits ahead / 0 behind; two effective files
  • source relation: one source-neutral child above reviewed c5ca0d8c…; GitHub compare reports zero changed files
  • hosted evidence: eight workflows terminal SUCCESS, including Tests 36728623459 and Security Scan 36728623539
  • CodeQL PR 36728623755: completed/skipped, not a successful analysis verdict
  • review: prior Noema approval targets predecessor c5ca0d8c… and does not transfer; current-head approval 0, unresolved threads 0

The repeated Bolt commit message contributes no source or verification delta. Keep Draft until the unchanged exact head has a qualifying independent review and terminal required protection evidence. No manual rerun or source-neutral trigger is justified.


PR created automatically by Jules for task 14541688219511296318 started by @seonghobae

Summary by CodeRabbit

  • 개선 사항
    • 조직 저장소 현황을 계산하는 처리 과정을 효율화해 반복 작업을 줄였습니다. 저장소가 많은 조직에서 현황을 더 효율적으로 계산할 수 있습니다.
    • 저장소 언어와 기본 브랜치 집계, 비공개 저장소 수, 포크 및 비포크 저장소 수의 결과는 기존과 동일하게 유지됩니다. 지원 언어와 미지원 언어의 분류 기준도 유지됩니다.

appguardrail_core/org_intelligence.py 내부 `build_org_inventory` 함수가
동일한 github 리포지토리 컬렉션을 다중 순회(O(N) * K)하며 파생 리스트들을 생성하던 것을 단일 루프로 통합하여
성능을 최적화함. 상수 인자(constant-factor) 개선사항이며, 변경사항은 .jules/bolt.md 에 기록됨.
@google-labs-jules

Copy link
Copy Markdown

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@coderabbitai

coderabbitai Bot commented Sep 30, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 45df0016-3be2-4993-8a33-b542ab50cb44

📥 Commits

Reviewing files that changed from the base of the PR and between f9d6a3d and c5ca0d8.

📒 Files selected for processing (1)
  • appguardrail_core/org_intelligence.py

Included review availability: This review used your included allowance. Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

build_org_inventory는 저장소 목록을 한 번 순회하며 집계합니다. 전체 저장소와 비포크 저장소에 적용되는 집계 기준은 유지합니다. 반환값은 누적값으로 구성합니다. 중복 순회를 결합하는 최적화 지침도 추가했습니다.

Changes

저장소 인벤토리 최적화

Layer / File(s) Summary
단일 순회 집계와 결과 구성
appguardrail_core/org_intelligence.py, .jules/bolt.md
build_org_inventory가 저장소를 한 번 순회하며 언어, 기본 브랜치, 비공개 수와 포크·비포크 수를 누적합니다. 지원 언어 수와 지원되지 않는 언어 집합은 비포크 저장소를 기준으로 구성하며, "Unknown"은 지원되지 않는 언어 집계에서 제외합니다. 활성 저장소 목표 판정은 누적된 비포크 수를 사용합니다. 중복 순회를 결합하는 최적화 지침을 추가했습니다.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to c5ca0

The single-pass calculation preserves the prior inventory results and active-repository threshold for supported inputs, with no actionable merge-blocking risk identified.

Architecture Summary

Architecture risk: 🔵 Low · up to c5ca0

The change affects 1 system.

Changed systems: appguardrail_core

Architecture concerns
No architecture-level concerns identified.

Review details

Systems and components

  • observed — appguardrail_core (service) was modified; 1 changed file maps to changed impact.

Before / after behavior

  • observed — Modified behavior in appguardrail_core/org_intelligence.py: build_org_inventory replaces list-based filtering and repeated scans with one pass over repos, accumulating repository counts and language/branch counts. It still counts supported and unsupported primary languages only for non-forks, excluding "Unknown" from unsupported languages; private and language/branch totals include forks.
  • observed — Modified behavior in appguardrail_core/org_intelligence.py: The inventory return now uses the accumulated counts for totals, fork/non-fork/private counts, and sorted unsupported languages; the active-target check remains nonfork_count >= active_repository_target.
  • observed — Modified behavior in .jules/bolt.md: build_org_inventory가 여러 O(N) 순회로 값을 도출하던 방식을 단일 순회로 통합해 반복 횟수를 2N에서 N으로 줄였다는 학습 내용과, 기능을 유지하면서 동일한 입력의 중복 순회를 결합하라는 지침을 추가했습니다.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 1 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목은 build_org_inventory의 단일 루프 집계 최적화라는 주요 변경 사항을 정확하고 간결하게 설명합니다.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@seonghobae seonghobae added enhancement New feature or request priority: medium Normal-priority or P2 work status: needs-review Open pull request requiring current-head review or checks labels Sep 30, 2026 — with ChatGPT Codex Connector
appguardrail_core/org_intelligence.py 내부 `build_org_inventory` 함수가
동일한 github 리포지토리 컬렉션을 다중 순회(O(N) * K)하며 파생 리스트들을 생성하던 것을 단일 루프로 통합하여
성능을 최적화함. 상수 인자(constant-factor) 개선사항이며, 변경사항은 .jules/bolt.md 에 기록됨.
appguardrail_core/org_intelligence.py 내부 `build_org_inventory` 함수가
동일한 github 리포지토리 컬렉션을 다중 순회(O(N) * K)하며 파생 리스트들을 생성하던 것을 단일 루프로 통합하여
성능을 최적화함. 상수 인자(constant-factor) 개선사항이며, 변경사항은 .jules/bolt.md 에 기록됨.
cwl-noema-review[bot]
cwl-noema-review Bot previously approved these changes Sep 30, 2026

@cwl-noema-review cwl-noema-review Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Noema LLM review

The optimization in appguardrail_core/org_intelligence.py correctly consolidates multiple O(N) passes into a single loop without altering the business logic. Verified that counts for private repositories, non-fork repositories, and unsupported languages remain consistent with the previous declarative implementation. The addition to .jules/bolt.md accurately documents this architectural learning.

Reviewed changed lines

  • appguardrail_core/org_intelligence.py:140 (RIGHT): The migration from a filtered set comprehension on nonforks to a conditional unsupported_set.add within the main loop preserves the logic: it correctly excludes forks, supported languages, and 'Unknown' languages, and maintains the sorting requirement in the return value.
  • appguardrail_core/org_intelligence.py:144 (RIGHT): Replacing a generator-based sum for private repositories with a simple integer increment (private_count) is a direct behavioral equivalent that avoids an extra traversal of the repository list.
  • appguardrail_core/org_intelligence.py:153 (RIGHT): The check for active_repository_target_met now uses the accumulated nonfork_count instead of len(nonforks). Since nonfork_count is incremented only when is_fork is false, this is logically identical.

Adversarial validation

  • appguardrail_core/org_intelligence.py:153 (RIGHT) falsified: Using an integer counter instead of a filtered list length might lead to off-by-one errors or miscount forks as non-forks. — The conditional logic if is_fork: fork_count += 1 else: nonfork_count += 1 ensures mutual exclusivity and completeness.
  • appguardrail_core/org_intelligence.py:140 (RIGHT) falsified: The new logic might include languages from fork repositories in the unsupported_nonfork_languages tuple. — Indentation and logical flow strictly limit updates to unsupported_set to cases where is_fork is false.
  • Residual risk: none

Findings

  • No blocking findings.
  • Result: APPROVE
  • Head SHA: c5ca0d8c1bf6713ab21cdfbf372638ce774753af
  • Reviewer credential: noema-review-github-app-refresh
  • Actor: cwl-noema-review[bot]

@seonghobae
seonghobae marked this pull request as draft September 30, 2026 14:17

Copy link
Copy Markdown
Contributor Author

Lifecycle correction on exact head c5ca0d8c1bf6713ab21cdfbf372638ce774753af.

CodeQL PR run 36704881602 is terminal failure. Receiver job(s) 109874443048/109874443183 completed the dispatch request but read VERDICT_STATE=pending and then failed closed; queued/pending settlement is not GREEN. This PR is therefore returned to Draft until the central protected CodeQL settlement produces authenticated terminal evidence on this unchanged head and all remaining exact-head gates finish. No manual rerun, synthetic status, bypass, force push, or source change was used.

appguardrail_core/org_intelligence.py 내부 `build_org_inventory` 함수가
동일한 github 리포지토리 컬렉션을 다중 순회(O(N) * K)하며 파생 리스트들을 생성하던 것을 단일 루프로 통합하여
성능을 최적화함. 상수 인자(constant-factor) 개선사항이며, 변경사항은 .jules/bolt.md 에 기록됨.

Copy link
Copy Markdown
Contributor Author

Verified successor carryover before retirement:

  • predecessor exact head: 7764372202ab1736987b0ea1f2951765e61b89b3
  • protected base: develop@2949d30718752ea5915c7713ba227e8c19d9e5bf
  • predecessor diff: .jules/bolt.md plus appguardrail_core/org_intelligence.py; no executable regression
  • canonical successor: refactor(inventory): stream repository aggregation #1292 exact be032f101a7b1e234c603d983b9a5645ecebd031
  • successor diff: exactly the inventory implementation plus tests/test_org_inventory_single_pass.py
  • successor tree equals verified c12402ee828068b2287bb06594218f3aeb7f2f7c with zero file changes; source blob 28f9876e… and behavioral regression blob d0620b3c… are identical

The valid delta is fully carried: both implementations perform one-pass, non-materializing aggregation of total/fork/non-fork/private/language/default-branch facts, while #1292 additionally proves release of consumed records and semantic counts with an executable weak-reference regression. The predecessor's four-line .jules/bolt.md addition is intentionally not carried because it promotes an unmeasured constant-factor rewrite into repository-wide guidance; neither PR contains representative wall/CPU/allocation benchmark evidence for that blanket rule.

I will now restore both predecessor paths to the protected-base blobs, mechanically verify a zero-file diff on the new exact head, and only then close this duplicate. #1292 remains Draft because its current hosted jobs are zero-step admission failures and it has no qualifying current-head approval; no Check or approval evidence is transferred.

Copy link
Copy Markdown
Contributor Author

Retirement proof complete on exact head fdb57af4cc5066784748d82ce3153f18e9bde642: compare against protected develop@2949d30718752ea5915c7713ba227e8c19d9e5bf is ahead 6 / behind 0 with files: [], and the PR file list is empty. Every valid inventory delta remains in #1292 exact be032f101a7b1e234c603d983b9a5645ecebd031; the unmeasured blanket .jules rule was explicitly rejected above. Closing only after mechanical zero-diff verification; this is verified successor carryover, not abandonment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request priority: medium Normal-priority or P2 work status: needs-review Open pull request requiring current-head review or checks

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

1 participant