Skip to content

feat(components): component index correctness + build caching#12784

Merged
ogabrielluiz merged 9 commits intocold-start/01-measurement-foundationfrom
cold-start/02-component-index
May 6, 2026
Merged

feat(components): component index correctness + build caching#12784
ogabrielluiz merged 9 commits intocold-start/01-measurement-foundationfrom
cold-start/02-component-index

Conversation

@ogabrielluiz
Copy link
Copy Markdown
Contributor

Summary

Fixes correctness bugs in the component index (concurrency, version stamping, atomic writes, stale detection) and adds a cache-hit short-circuit that brings the index-populated cold-start path from ~3.4s to <500ms by skipping the full package walk when the installed lfx version matches.

Scope

  • src/lfx/src/lfx/interface/components.py — all index correctness + caching changes:
    • Lazy asyncio.Lock property on ComponentCache (safe under module-import-time constraints)
    • asyncio.Semaphore(16) cap on _load_components_dynamically
    • Async _read_component_index with asyncio.to_thread for file I/O
    • version("lfx") stamp on the persisted index; atomic same-directory tmp + os.replace writes
    • Dev-mode stale-index warning on version mismatch
    • Cache-hit short-circuit: when the persisted cache matches the installed lfx version, skip the full package walk
  • src/lfx/tests/unit/test_component_index.py — parity tests (byte-identical flow output + vertex execution order) for every change, plus cache-hit perf assertion (<500ms)

Stacked on

PR #12783 (cold-start measurement harness)

Test plan

  • cd src/lfx && uv run pytest tests/unit/test_component_index.py -v (scope to this file; do not run tests/unit/ as a glob)

Lazy asyncio.Lock on ComponentCache (safe under module-import-time
constraints), bounded concurrency on dynamic component loading,
non-blocking async read of the persisted index, cache-hit short-circuit
that skips the full package walk when the installed lfx version matches,
atomic + version-stamped writes, stale-index warning.

- src/lfx/src/lfx/interface/components.py: all correctness + caching changes
- src/lfx/tests/unit/test_component_index.py: parity + correctness tests

Observable flow behavior is unchanged: every change is accompanied by a
deep parity snapshot test that loads a flow via the component cache and
asserts byte-identical final output + vertex execution order.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 20, 2026

Important

Review skipped

Draft detected.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: 0b21fa0c-3030-49b4-9f40-371a601af9db

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch cold-start/02-component-index

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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 and usage tips.

@github-actions github-actions Bot added the enhancement New feature or request label Apr 20, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 4, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 4, 2026
- Cache-hit short-circuit now verifies SHA256 inline before promoting the
  blob; tampered or missing-SHA caches fall through to the rebuild path.
- Stale-version caches are unlinked in the peek so the rebuild path can
  write fresh, instead of warning every cold start indefinitely.
- _save_generated_index splits OSError (warning) from unexpected
  exceptions (error + traceback); silent debug-level failures previously
  hid disk-full / permission-denied regressions.
- Cache peek narrows except to (OSError, JSONDecodeError) and emits a
  warning so corrupt files don't silently trigger a rebuild.
- _load_components_dynamically tracks per-type failure counts and emits
  one aggregate "N of M modules failed" log alongside the per-module
  warnings.
- _load_selective_dev_mode warns when the merge produces zero components
  to avoid empty-palette debug-time UX.
- _read_component_index outer except includes exc_info=True.
- Stale-cache log converted from %-formatting to f-string.

Tests live in a new file (test_component_index_correctness.py) so they
collect cleanly; the existing test_component_index.py imports a
parity-helpers module that does not exist on this branch.
Drop the defensive negatives and second-branch variants. Each remaining
test exercises one fix end-to-end:

- tampered SHA does not short-circuit (cache-hit SHA verification)
- stale-version cache is unlinked (auto-regeneration)
- corrupt JSON cache warns and rebuilds (narrow except)
- save OSError logs at warning (write-failure visibility)
- selective dev mode warns on empty result
- load_components_dynamically emits aggregate failure summary

12 tests -> 6 tests, ~370 lines -> ~200.
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 4, 2026
Move the 6 regression tests for the post-review fixes into the existing
test_component_index.py and drop the standalone file. Reuses the file's
existing _fake_settings_service / _reset_component_cache_singleton
helpers.
@jordanrfrazier jordanrfrazier self-requested a review May 4, 2026 21:08
@github-actions github-actions Bot added enhancement New feature or request lgtm This PR has been approved by a maintainer and removed enhancement New feature or request labels May 4, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 6, 2026
@github-actions github-actions Bot added enhancement New feature or request and removed enhancement New feature or request labels May 6, 2026
@ogabrielluiz ogabrielluiz merged commit 8921cd5 into cold-start/01-measurement-foundation May 6, 2026
30 of 31 checks passed
@ogabrielluiz ogabrielluiz deleted the cold-start/02-component-index branch May 6, 2026 16:59
@ogabrielluiz
Copy link
Copy Markdown
Contributor Author

Consolidated into #12783 for QA. The chain merges that brought this branch's content up to the base PR caused GitHub to auto-mark this as merged; the actual landing happens when #12783 merges into release-1.10.0. Original review thread preserved here.

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

Labels

enhancement New feature or request lgtm This PR has been approved by a maintainer

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants