Skip to content

⚡ Bolt: Optimize handle resolution in ERD exports - #668

Closed
seonghobae wants to merge 1 commit into
mainfrom
bolt-optimize-handle-resolution-5430572171063510170
Closed

⚡ Bolt: Optimize handle resolution in ERD exports#668
seonghobae wants to merge 1 commit into
mainfrom
bolt-optimize-handle-resolution-5430572171063510170

Conversation

@seonghobae

@seonghobae seonghobae commented Jul 28, 2026

Copy link
Copy Markdown
Collaborator

💡 What: Replaced $O(N)$ column scanning and string encodings (via sourceColumnHandleId and sanitizeHandleId) with an $O(1)$ parseColumnNameFromHandle function.
🎯 Why: Resolving edge connections in export.ts and exportDataDictionary.ts required iterating through all columns of a node and encoding their names just to see if they matched the edge's sourceHandle or targetHandle. This resulted in $O(N \times C)$ complexity where $N$ is the number of edges and $C$ is the average number of columns per table.
📊 Impact: Considerably reduces CPU usage, string allocations, and garbage collection overhead during large diagram exports or dictionary CSV/Markdown generation.
🔬 Measurement: Verify tests still pass (cd frontend && pnpm test). For large ERDs, diagram and data dictionary exports will execute noticeably faster and with less memory overhead.


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

Summary by CodeRabbit

  • 개선 사항

    • ERD 내보내기에서 외래키 컬럼을 더 정확하게 식별합니다.
    • 유효하지 않거나 존재하지 않는 컬럼이 관계 정보에 포함되지 않도록 검증이 강화되었습니다.
    • CSV 및 Markdown 데이터 사전 내보내기의 외래키 표시가 더욱 안정적으로 처리됩니다.
  • 테스트

    • 다양한 핸들 형식과 잘못된 입력에 대한 컬럼명 복원 검증을 추가했습니다.

@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 Jul 28, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

ERD 핸들에서 컬럼명을 직접 복원하는 유틸리티를 추가하고, ERD 및 데이터 사전 내보내기의 FK 컬럼 매칭을 파싱된 컬럼명 기반으로 변경했습니다. 유효하지 않은 핸들 입력에 대한 테스트도 추가했습니다.

Changes

ERD 핸들 해석 최적화

Layer / File(s) Summary
핸들 컬럼명 디코더 추가
frontend/src/erd/handleUtils.ts, frontend/src/erd/handleUtils.test.ts
src-, tgt-, c- 핸들에서 컬럼명을 복원하는 parseColumnNameFromHandle와 정상·오류 입력 테스트를 추가했습니다.
내보내기 FK 매칭 전환
frontend/src/erd/export.ts, frontend/src/erd/exportDataDictionary.ts, .jules/bolt.md
FK 판별이 핸들 재생성·검색 대신 파싱된 컬럼명과 노드 컬럼 집합을 사용하도록 변경되었으며, 관련 최적화 기록을 추가했습니다.

Estimated code review effort: 3 (Moderate) | ~20 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed 제목이 ERD exports의 handle resolution 최적화라는 핵심 변경을 간결하고 정확하게 요약합니다.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bolt-optimize-handle-resolution-5430572171063510170

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

@coderabbitai coderabbitai 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.

Actionable comments posted: 2

🤖 Prompt for all review comments with 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.

Inline comments:
In `@frontend/src/erd/export.ts`:
- Around line 70-76: Update the export flow around the sourceHandleColumn and
targetHandleColumn checks to precompute each node’s column_name values into Set
or Map collections once before iterating edges. Replace both per-edge
columns?.some(...) scans with O(1) has() lookups while preserving the existing
validation behavior for source and target handles.

In `@frontend/src/erd/handleUtils.ts`:
- Around line 32-39: Update the encoded-token loop in the handle decoding
function to validate each hex token entirely against /^[0-9a-fA-F]+$/ before
calling parseInt, rejecting tokens with trailing non-hex characters while
preserving existing invalid-token behavior. Add a regression test covering an
input such as src-c-0069oops and verify it is not decoded as a valid handle.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: dedb49cb-3138-4513-9356-5ffaaae2b7bd

📥 Commits

Reviewing files that changed from the base of the PR and between 4bf3968 and 6ce0058.

📒 Files selected for processing (5)
  • .jules/bolt.md
  • frontend/src/erd/export.ts
  • frontend/src/erd/exportDataDictionary.ts
  • frontend/src/erd/handleUtils.test.ts
  • frontend/src/erd/handleUtils.ts

Comment on lines +70 to +76
const sourceHandleColumn = parseColumnNameFromHandle(edge.sourceHandle);
const targetHandleColumn = parseColumnNameFromHandle(edge.targetHandle);
if (
sourceHandleColumn &&
targetHandleColumn &&
sourceNode.data.columns?.some(c => c.column_name === sourceHandleColumn) &&
targetNode.data.columns?.some(c => c.column_name === targetHandleColumn)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🚀 Performance & Scalability | 🟠 Major | 🏗️ Heavy lift

노드 컬럼 확인 때문에 최악의 복잡도는 여전히 O(N × C)입니다.

parseColumnNameFromHandle은 O(1) 방식으로 사용되지만, 두 개의 .some() 호출이 각 edge마다 컬럼 배열을 선형 탐색합니다. export 시작 시 노드별 column_nameSet/Map으로 한 번만 구성한 뒤 has()로 조회해야 PR 목표인 O(N) 처리가 달성됩니다.

🤖 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 `@frontend/src/erd/export.ts` around lines 70 - 76, Update the export flow
around the sourceHandleColumn and targetHandleColumn checks to precompute each
node’s column_name values into Set or Map collections once before iterating
edges. Replace both per-edge columns?.some(...) scans with O(1) has() lookups
while preserving the existing validation behavior for source and target handles.

Comment on lines +32 to +39
try {
const parts = encoded.split('-');
let result = '';
for (const hex of parts) {
if (!hex) return undefined;
const cp = parseInt(hex, 16);
if (Number.isNaN(cp)) return undefined;
result += String.fromCodePoint(cp);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🎯 Functional Correctness | 🟠 Major | ⚡ Quick win

16진 토큰 전체를 먼저 검증하세요.

parseInt는 유효한 접두사까지만 변환하므로 src-c-0069oops"i"로 복원합니다. 이런 잘못된 핸들이 실제 컬럼명과 일치하면 ERD/데이터 사전에서 FK가 잘못 표시될 수 있습니다. 변환 전에 /^[0-9a-fA-F]+$/로 토큰 전체를 검증하고 회귀 테스트를 추가하세요.

🤖 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 `@frontend/src/erd/handleUtils.ts` around lines 32 - 39, Update the
encoded-token loop in the handle decoding function to validate each hex token
entirely against /^[0-9a-fA-F]+$/ before calling parseInt, rejecting tokens with
trailing non-hex characters while preserving existing invalid-token behavior.
Add a regression test covering an input such as src-c-0069oops and verify it is
not decoded as a valid handle.

@seonghobae

Copy link
Copy Markdown
Collaborator Author

Closed as superseded/duplicate agent perf micro-optimization; main already has comparable Bolt export/render opts (#561/#538). Commercial-baseline drain: not uniquely required.

@seonghobae seonghobae closed this Jul 31, 2026
@google-labs-jules

Copy link
Copy Markdown

Closed as superseded/duplicate agent perf micro-optimization; main already has comparable Bolt export/render opts (#561/#538). Commercial-baseline drain: not uniquely required.

Understood. Acknowledging that this work is now obsolete and stopping work on this task.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant