Skip to content

Exclude ai-chat nodes from embedding/vectorization #1696

Closed

Description

@malibio

Overview

AI-chat conversation nodes are currently embedded and made semantically searchable. This should stop — ai-chat nodes should not be vectorized at all.

Architecture Impact

This reverses ADR-029 (decisions/029-behavior-owned-embedding.md, Status: Accepted), which explicitly decided: "AI chat nodes are embeddable but excluded from default search via SearchScope::Knowledge." ADR-029's table of per-type behavior explicitly lists ai-chat as extracting "user+assistant text from properties.messages[]" for get_embeddable_content() (Accepted, 2026-04-03).

This issue changes that decision from "embeddable, but hidden from default search" to "not embeddable at all." A companion nodespace-docs change is required: update ADR-029's per-type behavior table and its SearchScope::Conversations/Everything discussion to reflect that ai-chat no longer produces embeddings, since SearchScope::Conversations (searching conversations explicitly) becomes a dead/no-op scope once ai-chat stops embedding. Commit that edit directly to nodespace-docs main (per that repo's own workflow — no branch/PR needed there).

Problem Statement

AiChatNodeBehavior::get_embeddable_content() (packages/core/src/behaviors/mod.rs:1609-1619) currently extracts and returns concatenated user/assistant message text from properties.messages[], so every ai-chat node with messages is embedded and indexed like any other content. A test at packages/core/src/behaviors/mod.rs:4479-4482 explicitly asserts "ai-chat with messages should be embeddable" — codifying the ADR-029 behavior this issue reverses.

Per CLAUDE.md's decision tree, embeddability for built-in node types is entirely behavior-trait-owned (no schema flag exists for this), so this is a Core hardcoded-behavior change in packages/core/src/behaviors/mod.rs.

Proposed Solution

Change AiChatNodeBehavior::get_embeddable_content() to return None unconditionally, so ai-chat nodes are never embedded. Update the now-inverted test assertion at mod.rs:4479-4482 to assert non-embeddability instead, and search for any other tests or SearchScope handling that assume ai-chat embeddability (e.g. SearchScope::Conversations/SearchScope::Everything in the search-scope enum referenced by ADR-029) and update them consistently.

No change needed to NON_EMBEDDABLE_CONTAINER_TYPES (mod.rs:167) — that const list is only for child-bearing container types used in the BM25 ancestor-walk CTE (packages/core/src/db/sqlite_store/embeddings.rs:645). Ai-chat nodes have can_have_children() == false, so they are not part of that walk-stop mechanism; only get_embeddable_content() needs to change.

Acceptance Criteria

  • AiChatNodeBehavior::get_embeddable_content() returns None for all ai-chat nodes
  • Newly created or updated ai-chat nodes produce no embeddings going forward
  • No migration of existing embeddings is needed — this is a pre-release app with no production data (per CLAUDE.md); stale ai-chat embeddings, if any exist in dev databases, are simply never regenerated
  • Test at mod.rs:4479-4482 updated to assert non-embeddability
  • Any SearchScope variants/tests assuming ai-chat is embeddable (Conversations, Everything) updated to reflect the new behavior
  • Tests pass (bun run test:all)
  • Code passes bun run quality:fix

Technical Specifications

Reference Files

  • behaviors/mod.rs: packages/core/src/behaviors/mod.rs:1609-1619 — AiChatNodeBehavior::get_embeddable_content(), the method to change
  • behaviors/mod.rs: packages/core/src/behaviors/mod.rs:4479-4482 — existing test asserting current (to-be-reversed) embeddability
  • behaviors/mod.rs: packages/core/src/behaviors/mod.rs:167 — NON_EMBEDDABLE_CONTAINER_TYPES const, confirmed out of scope for this change

Implementation Details

Follow the ADR-029 pattern used by types that already return None (e.g. task, date, collection per ADR-029's behavior table) — get_embeddable_content() for ai-chat should mirror those, dropping the properties.messages[] extraction entirely rather than extracting and discarding.

Related Issues

Activity

  1. added
    bug
    on Jul 19, 2026
  2. added a commit that references this issue on Jul 24, 2026
    a93754a
  3. mstomar125 commented on Jul 24, 2026

    @mstomar125
    Contributor

    ✅ Completed — merged in PR #1733

    AI-chat conversation nodes are no longer embedded or vectorized. AiChatNodeBehavior::get_embeddable_content() returns None unconditionally, so conversations never enter the vector index and never surface in semantic search.

    Changes:

    • behaviors/mod.rs — get_embeddable_content() → None; doc comments updated; the two obsolete extraction tests consolidated into test_ai_chat_node_never_embeddable (asserts None for rich / empty / tool-only / no-messages shapes); matrix assertion flipped to is_none().
    • embedding_service.rs — flipped the ai-chat assertion in test_behavior_driven_embedding_decision; noted SearchScope::Conversations is now a no-op at matches_scope.
    • agent/local_agent/tools.rs + agent/skill_pipeline.rs — removed conversations from the search_nodes tool schema and the skill guidance, so the model is no longer steered to a scope that returns nothing (surfaced in review). The core SearchScope::Conversations enum variant is retained as a documented no-op for API stability.
    • Cargo.lock — drive-by: committed the sha2 entry for nodespace-nlp-engine that Build-time model download (scripts/download-models.ts) skips SHA-256 verification #1715's Cargo.toml change left uncommitted (root lockfile wasn't staged), which would have broken --locked/release builds.

    Docs: ADR-029 revised directly on nodespace-docs main — Revision note + per-type table (ai-chat → None) + SearchScope section updated.

    Notes:

    • NON_EMBEDDABLE_CONTAINER_TYPES unchanged (ai-chat isn't a container type; can_have_children() is false, so the container-parity test is unaffected).
    • Existing ai-chat embeddings are cleaned up by the normal pipeline: returning None triggers the embedding service's delete-existing-embeddings path on reprocess (greenfield — no migration).

    Verification:

    • cargo test -p nodespace-core --lib: 966 passed; agent scope + skill tests green; cargo clippy (core + agent): clean; full pre-push gate green.
    • Independent adversarial review: crate-wide, no test breaks; container-parity and consolidated-test correctness verified; the agent-scope gap it found is fixed in this PR.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugfoundation

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions