Repository navigation
Dynamic skill descriptions: update Node Creation skill when schemas change - #1074
Conversation
…hange (closes #1061) Implements a reactive SkillUpdater that subscribes to domain events and updates the "Node Creation" skill node description when schemas are created or deleted. This ensures semantic skill discovery stays current — when a user creates an "invoice" schema, searching for "create a new invoice" will now match the Node Creation skill with high confidence. ## Implementation - `packages/core/src/ops/skill_updater.rs` — new `SkillUpdater` struct: - Subscribes to `NodeCreated`/`NodeUpdated`/`NodeDeleted` events where `node_type == "schema"` - Fetches all non-core schemas via `get_all_schemas()` - Builds description: "...add a task, text note, or an entry for invoice, customer, project." when custom types are present - Updates skill node via `update_node_unchecked()` → triggers embedding pipeline re-embeds the skill automatically - Skips write if description is unchanged (idempotent) - Handles broadcast lag gracefully by running a proactive sync - `packages/core/src/ops/mod.rs` — declares `pub mod skill_updater` - `packages/core/tests/skill_updater_test.rs` — 4 integration tests: - Full event-driven cycle: create schema → skill description updated - Multiple schema names all appear in updated description - `build_node_creation_description` with custom types - `build_node_creation_description` fallback to base - `packages/desktop-app/src-tauri/src/lib.rs` — `initialize_skill_updater()` function that spawns the updater as a background task with shutdown support - `packages/desktop-app/src-tauri/src/commands/db.rs` — call `initialize_skill_updater()` after playbook engine initialization Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Code Review — PR #1074: Dynamic Skill DescriptionsOverall Assessment: This is a net-positive change that correctly solves the semantic discovery problem described in #1061. The architecture is sound — a narrow, single-purpose background task that subscribes to existing domain events and performs an idempotent write. The core loop, lag handling, and shutdown wiring are all done well. There are a few issues worth addressing before merge. Findings[Improvement]
|
| Criterion | Status |
|---|---|
| Schema created → skill description updated | Covered by implementation and integration test |
| Schema deleted → type removed from description | Event handling correct; no integration test for delete path |
| Skill embedding regenerated after update | Correct by design — update_node_unchecked emits NodeUpdated which triggers embedding pipeline |
| Semantic search for "create a new {type}" matches | Not unit-testable here, but the mechanism is correct |
| Fully reactive, no manual intervention | Yes |
The missing integration test for the delete path is the only acceptance criterion gap. Worth adding a test_skill_updater_removes_deleted_schema test.
Summary
The core design is correct and the implementation is clean. The two most impactful items before merge are: (1) the missing proactive startup sync — schemas present on boot will be silently ignored until the next mutation, and (2) the s.id vs s.content question for description quality. The weak OR assertion in the multiple-schema integration test and the missing delete-path test are also worth fixing to ensure the test suite actually validates the stated behavior.
Not a blocker overall given the greenfield context, but these are all straightforward fixes.
malibio
left a comment
There was a problem hiding this comment.
Principal Engineer review complete. See detailed findings in the comment above. Key items before merge: (1) proactive startup sync missing — schemas present at boot are ignored until next schema mutation; (2) s.id vs s.content for display names; (3) weak OR assertion in multi-schema integration test; (4) no integration test for the delete path (acceptance criterion gap). All are straightforward fixes.
All 5 findings from pragmatic-code-review addressed: 1. Use s.content (display name) instead of s.id (machine key) for descriptions — embedding model now sees "Invoice" not "invoice", improving semantic match quality. 2. Proactive startup sync — update_node_creation_skill() called before entering the event loop so schemas present at boot time are immediately reflected. 3. initialize_skill_updater() now returns anyhow::Result<()> consistent with initialize_playbook_engine() and other sibling initializers. 4. Added AssertUnwindSafe + catch_unwind panic guard on spawned task, matching the pattern used by initialize_playbook_engine(). 5. Fixed test_skill_updater_adds_multiple_schemas to use && instead of ||. Added test_skill_updater_removes_deleted_schema_from_description to cover the schema deletion acceptance criterion. Nit: replaced unwrap_or_default() on get_all_schemas() with explicit error logging via warn!() before returning early, so DB errors are not silently swallowed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
Re-Review — PR #1074: Dynamic Skill DescriptionsRe-review scope: Commit Finding-by-Finding VerificationFinding 1 — Finding 2 — No proactive startup sync [Improvement] Finding 3 — Finding 4 — No panic guard on spawned task [Improvement] Finding 5 — Weak
One observation on the delete test design: the schemas are created before the updater starts, so the test correctly relies on the startup sync (Finding 2's fix) rather than the event loop to initially populate the description. This is good — it tests both features together and will catch a regression if startup sync is ever removed. The subsequent deletion then exercises the event-driven path. Design is sound. Nit — New Code Introduced — No New IssuesThe new test helper code in
SummaryAll 5 findings and the nit are properly addressed. The fix commit is focused and does not introduce any new issues. The test suite now covers the full acceptance criteria surface including the delete path. The startup sync ordering is correctly implemented with the TOCTOU gap closed. This PR is ready to merge. |
malibio
left a comment
There was a problem hiding this comment.
Re-review complete: all findings addressed
…hange (closes #1061) * Dynamic skill descriptions: update Node Creation skill when schemas change (closes #1061) Implements a reactive SkillUpdater that subscribes to domain events and updates the "Node Creation" skill node description when schemas are created or deleted. This ensures semantic skill discovery stays current — when a user creates an "invoice" schema, searching for "create a new invoice" will now match the Node Creation skill with high confidence. ## Implementation - `packages/core/src/ops/skill_updater.rs` — new `SkillUpdater` struct: - Subscribes to `NodeCreated`/`NodeUpdated`/`NodeDeleted` events where `node_type == "schema"` - Fetches all non-core schemas via `get_all_schemas()` - Builds description: "...add a task, text note, or an entry for invoice, customer, project." when custom types are present - Updates skill node via `update_node_unchecked()` → triggers embedding pipeline re-embeds the skill automatically - Skips write if description is unchanged (idempotent) - Handles broadcast lag gracefully by running a proactive sync - `packages/core/src/ops/mod.rs` — declares `pub mod skill_updater` - `packages/core/tests/skill_updater_test.rs` — 4 integration tests: - Full event-driven cycle: create schema → skill description updated - Multiple schema names all appear in updated description - `build_node_creation_description` with custom types - `build_node_creation_description` fallback to base - `packages/desktop-app/src-tauri/src/lib.rs` — `initialize_skill_updater()` function that spawns the updater as a background task with shutdown support - `packages/desktop-app/src-tauri/src/commands/db.rs` — call `initialize_skill_updater()` after playbook engine initialization Co-Authored-By: Claude Sonnet 4.6 <[email protected]> * Address review findings for SkillUpdater (PR #1074) All 5 findings from pragmatic-code-review addressed: 1. Use s.content (display name) instead of s.id (machine key) for descriptions — embedding model now sees "Invoice" not "invoice", improving semantic match quality. 2. Proactive startup sync — update_node_creation_skill() called before entering the event loop so schemas present at boot time are immediately reflected. 3. initialize_skill_updater() now returns anyhow::Result<()> consistent with initialize_playbook_engine() and other sibling initializers. 4. Added AssertUnwindSafe + catch_unwind panic guard on spawned task, matching the pattern used by initialize_playbook_engine(). 5. Fixed test_skill_updater_adds_multiple_schemas to use && instead of ||. Added test_skill_updater_removes_deleted_schema_from_description to cover the schema deletion acceptance criterion. Nit: replaced unwrap_or_default() on get_all_schemas() with explicit error logging via warn!() before returning early, so DB errors are not silently swallowed. Co-Authored-By: Claude Sonnet 4.6 <[email protected]> --------- Co-authored-by: Michael Libio <[email protected]> Co-authored-by: Claude Sonnet 4.6 <[email protected]>
Closes #1061