Skip to content

Unify skill/prompt seeding with markdown import pipeline - #1096

Merged
malibio merged 3 commits into
mainfrom
feature/issue-1056-unify-seed-with-markdown-pipeline
Apr 11, 2026
Merged

malibio merged 3 commits into
mainfrom
feature/issue-1056-unify-seed-with-markdown-pipeline

Conversation

@malibio

@malibio malibio commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator

Closes #1056

Replaces the ad-hoc SeedSkill / SeedGuidancePrompt / SeedPrompt structs
and their bespoke to_node() conversions with a single NodeTemplate
abstraction backed by the existing prepare_nodes_from_markdown pipeline.

## What changed

### packages/core/src/mcp/handlers/markdown.rs
- Add `NodeTemplate` struct: title, optional content override, markdown_content,
  root_node_type, root_properties, child_node_type, child_properties
- Add `prepare_nodes_from_template()`: expands a template into a flat
  PreparedNode list (root + children) using the existing markdown parser

### packages/core/src/services/node_service.rs
- Add `seed_nodes_from_templates()`: inserts template-expanded node groups
  with the same type-level idempotency guarantee as the old seeding path
- Delete unused `seed_nodes_if_needed()` (replaced entirely)

### packages/agent/src/skill_pipeline.rs
- `seed_skill_nodes()` now returns `Vec<NodeTemplate>` instead of `Vec<SeedSkill>`
- Guidance text moves into `markdown_content`; skill metadata moves into
  `root_properties` (description, tool_whitelist, max_iterations, output_format)
- Delete `SeedSkill`, `SeedGuidancePrompt` structs and their impl blocks
- Tests updated to use NodeTemplate field access + prepare_nodes_from_template

### packages/agent/src/prompt_assembler.rs
- `seed_prompt_nodes()` now returns `Vec<NodeTemplate>` instead of `Vec<SeedPrompt>`
- Prompt body text stored in `content` field (overrides title as node content)
- `assemble_static()` updated to read priority/template_syntax from root_properties
- Delete `SeedPrompt` struct and its `to_node()` impl
- Tests updated accordingly

### packages/desktop-app/src-tauri/src/commands/db.rs
- Seeding block unified: expands all templates via prepare_nodes_from_template,
  inserts via seed_nodes_from_templates (single pass, no separate child loop)
- Prompt content diff-check preserved using template.content field

### packages/agent/tests/ollama_integration.rs
- tools_for_skill() and build_schema_creation_prompt() updated to use
  NodeTemplate field access (.title, .root_properties, .markdown_content)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>
@malibio

malibio commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator Author

Code Review — PR #1096: Unify skill/prompt seeding with markdown import pipeline

Branch: `feature/issue-1056-unify-seed-with-markdown-pipeline`
Reviewed commit: d723da8
Initial review (no prior reviews on record)


Summary

