Create Issue entity with external tracker fields #26

Closed
opened 2025-12-29 23:47:12 +00:00 by cardosofelipe · 0 comments

Description

Implement Issue entity that syncs with external trackers (Gitea, GitHub, GitLab).

Requirements

Entity Fields

class Issue(Base):
    id: UUID
    project_id: UUID  # FK to Project

    # Local Fields
    title: str
    body: str
    status: IssueStatus
    priority: IssuePriority
    labels: List[str]  # JSON array

    # Assignment
    assigned_agent_id: Optional[UUID]  # FK to AgentInstance
    human_assignee: Optional[str]

    # Sprint
    sprint_id: Optional[UUID]  # FK to Sprint
    story_points: Optional[int]

    # External Tracker Sync (per ADR-009)
    external_tracker: Optional[str]  # 'gitea', 'github', 'gitlab'
    external_id: Optional[str]  # Issue ID in external system
    external_url: Optional[str]  # Direct link
    external_number: Optional[int]  # Issue number
    sync_status: SyncStatus
    last_synced_at: Optional[datetime]
    external_updated_at: Optional[datetime]  # Conflict detection

    # Timestamps
    created_at: datetime
    updated_at: datetime
    closed_at: Optional[datetime]

Enums

class IssueStatus(str, Enum):
    OPEN = "open"
    IN_PROGRESS = "in_progress"
    IN_REVIEW = "in_review"
    BLOCKED = "blocked"
    CLOSED = "closed"

class IssuePriority(str, Enum):
    LOW = "low"
    MEDIUM = "medium"
    HIGH = "high"
    CRITICAL = "critical"

class SyncStatus(str, Enum):
    SYNCED = "synced"
    PENDING = "pending"
    CONFLICT = "conflict"
    ERROR = "error"

CRUD Operations

  • Standard CRUD
  • get_by_external_id(db, tracker, external_id) -> Optional[Issue]
  • get_pending_sync(db, project_id: UUID) -> List[Issue]
  • get_by_sprint(db, sprint_id: UUID) -> List[Issue]
  • get_assigned_to_agent(db, agent_id: UUID) -> List[Issue]

Tests

  • CRUD operations
  • External sync field handling
  • Sprint assignment
  • Agent assignment

Acceptance Criteria

  • Model with all fields
  • Migration created
  • CRUD operations
  • Conflict detection logic
  • Pydantic schemas
  • Unit tests with >90% coverage

Technical Notes

  • Reference: ADR-009 (Issue synchronization)
  • Reference: SPIKE-009 (Issue synchronization research)
  • external_updated_at used for conflict detection

Dependencies

  • Depends on: #23 (Project)

Assignable To

backend-engineer agent

## Description Implement Issue entity that syncs with external trackers (Gitea, GitHub, GitLab). ## Requirements ### Entity Fields ```python class Issue(Base): id: UUID project_id: UUID # FK to Project # Local Fields title: str body: str status: IssueStatus priority: IssuePriority labels: List[str] # JSON array # Assignment assigned_agent_id: Optional[UUID] # FK to AgentInstance human_assignee: Optional[str] # Sprint sprint_id: Optional[UUID] # FK to Sprint story_points: Optional[int] # External Tracker Sync (per ADR-009) external_tracker: Optional[str] # 'gitea', 'github', 'gitlab' external_id: Optional[str] # Issue ID in external system external_url: Optional[str] # Direct link external_number: Optional[int] # Issue number sync_status: SyncStatus last_synced_at: Optional[datetime] external_updated_at: Optional[datetime] # Conflict detection # Timestamps created_at: datetime updated_at: datetime closed_at: Optional[datetime] ``` ### Enums ```python class IssueStatus(str, Enum): OPEN = "open" IN_PROGRESS = "in_progress" IN_REVIEW = "in_review" BLOCKED = "blocked" CLOSED = "closed" class IssuePriority(str, Enum): LOW = "low" MEDIUM = "medium" HIGH = "high" CRITICAL = "critical" class SyncStatus(str, Enum): SYNCED = "synced" PENDING = "pending" CONFLICT = "conflict" ERROR = "error" ``` ### CRUD Operations - Standard CRUD - `get_by_external_id(db, tracker, external_id) -> Optional[Issue]` - `get_pending_sync(db, project_id: UUID) -> List[Issue]` - `get_by_sprint(db, sprint_id: UUID) -> List[Issue]` - `get_assigned_to_agent(db, agent_id: UUID) -> List[Issue]` ### Tests - CRUD operations - External sync field handling - Sprint assignment - Agent assignment ## Acceptance Criteria - [ ] Model with all fields - [ ] Migration created - [ ] CRUD operations - [ ] Conflict detection logic - [ ] Pydantic schemas - [ ] Unit tests with >90% coverage ## Technical Notes - Reference: ADR-009 (Issue synchronization) - Reference: SPIKE-009 (Issue synchronization research) - `external_updated_at` used for conflict detection ## Dependencies - Depends on: #23 (Project) ## Assignable To backend-engineer agent
cardosofelipe added the backenddatabasephase-1 labels 2025-12-29 23:49:58 +00:00
Sign in to join this conversation.