WIP: Save current work before CHORUS rebrand
- 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>
This commit is contained in:
@@ -2,4 +2,5 @@ from . import agent
|
||||
from . import agent_role
|
||||
from . import project
|
||||
from . import task
|
||||
from . import context_feedback
|
||||
from . import sqlalchemy_models
|
||||
@@ -34,6 +34,8 @@ class Agent(Base):
|
||||
|
||||
# Relationships
|
||||
tasks = relationship("Task", back_populates="assigned_agent")
|
||||
context_feedback = relationship("ContextFeedback", back_populates="agent")
|
||||
permissions = relationship("AgentPermissions", back_populates="agent")
|
||||
|
||||
def to_dict(self):
|
||||
return {
|
||||
|
||||
85
backend/app/models/context_feedback.py
Normal file
85
backend/app/models/context_feedback.py
Normal file
@@ -0,0 +1,85 @@
|
||||
"""
|
||||
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())
|
||||
@@ -2,7 +2,7 @@
|
||||
Task model for SQLAlchemy ORM
|
||||
"""
|
||||
|
||||
from sqlalchemy import Column, String, Text, Integer, DateTime, ForeignKey, UUID as SqlUUID
|
||||
from sqlalchemy import Column, String, Text, Integer, DateTime, ForeignKey, UUID as SqlUUID, Float, Boolean
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.sql import func
|
||||
from sqlalchemy.orm import relationship
|
||||
@@ -30,6 +30,17 @@ class Task(Base):
|
||||
# Task metadata (includes context and payload)
|
||||
task_metadata = Column("metadata", JSONB, nullable=True)
|
||||
|
||||
# RL Context Curator outcome tracking fields
|
||||
completion_time = Column(Integer, nullable=True) # Time to complete in seconds
|
||||
errors_encountered = Column(Integer, default=0) # Number of errors during execution
|
||||
follow_up_questions = Column(Integer, default=0) # Number of follow-up questions
|
||||
success_rate = Column(Float, nullable=True) # Success rate (0.0 to 1.0)
|
||||
context_used = Column(JSONB, nullable=True) # Context IDs used in this task
|
||||
context_relevance_score = Column(Float, nullable=True) # Average relevance of used context
|
||||
feedback_collected = Column(Boolean, default=False) # Whether feedback was collected
|
||||
task_outcome = Column(String(50), nullable=True) # completed, failed, abandoned
|
||||
outcome_confidence = Column(Float, nullable=True) # Confidence in outcome classification
|
||||
|
||||
# Timestamps
|
||||
created_at = Column(DateTime(timezone=True), server_default=func.now())
|
||||
started_at = Column(DateTime(timezone=True), nullable=True)
|
||||
|
||||
Reference in New Issue
Block a user