Skip to content

Refactor skill node guidance to real markdown children; retire prompt type; expose skill in nav #1699

Closed

Description

@malibio

Overview

The skill node type's guidance body currently routes through a vestigial prompt-typed child node, a leftover from an earlier design that was never fully implemented. This issue implements the corrected node shape: skill guidance children become ordinary markdown nodes (the same shape every other document uses), the now-purposeless prompt node type is retired, and duplicate subtree-rendering logic is consolidated. A small, separable nav change (exposing skill in the left nav's Schemas section) is included since it depends on nothing else here.

Architecture Impact

This issue implements ADR-057 (nodespace-docs/decisions/057-skill-node-markdown-children.md), which formally supersedes ADR-030 (nodespace-docs/decisions/030-prompt-skill-node-architecture.md, now marked Status: Superseded). This is not a reversal of shipped behavior — ADR-030 was still Status: Proposed and was never fully implemented as originally specified (its skill→prompt-children shape and its prompt-as-agent-config-override role were never both built). ADR-057 closes out ADR-030's one remaining undecided half: the skill node's guidance-body shape and the prompt type's fate.

ADR-038 (nodespace-docs/decisions/038-skill-mediated-tool-routing.md, Status: Accepted) already superseded ADR-030's discovery mechanism (replaced the push-based pre-turn pipeline with the model-driven search_skills tool + LLM-judged routing) before this issue existed. This issue does not touch discovery — search_skills, find_skills, and the routing/gating logic in ADR-038 are unchanged and out of scope.

No companion nodespace-docs change is required as part of this implementation — ADR-057 and the ADR-030 status update are already written and pushed to nodespace-docs main as of this issue's creation.

Background

  • skill schema: packages/core/src/models/core_schemas.rs:880-941. Fields description (required, drives semantic-search discovery via find_skills), tool_whitelist (array), max_iterations (int). This schema is correct as-is and does not change.
  • prompt schema: packages/core/src/models/core_schemas.rs:866-879. Zero fields — schema-only, no behavior. Its only live use today is typing skill-guidance children (see below); ADR-030's other intended use (agent-config -[includes]-> prompt-node) was never implemented — no agent-config schema exists anywhere in core_schemas.rs, and no code creates or reads an includes edge.
  • seed_skill_nodes() (packages/agent/src/skill_pipeline.rs:227): builds each of the 8 seeded skills from a flat markdown_content: String field on the NodeTemplate, expanded via prepare_nodes_from_template (packages/core/src/markdown/mod.rs:1335) with child_node_type: Some("prompt".to_string()) — every seeded skill's guidance children are literally typed prompt, purely a vestige of ADR-030's original two-role design. Nothing about these children uses prompt-specific fields (there are none) or prompt-specific behavior.
  • PromptAssembler::assemble_with_skill() (packages/agent/src/prompt_assembler.rs:259-284): injects only skill.content (name) + description property into the system prompt as a short header. Confirmed dead code — zero callers anywhere in the repo (verified via full-repo grep; the only match is its own definition). This is a leftover from the push-based discovery design ADR-038 already replaced.
  • Skill guidance actually reaches the model via a separate, already-working path: search_skills tool (packages/agent/src/local_agent/tools.rs:573) → skill_ops::find_skills (packages/core/src/ops/skill_ops.rs:117) → render_skill_instructions/render_subtree_dfs (packages/core/src/ops/skill_ops.rs:54-101), which already walks the matched skill's full child subtree depth-first and returns it as an instructions field (skill_ops.rs:243,252) alongside name/description/tools/schema_metadata. This works correctly today, independent of child_node_type.
  • PromptAssembler::fetch_prompt_body() (packages/agent/src/prompt_assembler.rs:182-230) performs the same operation as render_skill_instructions above — subtree walk via get_subtree_data, depth-first, concatenate .content — but is a separate, independently-written implementation used for standalone prompt-root override nodes in the base-prompt-assembly path (PromptAssembler::assemble()). Its doc comment records a real bug this full-subtree-walk shape already fixed once (a direct-children-only flatten previously dropped bullets nested under a header line).

Scope of this issue

1. Skill guidance children become real markdown types

