Skip to content

feat(knowledge): User ownership model for chat-derived knowledge #688

Closed

Description

@mrveiss

Summary

Implement user ownership and sharing model for knowledge base facts derived from chat conversations.

Problem

Currently, KB facts from chats are only tagged with session_id but have no user ownership or sharing model. When a conversation is shared, there's no mechanism to share the associated knowledge. Users cannot filter "my knowledge" vs "shared with me".

Proposed Solution

New Metadata Fields for Facts

metadata = {
    # Existing
    "source_session_id": "uuid",
    "category": "chat_knowledge",      # New category
    
    # NEW: Ownership
    "owner_id": "user_id",
    "visibility": "private",          # private | shared | public
    
    # NEW: Sharing
    "shared_with": ["user_id1", "user_id2"],
    "shared_via_session": "session_id",
    
    # NEW: Source tracking
    "source_type": "chat",            # chat | manual | import | system
    "created_by": "user_id",
}

New Redis Indexes

user:kb:facts:{user_id}           -> Set of fact IDs owned by user
user:kb:shared:{user_id}          -> Set of fact IDs shared with user
kb:category:chat_knowledge        -> Set of all chat-derived facts

Access Control

  • Owner always has access
  • Public facts accessible to all
  • Check explicit shares list
  • Check session-based sharing

Acceptance Criteria

  • Facts created from chat are automatically tagged with owner_id
  • Default visibility is "private"
  • Access control enforced on all KB queries
  • Redis indexes created for efficient user-based queries

Related Issues

Technical Notes

  • Backend: src/knowledge/facts.py - Add ownership fields
  • Backend: autobot-user-autobot-user-backend/api/knowledge.py - Add access control to queries
  • Affects: Knowledge search, fact retrieval, orphan cleanup

Activity

  1. mrveiss commented on Feb 11, 2026

    @mrveiss
    OwnerAuthor

    Merged via PR #845. User ownership model for chat-derived knowledge: ownership.py module, 5 API endpoints (share/unshare/visibility/mine/shared-with-me), Redis indexes (user:kb:facts, user:kb:shared, kb:category:chat_knowledge), auto-tagging chat facts with owner_id, access control on queries. +1,010/-27 lines, 7 files.

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions