# Structured Learnings Schema (v1)

## Data Model

| Field | Type | Description |
|-------|------|-------------|
| **ID** | string | Stable learning identifier |
| **Category** | enum | `correction`, `insight`, `knowledge_gap`, `best_practice` |
| **Area** | enum | `frontend`, `backend`, `infra`, `tests`, `docs`, `config`, `other` |
| **Status** | enum | `pending`, `in_progress`, `resolved`, `wont_f` |
| **Priority** | string | e.g., `low`, `medium`, `high` |
| **Summary** | string | Brief description |
| **Details** | string | Full description / context |
| **ProjectID** | string (optional) | Reference to a project |
| **ThoughtID** | string (optional) | Reference to a thought |
| **SkillID** | string (optional) | Reference to a skill |
| **CreatedAt** | timestamp | Creation timestamp |
| **UpdatedAt** | timestamp | Last update timestamp |

## Suggested SQL Definition

```sql
CREATE TABLE learnings (
    id UUID PRIMARY KEY,
    category TEXT NOT NULL,
    area TEXT NOT NULL,
    status TEXT NOT NULL,
    priority TEXT,
    summary TEXT,
    details TEXT,
    project_id UUID,
    thought_id UUID,
    skill_id UUID,
    created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW(),
    updated_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
```

## Tool Surface (MCP)

- `create_learning` – insert a new learning record  
- `list_learnings` – query with optional filters (category, area, status, project, etc.)  
- `get_learning` – retrieve a single learning by ID  
- `update_learning` – modify fields (e.g., status, priority) and/or links  

## Enums (Go)

```go
type LearningCategory string
const (
    LearningCategoryCorrection LearningCategory = "correction"
    LearningCategoryInsight    LearningCategory = "insight"
    LearningCategoryKnowledgeGap LearningCategory = "knowledge_gap"
    LearningCategoryBestPractice LearningCategory = "best_practice"
)

type LearningArea string
const (
    LearningAreaFrontend      LearningArea = "frontend"
    LearningAreaBackend       LearningArea = "backend"
    LearningAreaInfra         LearningArea = "infra"
    LearningAreaTests         LearningArea = "tests"
    LearningAreaDocs          LearningArea = "docs"
    LearningAreaConfig        LearningArea = "config"
    LearningAreaOther         LearningArea = "other"
)

type LearningStatus string
const (
    LearningStatusPending      LearningStatus = "pending"
    LearningStatusInProgress   LearningStatus = "in_progress"
    LearningStatusResolved     LearningStatus = "resolved"
    LearningStatusWontF        LearningStatus = "wont_f"
)
```

Let me know if this alignment works or if you’d like any adjustments before I proceed with the implementation.