Change seed_skill_nodes() in packages/agent/src/skill_pipeline.rs so each of the 8 NodeTemplates uses child_node_type: None (or an explicit content type if markdown type-inference proves insufficient) instead of Some("prompt".to_string()), so guidance children come out as ordinary text/header nodes. markdown_content (the actual guidance prose) does not need to change. Verify prepare_nodes_from_markdown's type inference produces sensible header/text children for each of the 8 seeds' markdown structure.

2. Consolidate duplicate subtree-render logic

render_skill_instructions/render_subtree_dfs (packages/core/src/ops/skill_ops.rs:54-101) and PromptAssembler::fetch_prompt_body (packages/agent/src/prompt_assembler.rs:182-230) do the same thing independently. Extract one shared subtree-flattening utility in packages/core (e.g. near get_subtree_data, or a new small module) and have both find_skills and PromptAssembler::assemble() call it.

3. Retire the prompt node type

Delete the prompt core schema entirely (packages/core/src/models/core_schemas.rs:866-879) — it has zero remaining consumers once (1) lands. Do NOT delete PromptAssembler's graph-override mechanism itself (the hardcoded-base + graph-override assembly path in assemble()) — that mechanism is legitimate and currently working; it simply no longer has a dedicated node type backing it. If a future need for a queryable prompt-override node type resurfaces, it should be designed together with a real agent-config schema at that time, not kept as speculative unused schema now.

4. Delete dead code

Remove PromptAssembler::assemble_with_skill() (packages/agent/src/prompt_assembler.rs:259-284) — zero callers, confirmed via repo-wide grep. Skill guidance flows exclusively through search_skills → find_skills → the shared subtree utility from (2).

5. Update/verify tests

packages/agent/src/skill_pipeline.rs test module (seed_skills_have_valid_properties, seed_skill_template_produces_skill_node, all_skill_whitelist_tools_are_registered, and others in that module) assert on root_properties and root-node shape, not child node_type — expected to pass unchanged, but verify. Grep the codebase for any test asserting child_node_type == "prompt" or similar and update to the new content type. Grep for any other reference to the prompt schema/node type before deleting it (UI, MCP handlers, other seed paths) to confirm full removal is safe.

6. Nav exposure (small, separable)

Add 'skill' to SIDENAV_CORE_TYPES in packages/desktop-app/src/lib/stores/schemas.svelte.ts:24 (currently new Set(['task'])) so skill nodes appear as a browsable entry in the left nav's "Schemas" section. skill is already a registered core schema and the generic QueryNodeViewer/table-view browse mechanism already works for any schema id — this should require no new UI code, just the allowlist entry. Do NOT add prompt to this allowlist — prompt fragments out of context of their parent skill aren't useful to browse flatly, and the prompt type is being retired per item 3 anyway.

Explicitly out of scope

  • Skill discovery mechanism (search_skills tool, LLM-judged routing, retrieval gating) — settled by ADR-038, unchanged by this issue.
  • skill schema fields (description/tool_whitelist/max_iterations) — unchanged, already correct.
  • Any change to the 8 seeded skills' actual guidance text/content.