This PR delivers a clean unification of three ad-hoc seeding structs (SeedSkill, SeedGuidancePrompt, SeedPrompt) into a single NodeTemplate abstraction backed by the existing prepare_nodes_from_markdown pipeline. The net result is a meaningful reduction in code surface (~130 lines deleted, a single well-documented insertion path, and direct reuse of the battle-tested markdown parser for hierarchy creation.

The architectural intent is correct and well-executed. There is one functional regression worth addressing before merge, one minor structural concern, and a handful of nits.


Findings

[Improvement] Skill guidance content drift is now silently ignored

File: packages/desktop-app/src-tauri/src/commands/db.rs

The old seeding block included a per-guidance-prompt diff-check loop: it queried each skill node's children, compared content against the seed string, and called update_node_unchecked if they differed. This kept guidance prompt text current across application updates on existing installations.

The new code drops this loop entirely. Only root prompt nodes (from prompt_templates) are diff-checked. Skill guidance children — the markdown bodies stored under skill roots — are never updated after first seed. If someone changes the "Research & Search Guidance" or "Schema Creation Guidance" markdown content in a future release, existing users will silently keep the old text forever.

The issue description says "Eliminates SeedGuidancePrompt structs and custom seeding logic," which could be read as intentionally removing this, but the seeding block comment still says "Built-in prompt content is also diff-checked so changes to the seed strings propagate to existing installations" — a contract it only fulfills for half the seeded data.

Options:

  1. Extend the diff-check loop to also walk skill_templates, query their existing guidance children by (parent_skill_id, title), and update content if changed. This preserves the previous behavior.
  2. Accept the regression explicitly and update the comment to remove the false promise.

Given this is a greenfield project with no live installations, option 2 is acceptable in the short term, but the misleading comment needs to be corrected now.


[Improvement] Stale test comment contradicts the assertion it introduces

File: packages/agent/src/skill_pipeline.rs, line 702

The comment reads:

// --- Skill whitelist tests for all 7 skills ---

But line 483 asserts seeds.len() == 8 and the section covers 8 skills. This comment was likely copied from a previous count and then not updated when "Organization" was added. It will confuse anyone reading the test file.


[Improvement] child_node_type / child_properties are populated on skills with empty markdown_content

File: packages/agent/src/skill_pipeline.rs

Six of the eight skill templates (Node Creation, Graph Editing, Relationship Management, Node Deletion, Bulk Import, Organization) have markdown_content: String::new() but still specify child_node_type: Some("prompt"...) and child_properties: Some(...). Because prepare_nodes_from_template guards the child-parse path with if tmpl.markdown_content.trim().is_empty() { Vec::new() }, these fields are dead on those instances — the overrides are built and then never applied.

This is harmless but it clutters every skill literal with three extra fields that do nothing. Either:

  • Set child_node_type: None and child_properties: None on skills that have no guidance, matching the actual runtime behavior, or
  • Add a Default impl to NodeTemplate so callers only set what they need (reduces boilerplate significantly across the whole file).

[Nit] Doc example omits the content field

File: packages/core/src/mcp/handlers/markdown.rs, line 1256

The ````ignoreexample inNodeTemplate`'s doc comment is missing the `content` field (which is part of the struct). Since `content` has a meaningful semantic role (overrides `title` as the node body), showing `content: None` in the skill example and a separate `content: Some(...)` snippet for the prompt use-case would make the struct's dual usage immediately clear.


[Nit] prepare_nodes_from_template has no direct unit tests in markdown_test.rs

File: packages/core/src/mcp/handlers/markdown_test.rs

The function is exercised indirectly through the agent-level tests (seed_skill_template_produces_skill_node, seed_prompt_template_produces_prompt_node), which are adequate for correctness of the happy path. However, edge cases specific to the new function — empty markdown_content with child_properties set, non-object child_properties triggering the replace-entirely branch, root_properties being non-object — are not covered. Given the function is pub and will be the unified entry point for all future seeding, a small dedicated test block directly in markdown_test.rs would improve confidence and serve as specification documentation.


What is done well

  • Clean deletion: All three old structs and their to_node() / guidance_nodes() impls are fully removed. No #[deprecated], no #[allow(dead_code)], no transitional shims. This is exactly the right pattern for this codebase.
  • Type-level idempotency is preserved: seed_nodes_from_templates uses the same HashSet-keyed-by-root-node_type strategy as the old seed_nodes_if_needed, so the semantics are unchanged for fresh installs.
  • assemble_static is functionally equivalent: The priority sort and template_syntax dispatch both correctly migrate from typed fields to JSON property lookups, and the fallback chain (content → markdown_content) correctly resolves for all six prompt seeds (all of which supply content: Some(...)).
  • Integration tests updated correctly: tools_for_skill and build_schema_creation_prompt in ollama_integration.rs both migrate cleanly to the new field paths.
  • Tracing is improved: The new logging separates created_roots from created_children, which will make debugging partial-seed failures noticeably easier.
  • Documentation quality: NodeTemplate has clear field-level docs and a working ````ignore` example. The module-level block comment explaining what was replaced and why is appropriate.

Verdict

Request changes on the stale comment (the diff-check comment in db.rs claims to cover guidance content propagation but no longer does). The remaining items are improvements and nits that do not block correctness for a zero-user installation, but the misleading comment is a maintenance hazard that should be fixed before merge.

- Fix stale comment "all 7 skills" → "all 8 skills" in skill_pipeline.rs tests
- Fix misleading comment in db.rs: clarify only prompt roots are diff-checked
  after seed, skill guidance children are intentionally user-editable
- Update NodeTemplate doc example to include `content: None` for skill pattern
  and add second example showing `content: Some(...)` for prompt pattern
- Add 7 unit tests for `prepare_nodes_from_template` in markdown_test.rs
  covering: no-child skill, guidance children, child_properties merge,
  prompt content override, title fallback, property replacement, root_properties

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio

malibio commented Apr 11, 2026

Copy link
Copy Markdown
Collaborator Author

Address Review Summary

All reviewer recommendations addressed. Changes pushed in commit 52cb648a.

✅ Addressed (4 items)

🟡 Fix stale comment in skill_pipeline.rs
packages/agent/src/skill_pipeline.rs — Updated // --- Skill whitelist tests for all 7 skills --- → // --- Skill whitelist tests for all 8 skills ---

🟡 Fix misleading comment in db.rs
packages/desktop-app/src-tauri/src/commands/db.rs — Clarified that only prompt root nodes are diff-checked after initial seed; skill guidance children are intentionally left as user-editable (not a gap in the implementation).

🟢 Improve NodeTemplate doc example
packages/core/src/mcp/handlers/markdown.rs — Added content: None to skill example and a second example showing the content: Some(...) prompt pattern, making the content override behavior self-documenting.

🟢 Add unit tests for prepare_nodes_from_template
packages/core/src/mcp/handlers/markdown_test.rs — Added 7 unit tests covering:

  • No-child skill (root only)
  • Skill with guidance children (markdown_content parsed into children)
  • child_properties merge into parsed nodes
  • Prompt with content: Some(...) override
  • Title fallback when content: None
  • Non-object child_properties replacement
  • root_properties injection on root node

⏭️ Skipped (1 item)

🟢 Set child_node_type/child_properties to None on childless skill templates
Skipped intentionally. The fields are already None on childless templates, and making the omission "explicit" by typing child_node_type: None, child_properties: None, on all 8 templates adds boilerplate without adding information. The struct derives have no default, so None must be explicit anyway — Rust's ..Default::default() pattern isn't available here. The recommendation was subjective style; skipping in favor of current ergonomics.

Test Status

All tests pass: 1170 core + 284 agent = 1454 total (no regressions).

Resolved conflict in skill_pipeline.rs: kept main branch's expanded
markdown_content for Research & Search skill which adds PARAMETER GUIDANCE
and LISTING BY TYPE OR PROPERTY sections.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@malibio
malibio merged commit 1e927cc into main Apr 11, 2026
@malibio
malibio deleted the feature/issue-1056-unify-seed-with-markdown-pipeline branch April 11, 2026 19:05
malibio added a commit that referenced this pull request Apr 14, 2026
…ompilation

- Merge split doc comment on ensure_model_ready so rustdoc sees a single block
- Add clarifying comment on explicit drop(guard) explaining lock ordering
- Extract build_noop_service() helper to deduplicate no-op construction
- Add doc comment on test explaining runtime difference from production path
- Fix agent_e2e skill pipeline tests: update NodeTemplate API (name→title,
  to_node()→prepare_nodes_from_template, extract whitelist/iterations from
  root_properties) after #1096 refactored NodeTemplate struct

Co-Authored-By: Claude <[email protected]>
malibio added a commit that referenced this pull request Apr 14, 2026
…ompilation (#1100)

- Merge split doc comment on ensure_model_ready so rustdoc sees a single block
- Add clarifying comment on explicit drop(guard) explaining lock ordering
- Extract build_noop_service() helper to deduplicate no-op construction
- Add doc comment on test explaining runtime difference from production path
- Fix agent_e2e skill pipeline tests: update NodeTemplate API (name→title,
  to_node()→prepare_nodes_from_template, extract whitelist/iterations from
  root_properties) after #1096 refactored NodeTemplate struct

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Apr 17, 2026
…ompilation (#1103)

- Merge split doc comment on ensure_model_ready so rustdoc sees a single block
- Add clarifying comment on explicit drop(guard) explaining lock ordering
- Extract build_noop_service() helper to deduplicate no-op construction
- Add doc comment on test explaining runtime difference from production path
- Fix agent_e2e skill pipeline tests: update NodeTemplate API (name→title,
  to_node()→prepare_nodes_from_template, extract whitelist/iterations from
  root_properties) after #1096 refactored NodeTemplate struct

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Apr 17, 2026
- Add additionalProperties hint to property_filters schema in def_search_semantic (guides LLM to generate string-valued objects)
- Add reverse parity check to search_semantic_schema_parity_with_params test (bidirectional guard against drift)
- Add doc comments to tmpl_* helper functions in agent_e2e.rs explaining they are adapters for NodeTemplate API change in #1096

Co-Authored-By: Claude <[email protected]>
malibio added a commit that referenced this pull request Apr 17, 2026
- Add additionalProperties hint to property_filters schema in def_search_semantic (guides LLM to generate string-valued objects)
- Add reverse parity check to search_semantic_schema_parity_with_params test (bidirectional guard against drift)
- Add doc comments to tmpl_* helper functions in agent_e2e.rs explaining they are adapters for NodeTemplate API change in #1096

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
* Unify skill/prompt seeding with markdown import pipeline (#1056)

Replaces the ad-hoc SeedSkill / SeedGuidancePrompt / SeedPrompt structs
and their bespoke to_node() conversions with a single NodeTemplate
abstraction backed by the existing prepare_nodes_from_markdown pipeline.

## What changed

### packages/core/src/mcp/handlers/markdown.rs
- Add `NodeTemplate` struct: title, optional content override, markdown_content,
  root_node_type, root_properties, child_node_type, child_properties
- Add `prepare_nodes_from_template()`: expands a template into a flat
  PreparedNode list (root + children) using the existing markdown parser

### packages/core/src/services/node_service.rs
- Add `seed_nodes_from_templates()`: inserts template-expanded node groups
  with the same type-level idempotency guarantee as the old seeding path
- Delete unused `seed_nodes_if_needed()` (replaced entirely)

### packages/agent/src/skill_pipeline.rs
- `seed_skill_nodes()` now returns `Vec<NodeTemplate>` instead of `Vec<SeedSkill>`
- Guidance text moves into `markdown_content`; skill metadata moves into
  `root_properties` (description, tool_whitelist, max_iterations, output_format)
- Delete `SeedSkill`, `SeedGuidancePrompt` structs and their impl blocks
- Tests updated to use NodeTemplate field access + prepare_nodes_from_template

### packages/agent/src/prompt_assembler.rs
- `seed_prompt_nodes()` now returns `Vec<NodeTemplate>` instead of `Vec<SeedPrompt>`
- Prompt body text stored in `content` field (overrides title as node content)
- `assemble_static()` updated to read priority/template_syntax from root_properties
- Delete `SeedPrompt` struct and its `to_node()` impl
- Tests updated accordingly

### packages/desktop-app/src-tauri/src/commands/db.rs
- Seeding block unified: expands all templates via prepare_nodes_from_template,
  inserts via seed_nodes_from_templates (single pass, no separate child loop)
- Prompt content diff-check preserved using template.content field

### packages/agent/tests/ollama_integration.rs
- tools_for_skill() and build_schema_creation_prompt() updated to use
  NodeTemplate field access (.title, .root_properties, .markdown_content)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <[email protected]>

* Address review: fix stale comment, improve docs, add template unit tests

- Fix stale comment "all 7 skills" → "all 8 skills" in skill_pipeline.rs tests
- Fix misleading comment in db.rs: clarify only prompt roots are diff-checked
  after seed, skill guidance children are intentionally user-editable
- Update NodeTemplate doc example to include `content: None` for skill pattern
  and add second example showing `content: Some(...)` for prompt pattern
- Add 7 unit tests for `prepare_nodes_from_template` in markdown_test.rs
  covering: no-child skill, guidance children, child_properties merge,
  prompt content override, title fallback, property replacement, root_properties

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>

---------

Co-authored-by: Michael Libio <[email protected]>
Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
…ompilation (#1100)

- Merge split doc comment on ensure_model_ready so rustdoc sees a single block
- Add clarifying comment on explicit drop(guard) explaining lock ordering
- Extract build_noop_service() helper to deduplicate no-op construction
- Add doc comment on test explaining runtime difference from production path
- Fix agent_e2e skill pipeline tests: update NodeTemplate API (name→title,
  to_node()→prepare_nodes_from_template, extract whitelist/iterations from
  root_properties) after #1096 refactored NodeTemplate struct

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
…ompilation (#1103)

- Merge split doc comment on ensure_model_ready so rustdoc sees a single block
- Add clarifying comment on explicit drop(guard) explaining lock ordering
- Extract build_noop_service() helper to deduplicate no-op construction
- Add doc comment on test explaining runtime difference from production path
- Fix agent_e2e skill pipeline tests: update NodeTemplate API (name→title,
  to_node()→prepare_nodes_from_template, extract whitelist/iterations from
  root_properties) after #1096 refactored NodeTemplate struct

Co-authored-by: Claude <[email protected]>
malibio added a commit that referenced this pull request Jun 22, 2026
- Add additionalProperties hint to property_filters schema in def_search_semantic (guides LLM to generate string-valued objects)
- Add reverse parity check to search_semantic_schema_parity_with_params test (bidirectional guard against drift)
- Add doc comments to tmpl_* helper functions in agent_e2e.rs explaining they are adapters for NodeTemplate API change in #1096

Co-authored-by: Claude <[email protected]>
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.

Unify skill/prompt seeding with markdown import pipeline

1 participant