fix(policies): preserve generated ToolGuard code - #14378
Conversation
|
Important Review skippedAuto incremental reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
WalkthroughThe PR preserves generated ToolGuard fields when generated-code sources are unavailable or when Policies frontend nodes are refreshed. It adds synchronization and frontend-node regression tests. Generated component metadata and its checksum are updated. ChangesGenerated guard preservation
Estimated code review effort: 3 (Moderate) | ~20 minutes 🚥 Pre-merge checks | ✅ 8 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (8 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
🧪 Generate unit tests (beta)
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. Comment |
✅ Test Coverage AdvisorNo source changes detected without accompanying tests. Thanks for keeping coverage up! 🎉
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/backend/tests/unit/components/models_and_agents/policies/test_policies_component.py (1)
74-74: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueRemove the redundant async marker.
pytest-asyncioalready auto-detects this async test withasyncio_mode = "auto"set inpyproject.toml.🤖 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 `@src/backend/tests/unit/components/models_and_agents/policies/test_policies_component.py` at line 74, Remove the redundant `@pytest.mark.asyncio` decorator from the async test in the policies component test module, relying on the existing asyncio_mode = "auto" configuration for detection.Source: Learnings
🤖 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
`@src/backend/tests/unit/components/models_and_agents/policies/test_policies_component.py`:
- Around line 75-113: Update
test_component_update_preserves_only_generated_guard_fields to use
ComponentTestBaseWithoutClient instead of directly relying on the mock_component
fixture. Add the required component_class, default_kwargs, and
file_names_mapping fixtures for PoliciesComponent, preserving the existing
assertions and ImportError behavior.
---
Nitpick comments:
In
`@src/backend/tests/unit/components/models_and_agents/policies/test_policies_component.py`:
- Line 74: Remove the redundant `@pytest.mark.asyncio` decorator from the async
test in the policies component test module, relying on the existing asyncio_mode
= "auto" configuration for detection.
🪄 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: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro Plus
Run ID: b41f3c9c-e122-4d4a-bf69-987be99674b0
📒 Files selected for processing (5)
src/backend/tests/unit/components/models_and_agents/policies/test_guard_sync_utils.pysrc/backend/tests/unit/components/models_and_agents/policies/test_policies_component.pysrc/lfx/src/lfx/_assets/component_index.jsonsrc/lfx/src/lfx/components/models_and_agents/policies/guard_sync_utils.pysrc/lfx/src/lfx/components/models_and_agents/policies_component.py
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release-1.11.2 #14378 +/- ##
==================================================
- Coverage 61.44% 58.42% -3.03%
==================================================
Files 2452 2391 -61
Lines 239862 237872 -1990
Branches 36330 35594 -736
==================================================
- Hits 147395 138986 -8409
- Misses 90661 97080 +6419
Partials 1806 1806
Flags with carried forward coverage won't be shown. Click here to find out more. 🚀 New features to boost your workflow:
|
Summary
CodeInputfields when the localStep_2directory is missing or invalidRoot cause
Canvas refresh treated an unavailable scratch directory as an authoritative empty directory and removed every generated field from the posted build config. Separately, component updates rebuilt Policies from its static template and copied values only for fields already present in that new schema, so dynamic guard fields disappeared before autosave.
Impact
Opening a Policies flow without its local scratch directory no longer deletes the guard code stored in the flow. Accepting a component update also retains the complete generated field dictionaries, without resurrecting unrelated retired inputs or requiring the optional ToolGuard runtime during template replacement.
When a real
Step_2directory exists, the existing synchronization behavior remains unchanged: files on disk refresh/add fields and absent files are pruned as stale.Validation
uv run pytest src/backend/tests/unit/components/models_and_agents/policies/test_guard_sync_utils.py src/backend/tests/unit/components/models_and_agents/policies/test_policies_component.py -q— 25 passedruff checkandruff formatLFX_DEV=1 uv run python scripts/build_component_index.pyAddresses LE-2094 (BUG-01 and BUG-02).
Related to #14050.
Summary by CodeRabbit
Bug Fixes
Tests