Acceptance Criteria

  • seed_skill_nodes() templates no longer route children through child_node_type: Some("prompt"); children are real markdown types
  • Shared subtree-flattening utility extracted and used by both find_skills (skill_ops.rs) and PromptAssembler::assemble() (prompt_assembler.rs)
  • prompt core schema deleted from core_schemas.rs
  • PromptAssembler::assemble_with_skill() deleted
  • All existing skill_pipeline.rs tests pass (or are updated if they assert on removed shape)
  • bun run test:all shows no new failures vs baseline
  • 'skill' added to SIDENAV_CORE_TYPES; skill nodes browsable in left nav Schemas section
  • prompt NOT added to nav (confirm it's fully retired, not just hidden)

Technical Specifications

Reference Files

  • packages/agent/src/skill_pipeline.rs:227 — seed_skill_nodes(), the 8 NodeTemplates to retype
  • packages/core/src/markdown/mod.rs:1335 — prepare_nodes_from_template, the expansion mechanism
  • packages/core/src/ops/skill_ops.rs:54-101 — render_skill_instructions/render_subtree_dfs, one half of the duplication to consolidate
  • packages/agent/src/prompt_assembler.rs:182-230 — fetch_prompt_body, the other half
  • packages/agent/src/prompt_assembler.rs:259-284 — assemble_with_skill, dead code to delete
  • packages/core/src/models/core_schemas.rs:866-879 — prompt schema to delete
  • packages/core/src/models/core_schemas.rs:880-941 — skill schema, unchanged, for reference
  • packages/desktop-app/src/lib/stores/schemas.svelte.ts:24 — SIDENAV_CORE_TYPES allowlist

Required Reading Before Implementation

  • nodespace-docs/decisions/057-skill-node-markdown-children.md (authoritative spec for this issue)
  • nodespace-docs/decisions/030-prompt-skill-node-architecture.md (Status: Superseded — historical context only)
  • nodespace-docs/decisions/038-skill-mediated-tool-routing.md (current discovery mechanism — do not touch, but understand it so as not to accidentally reintroduce push-based discovery)

Activity

  1. added
    enhancement
    on Jul 19, 2026
  2. mstomar125 commented on Jul 27, 2026

    @mstomar125
    Contributor

    ⚠️ Item 3's "zero remaining consumers" premise is incorrect — deferring items 2 & 3 pending a re-spec

    While implementing, I found the prompt node type still has a live production consumer, so retiring it as specified would ship a regression:

    • The daemon seeds prompt-typed nodes at startup — packages/daemon/src/services/assembly.rs:229 calls PromptAssembler::seed_prompt_nodes() (alongside skills/tools) and persists them.
    • PromptAssembler::fetch_prompt_overrides() (prompt_assembler.rs:120) queries node_type == "prompt" and injects those override bodies into the system prompt — and it runs every agent turn via assemble() (local_agent/agent_loop.rs:298, a live path, unlike the dead assemble_with_skill).

    So the graph-override mechanism the issue says to keep is backed by the prompt type. If the schema + PromptNodeBehavior are deleted (item 3), those seeded override nodes fall back to CustomNodeBehavior, whose default get_embeddable_content returns Some(content), and prompt is dropped from NON_EMBEDDABLE_CONTAINER_TYPES — so the internal system-prompt override nodes become embeddable/indexed → user semantic-search pollution. Item 2 (retyping skill guidance children from prompt→markdown) has the same implication: guidance children go from non-embeddable to embeddable.

    Retiring the prompt type needs a design decision this issue doesn't cover: how does PromptAssembler identify its override nodes without the prompt type (a different type? a property marker? a dedicated collection?), and should skill-guidance children be embeddable? That's the agent-config schema the issue itself gestures at ("if a future need for a queryable prompt-override node type resurfaces, it should be designed together with a real agent-config schema") — which turns out to be needed now, not later.

    What I'm shipping (a clean, non-conflicting subset)

    Items 1, 4, 6 are independent of the prompt-type question and have no embedding implications, so they go in now:

    • Item 1 — the duplicate subtree-render logic (render_subtree_dfs in skill_ops.rs + the manual walk in PromptAssembler::fetch_prompt_body) is consolidated into one shared flatten_subtree_content util in packages/core.
    • Item 4 — dead PromptAssembler::assemble_with_skill() deleted (zero callers).
    • Item 6 — 'skill' added to SIDENAV_CORE_TYPES (browsable in the left nav).

    Items 2 & 3 remain open here pending the re-spec above (migrate the PromptAssembler override mechanism off the prompt type + decide guidance-children embeddability). Keeping this issue open for that; happy to implement once the override-node replacement is decided.

  3. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Scope addition: rewrite skill descriptions for semantic retrieval

    Folding in a finding from the prompting spike (#1802), because it edits the same function this issue rewrites — seed_skill_nodes() in packages/agent/src/skill_pipeline.rs. Two issues touching that function would conflict.

    The finding

    Skill description properties are the index keys for semantic retrieval — they are embedded and matched against an embedding of the user's message. They are currently written as keyword/trigger-phrase lists ("Use when user says 'new type', 'node type', 'create schema'"), which are artifacts of ADR-030's pattern-match routing that ADR-038 replaced. Users never say those words, so the descriptions index against nothing real.

    Measured, 20 indirect intents against the 8 seeded skills with the production embedding model:

    descriptions rank-1 top-3
    as shipped 35% 50%
    rewritten for semantic matching 75% 95%

    One specific pathology: bulk_import won 6 of 13 mis-routes, including "mark the Camden invoice as paid". Its generic verbs (create/add/import) make it a semantic attractor that swallows unrelated intents. Rewriting must narrow attractor skills specifically, not just polish prose across the board.

    This is now doctrine — see ADR-064 rule 3 (skill descriptions own retrieval matching, a distinct writing target from tool descriptions, which own tool selection).

    Correction to this issue's Background section

    This issue currently states that skill guidance reaching the model via search_skills → render_skill_instructions "works correctly today". That claim is now under question. Delivering instructions as a tool result is exactly the mechanism suspected of suppressing tool-calling — see #1814, and ADR-038's full-subtree provision is marked Provisional pending that result. The path works in the sense that the text arrives; whether arriving that way is correct is unresolved.

    No change to this issue's scope follows from that — it does not touch discovery — but the Background should not assert correctness that measurement is currently disputing.

    Added acceptance criteria

    • All 8 seeded skill descriptions rewritten as natural descriptions of the situation the skill applies to, not trigger-phrase lists
    • Attractor skills (bulk_import, and any other built from generic verbs) narrowed so they stop capturing unrelated intents
    • Retrieval measured on the 20-intent set: rank-1 ≥ 75%, top-3 ≥ 95%
    • A retrieval regression test pins that set, so descriptions cannot silently regress

    Sequencing

    Blocked on #1812 for delivery: seed_nodes_from_templates skips by node type, so a rewritten description reaches no existing install. Without #1812 the acceptance measurement would only be verifiable on a purged database, which is not the shipping configuration.

  4. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Status check on items 2 & 3

    Re-verified current main (as of dde8b9d) against this issue's remaining scope.

    Confirmed already shipped (previous comment's "clean subset"):

    • Item 4 — PromptAssembler::assemble_with_skill() is gone; zero matches for assemble_with_skill anywhere in packages/agent/src/.
    • Item 6 — SIDENAV_CORE_TYPES in schemas.svelte.ts:24 is now new Set(['task', 'project', 'skill']). prompt correctly absent.
    • Item 1 (skill children → real markdown types) — not yet done. skill_pipeline.rs still sets child_node_type: Some("prompt".to_string()) for all 8 seeded skills.

    Items 2 & 3 remain blocked, same reason as before. ADR-057 (Accepted, in nodespace-docs) reaffirms the what (skill children become markdown, prompt schema gets deleted) but doesn't resolve the how the previous comment flagged:

    • PromptAssembler::fetch_prompt_overrides() (prompt_assembler.rs:120) still queries node_type == "prompt" and still runs every agent turn via assemble() (prompt_assembler.rs:84, called from the live local_agent/agent_loop.rs path).
    • PromptAssembler::seed_prompt_nodes() (prompt_assembler.rs:260) is still called from packages/daemon/src/services/assembly.rs:229 at daemon startup, persisting prompt-typed override nodes.
    • prompt is still in NON_EMBEDDABLE_CONTAINER_TYPES (packages/core/src/behaviors/mod.rs:167), which is the only thing currently keeping these override nodes (and, if item 1 ships as originally spec'd, skill-guidance children) out of semantic search.

    Deleting the prompt schema today, as item 3 asks, would fall back these nodes to CustomNodeBehavior's default embeddable behavior — the exact regression the prior comment described. ADR-057 explicitly punts this ("if a future need... resurfaces, it should be designed against its actual use case... rather than kept as unused schema surface now") without naming what PromptAssembler should key off of instead, or resolving whether skill-guidance children should be embeddable post-retype.

    Item 1 is separable and unblocked — it only touches seed_skill_nodes()'s child_node_type, doesn't touch the prompt schema, and doesn't change embeddability of anything that isn't already going to be markdown-typed. It could ship now if desired, ahead of the item 2/3 design work, since render_skill_instructions already walks children generically by edge, not by type.

    Holding items 2 & 3 open pending a design decision on the replacement identifier for PromptAssembler's override nodes (a dedicated marker/property vs. a minimal real agent-config schema) and the embeddability question for both override nodes and (if item 1 ships as spec'd) skill-guidance children. Let me know how you'd like to sequence this — happy to ship item 1 alone now, or hold everything for a combined design pass.

  5. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Ship item 1 now — agreed it's separable and safe on the argument you gave (children walked by edge, not type; nothing about the retype touches prompt or NON_EMBEDDABLE_CONTAINER_TYPES).

    On items 2/3's blocker

    The real issue isn't "how do we key PromptAssembler's override nodes" in isolation — it's that non-embeddability is currently an implicit side effect of type membership rather than an explicit property. prompt happens to sit in NON_EMBEDDABLE_CONTAINER_TYPES, so anything typed prompt gets the exemption for free, and anything that stops being typed prompt silently loses it. That's the same shape as the coreValues/core_values and TOOL_STRATEGY_RULES findings from the prompting spike (#1802) — a property riding on the wrong channel, discovered only when something downstream changes and the implicit link breaks.

    So I'd rather not solve this by finding a new type tag to carry the same implicit behavior (a minimal agent-config schema would just relocate the trap). Make non-embeddability an explicit property on the node, not a type-membership lookup:

    • Add something like is_embeddable: bool (default true) to the node model, or a NodeBehavior::default_embeddable() override per behavior, however fits the existing behavior trait shape best
    • PromptAssembler::fetch_prompt_overrides() keys off a stable identifier that isn't node_type == "prompt" — a dedicated marker property (e.g. is_prompt_override: true) or a fixed collection/root marker, whichever is less invasive given how seed_prompt_nodes() currently creates these
    • NON_EMBEDDABLE_CONTAINER_TYPES either goes away in favor of the per-node property, or stays as a type-level default that the per-node property can override — but not as the sole mechanism

    This also directly answers the "skill-guidance children post-retype" half of the question: once they're real markdown types, their embeddability is whatever markdown nodes default to, checked against whether that's actually what you want (probably yes — skill instructions arguably should be discoverable by the same retrieval that struggles with skill descriptions per #1802/#1699's other half, but that's worth a deliberate yes rather than an inherited default).

    Sequencing

    1. Ship item 1 now, unblocked
    2. Add the explicit embeddability property (small, mechanical, no behavior change if defaults preserve current semantics)
    3. Re-point PromptAssembler at the new marker instead of node_type == "prompt"
    4. Delete the prompt schema (item 3) — now safe, nothing depends on the type tag anymore
    5. Decide skill-guidance-children embeddability deliberately, not by default

    Steps 2-3 are a small standalone change if you want to split them out rather than doing the whole design pass at once — happy to file that as its own issue if it's cleaner to track separately from this one's remaining scope.

  6. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Correction to my last comment — no new property needed

    Checked before assuming: NodeBehavior already has the right hook — get_embeddable_content(&self, node: &Node) -> Option<String> (behaviors/mod.rs:296, default: embed if content non-empty, per-behavior override). SkillBehavior already overrides it correctly.

    The actual bug is that two independent mechanisms gate embeddability, and only one of them goes through the trait:

    • get_embeddable_content — per-behavior, extensible, principled
    • NON_EMBEDDABLE_CONTAINER_TYPES (behaviors/mod.rs:167) — a flat &[&str] checked directly against node_type in db/sqlite_store/embeddings.rs and services/node_service/mod.rs, bypassing the trait entirely

    prompt sits in the second list, not expressed through the first. That's the actual trap, and it's narrower than what I proposed before: not "add a persisted property," but delete the parallel gate and route everything through the trait method that already exists.

    Revised plan:

    1. Whatever behavior backs prompt-typed nodes overrides get_embeddable_content to return None — same pattern as SkillBehavior
    2. Delete NON_EMBEDDABLE_CONTAINER_TYPES; its two call sites go through the behavior registry's get_embeddable_content instead of a node_type string check
    3. At that point deleting the prompt schema (item 3) doesn't touch embeddability at all — it was only ever gated there through the second, bypassable mechanism

    That leaves exactly one open question, smaller than before: PromptAssembler::fetch_prompt_overrides()'s node_type == "prompt" lookup is a genuine identity question (which nodes are prompt-override nodes), not an embeddability one, and does need a replacement marker once the schema is gone. But it's now a single, well-scoped problem rather than two entangled ones.

    Sequencing unchanged: ship item 1 now; do the NON_EMBEDDABLE_CONTAINER_TYPES consolidation as its own small change (steps 1-2 above); then item 3 is safe; then decide the PromptAssembler marker and skill-guidance-children embeddability deliberately.

  7. malibio commented on Jul 30, 2026

    @malibio
    CollaboratorAuthor

    Frontend baseline: 171 test files passed, 4112 tests passed.

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

Metadata

Metadata

Assignees

Labels

enhancementfoundation

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions