- Agent roles integration progress - Various backend and frontend updates - Storybook cache cleanup 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
85 lines
3.3 KiB
Python
85 lines
3.3 KiB
Python
"""
|
|
Context Feedback model for RL Context Curator integration
|
|
"""
|
|
|
|
from sqlalchemy import Column, String, Text, Integer, DateTime, ForeignKey, UUID as SqlUUID, Float
|
|
from sqlalchemy.sql import func
|
|
from sqlalchemy.orm import relationship
|
|
from ..core.database import Base
|
|
import uuid
|
|
|
|
|
|
class ContextFeedback(Base):
|
|
__tablename__ = "context_feedback"
|
|
|
|
# Primary identification
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
|
|
# Context and agent information
|
|
context_id = Column(String(255), nullable=False, index=True) # HCFS context ID
|
|
agent_id = Column(String(255), ForeignKey("agents.id"), nullable=False)
|
|
task_id = Column(SqlUUID(as_uuid=True), ForeignKey("tasks.id"), nullable=True)
|
|
|
|
# Feedback details
|
|
feedback_type = Column(String(50), nullable=False) # upvote, downvote, forgetfulness, task_success, task_failure
|
|
role = Column(String(100), nullable=False) # Agent role when feedback was given
|
|
confidence = Column(Float, nullable=False) # Confidence in feedback (0.0 to 1.0)
|
|
reason = Column(Text, nullable=True) # Optional reason for feedback
|
|
usage_context = Column(String(255), nullable=True) # Context of usage (debugging, coding, etc.)
|
|
|
|
# Additional metadata
|
|
directory_scope = Column(String(500), nullable=True) # Directory where context was used
|
|
task_type = Column(String(100), nullable=True) # Type of task being performed
|
|
|
|
# Timestamps
|
|
timestamp = Column(DateTime(timezone=True), server_default=func.now())
|
|
|
|
# Relationships
|
|
agent = relationship("Agent", back_populates="context_feedback")
|
|
task = relationship("Task", backref="context_feedback")
|
|
|
|
|
|
class AgentPermissions(Base):
|
|
__tablename__ = "agent_permissions"
|
|
|
|
# Primary identification
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
|
|
# Agent and role information
|
|
agent_id = Column(String(255), ForeignKey("agents.id"), nullable=False, index=True)
|
|
role = Column(String(100), nullable=False)
|
|
|
|
# Permission details
|
|
directory_patterns = Column(Text, nullable=True) # JSON array of path patterns
|
|
task_types = Column(Text, nullable=True) # JSON array of allowed task types
|
|
context_weight = Column(Float, default=1.0) # Weight for context relevance
|
|
|
|
# Status
|
|
active = Column(String(10), default='true') # String to match existing boolean patterns
|
|
|
|
# Timestamps
|
|
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
|
updated_at = Column(DateTime(timezone=True), server_default=func.now(), onupdate=func.now())
|
|
|
|
# Relationships
|
|
agent = relationship("Agent", back_populates="permissions")
|
|
|
|
|
|
class PromotionRuleHistory(Base):
|
|
__tablename__ = "promotion_rule_history"
|
|
|
|
# Primary identification
|
|
id = Column(Integer, primary_key=True, index=True)
|
|
|
|
# Rule information
|
|
rule_version = Column(String(50), nullable=False)
|
|
category = Column(String(100), nullable=False)
|
|
role = Column(String(100), nullable=False)
|
|
weight_value = Column(Float, nullable=False)
|
|
|
|
# Change information
|
|
change_reason = Column(Text, nullable=True)
|
|
previous_value = Column(Float, nullable=True)
|
|
|
|
# Timestamps
|
|
timestamp = Column(DateTime(timezone=True), server_default=func.now()) |