⚡ Bolt: Optimize export dictionary foreign key lookup#564
Conversation
Refactors `foreignKeyColumnsByNode` and `isForeignKeyColumn` in `frontend/src/erd/exportDataDictionary.ts` to precompute a Map of node-to-ForeignKeyNodeInfo objects containing Sets for column names and source handles. This replaces the linear O(E) array search (`edges.some(...)`) previously executed for every column in the schema with an O(1) Set lookup. This reduces the total computational complexity of ERD data dictionary exports from O(N * C * E) to O(E + N * C), preventing the browser's main thread from freezing when exporting schemas with hundreds of tables and relationships. Includes an entry in `.jules/bolt.md` documenting the performance learning.
|
👋 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 New to Jules? Learn more at jules.google/docs. For security, I will only act on instructions from the user who triggered this task. |
|
You are seeing this message because GitHub Code Scanning has recently been set up for this repository, or this pull request contains the workflow file for the Code Scanning tool. What Enabling Code Scanning Means:
For more information about GitHub Code Scanning, check out the documentation. |
OpenCode Review Overview
Changed-File Evidence Mapflowchart LR
PR["PR changed files"] --> Evidence["OpenCode bounded evidence"]
Evidence --> S1["Changed file: bolt.md"]
S1 --> I1["repository behavior"]
I1 --> R1["Review risk: Changed file: bolt.md"]
R1 --> V1["required checks"]
Evidence --> S2["Frontend: exportDataDictionary.ts"]
S2 --> I2["browser runtime and bundle"]
I2 --> R2["Review risk: Frontend: exportDataDictionary.ts"]
R2 --> V2["frontend tests"]
|
There was a problem hiding this comment.
Pull request overview
OpenCode reviewed the current-head bounded evidence and found no blocking issues.
Findings
No blocking findings.
Summary
Approval sufficiency: bounded evidence supplied affirmative approval evidence for changed files, coverage/docstring posture, risk surfaces, and current-head verification; approval is not based merely on the absence of known blockers.
Verification posture: CodeGraph evidence was initialized and bounded current-head evidence reviewed for changed-file evidence including .jules/bolt.md, frontend/src/erd/exportDataDictionary.ts.
Linter/static: workflow/static review evidence is bounded by the current-head GitHub Checks gate and changed-file evidence.
TDD/regression: coverage execution evidence and focused changed hunks were reviewed from bounded-review-evidence.md.
Coverage: coverage execution evidence reports supported repository test suites passed.
Docstring coverage: coverage execution evidence reports configured repository docstring gates passed or docstring coverage was advisory.
DAG: CodeGraph/source-backed behavior map connects .jules/bolt.md to the affected review, runtime, or workflow path and required checks.
PoC/execution: coverage-evidence job executed on the current head and reported PASS.
DDD/domain: workflow and repository-governance invariants were reviewed against changed files in bounded evidence.
CDD/context: CodeGraph evidence, changed-file history, and focused hunks were reviewed from bounded-review-evidence.md.
Similar issues: changed-file history evidence was reviewed for comparable local precedents.
Claim/concept check: bounded evidence, repository source, current-head workflow evidence, and, where numeric, scientific, statistical, or literature-backed claims are affected, original-paper/formula evidence and parameter-recovery expectations were used for claims.
Standards search: standards and external-source checks are delegated to configured OpenCode web_search/Context7/DeepWiki sources when applicable; no evidence-backed standards blocker is present in bounded evidence.
Compatibility/convention: changed workflow/script conventions, object naming, and reserved-word safety for schema/API/config/code surfaces were checked in bounded evidence.
Breaking-change/backcompat: deployment evidence and changed-file history were checked for backward-compatibility risk.
Performance: changed surfaces were checked for performance risk in bounded evidence.
Developer experience: changed automation, review, test, setup, and maintenance surfaces were checked for helpful or obstructive DX impact in bounded evidence.
User experience: connected user, operator, API, CLI, documentation, review-comment, status-check, rendering, and workflow-reader behavior was checked for contradictions against code, docs, and tests in bounded evidence.
Visual/DOM: deterministic repair does not infer browser runtime execution; source-backed DOM/UI evidence and trusted workflow receipts were reviewed when present, and non-web surfaces used API/CLI/log/docs/workflow evidence instead.
Accessibility/i18n: accessibility, localization, and human-readable text surfaces were checked where UI, CLI, API message, docs, logs, or review text changed.
Supply-chain/license: dependency, package, model, container, and external-tool changes were checked in bounded evidence.
Packaging: package, build, test, lint, and security contracts were checked in bounded evidence.
Security/privacy: workflow-token, review-gate, and repository-automation security/privacy boundaries were checked in bounded evidence.
Adversarial validation
{"status":"passed","probes":[{"path":"frontend/src/erd/exportDataDictionary.ts","line":47,"hypothesis":"Precomputed Sets may not handle edge cases with missing or malformed edge data","attack_or_counterexample":"Test with edges missing `sourceColumns` or `sourceHandle`","evidence":"Code inspection confirms the function handles missing data gracefully with `data?.sourceColumns || []` and `if (edge.sourceHandle)` checks","outcome":"falsified"},{"path":"frontend/src/erd/exportDataDictionary.ts","line":69,"hypothesis":"The new `isForeignKeyColumn` may incorrectly flag non-FK columns","attack_or_counterexample":"Test with columns that share names with FK columns but are not FKs","evidence":"Code inspection confirms the function correctly checks both `info.columns` and `info.handles` Sets","outcome":"falsified"}],"residual_risk":"Low; the changes are well-contained and verified by inspection"}- Result: APPROVE
- Reason: Optimized foreign key lookup in export dictionary with precomputed Sets
- Head SHA:
47eb5fc8c9c654edbb90e61201373edf60e9ce1b - Workflow run: 29255785014
- Workflow attempt: 1
💡 What: Refactored
foreignKeyColumnsByNodeandisForeignKeyColumninfrontend/src/erd/exportDataDictionary.tsto precompute node-specific Sets of foreign key column names and source handles, replacing the linearedges.some(...)array search. I also recorded a performance learning in.jules/bolt.md.🎯 Why: The previous implementation iterated through all edges for every column in every table during data dictionary generation (CSV and Markdown). For large ERDs (e.g., 500 tables, 5,000 columns, 1,000 edges), this O(N * C * E) complexity resulted in millions of redundant iterations, freezing the browser's main thread and causing significant UI lockups during export.
📊 Impact: Reduces export time complexity from O(N * C * E) to O(E + N * C) by shifting the edge-processing work to a single O(E) upfront pass, and replacing the nested O(E) search with O(1) Set lookups.
🔬 Measurement: Verify by loading a very large ERD schema (e.g. hundreds of tables) and clicking the 'Export CSV' or 'Export Markdown' dictionary options. The export should complete nearly instantaneously without freezing the browser's main thread.
PR created automatically by Jules for task 11173522472619978712 started by @seonghobae