@polymorphism-tech/morph-spec 4.5.0 → 4.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/.morph/.morphversion +3 -3
  2. package/.morph/analytics/threads-log.jsonl +6 -44
  3. package/.morph/config/config.json +1 -1
  4. package/.morph/framework/standards/frontend/nextjs/nextjs-patterns.md +17 -0
  5. package/.morph/framework/templates/docs/user-stories.md +34 -0
  6. package/.morph/logs/tool-failures.log +7 -51
  7. package/.morph/memory/{pre-compact-2026-02-22T17-01-01-658Z.json → pre-compact-2026-02-23T15-43-03-521Z.json} +1 -1
  8. package/CLAUDE.md +77 -56
  9. package/framework/{skills/level-2-domains → agents}/ai-agents/ai-system-architect.md +1 -4
  10. package/framework/{skills/level-2-domains → agents}/architecture/po-pm-advisor.md +1 -2
  11. package/framework/{skills/level-2-domains → agents}/architecture/prompt-engineer.md +1 -2
  12. package/framework/{skills/level-2-domains → agents}/architecture/seo-growth-hacker.md +1 -2
  13. package/framework/{skills/level-2-domains → agents}/architecture/standards-architect.md +1 -4
  14. package/framework/agents/backend/api-designer.md +103 -0
  15. package/framework/{skills/level-2-domains → agents}/backend/dotnet-senior.md +1 -2
  16. package/framework/agents/backend/ef-modeler.md +119 -0
  17. package/framework/{skills/level-2-domains → agents}/backend/hangfire-orchestrator.md +1 -4
  18. package/framework/{skills/level-2-domains → agents}/backend/ms-agent-expert.md +1 -4
  19. package/framework/{skills/level-2-domains → agents}/frontend/blazor-builder.md +1 -4
  20. package/framework/{skills/level-2-domains → agents}/frontend/nextjs-expert.md +1 -4
  21. package/framework/{skills/level-2-domains → agents}/frontend/ui-ux-designer.md +1 -2
  22. package/framework/{skills/level-2-domains → agents}/infrastructure/azure-architect.md +1 -2
  23. package/framework/{skills/level-2-domains → agents}/infrastructure/azure-deploy-specialist.md +1 -2
  24. package/framework/{skills/level-2-domains → agents}/infrastructure/bicep-architect.md +1 -4
  25. package/framework/{skills/level-2-domains → agents}/infrastructure/container-specialist.md +1 -4
  26. package/framework/{skills/level-2-domains → agents}/infrastructure/devops-engineer.md +1 -4
  27. package/framework/{skills/level-2-domains → agents}/integrations/asaas-financial.md +1 -4
  28. package/framework/{skills/level-2-domains → agents}/integrations/azure-identity.md +1 -4
  29. package/framework/{skills/level-2-domains → agents}/integrations/clerk-auth.md +1 -4
  30. package/framework/{skills/level-2-domains → agents}/integrations/hangfire-integration.md +1 -2
  31. package/framework/{skills/level-2-domains → agents}/integrations/resend-email.md +1 -4
  32. package/framework/{skills/level-2-domains → agents}/quality/code-analyzer.md +1 -4
  33. package/framework/{skills/level-2-domains → agents}/quality/testing-specialist.md +1 -4
  34. package/framework/hooks/claude-code/statusline.py +384 -85
  35. package/framework/hooks/shared/phase-utils.js +129 -129
  36. package/framework/skills/README.md +66 -0
  37. package/framework/skills/level-0-meta/{brainstorming.md → brainstorming/SKILL.md} +3 -1
  38. package/framework/skills/level-0-meta/brainstorming/references/proposal-example.md +138 -0
  39. package/framework/skills/level-0-meta/{code-review.md → code-review/SKILL.md} +3 -2
  40. package/framework/skills/level-0-meta/code-review/references/review-example.md +164 -0
  41. package/framework/skills/level-0-meta/code-review/scripts/scan-csharp.mjs +121 -0
  42. package/framework/skills/level-0-meta/{morph-checklist.md → morph-checklist/SKILL.md} +2 -5
  43. package/framework/skills/{level-1-workflows/morph-replicate.md → level-0-meta/morph-replicate/SKILL.md} +6 -7
  44. package/framework/skills/level-0-meta/{simulation-checklist.md → simulation-checklist/SKILL.md} +3 -6
  45. package/framework/skills/level-0-meta/{tool-usage-guide.md → tool-usage-guide/SKILL.md} +1 -2
  46. package/framework/skills/level-0-meta/{verification-before-completion.md → verification-before-completion/SKILL.md} +3 -1
  47. package/framework/skills/level-0-meta/verification-before-completion/scripts/check-phase-outputs.mjs +110 -0
  48. package/framework/skills/level-1-workflows/{phase-clarify.md → phase-clarify/SKILL.md} +3 -3
  49. package/framework/skills/level-1-workflows/phase-clarify/references/clarifications-example.md +117 -0
  50. package/framework/skills/level-1-workflows/{phase-codebase-analysis.md → phase-codebase-analysis/SKILL.md} +2 -3
  51. package/framework/skills/level-1-workflows/{phase-design.md → phase-design/SKILL.md} +13 -185
  52. package/framework/skills/level-1-workflows/phase-design/references/spec-example.md +253 -0
  53. package/framework/skills/level-1-workflows/{phase-implement.md → phase-implement/SKILL.md} +3 -3
  54. package/framework/skills/level-1-workflows/phase-implement/references/recap-example.md +132 -0
  55. package/framework/skills/level-1-workflows/{phase-setup.md → phase-setup/SKILL.md} +2 -3
  56. package/framework/skills/level-1-workflows/{phase-tasks.md → phase-tasks/SKILL.md} +4 -3
  57. package/framework/skills/level-1-workflows/phase-tasks/references/tasks-example.md +231 -0
  58. package/framework/skills/level-1-workflows/phase-tasks/scripts/validate-tasks.mjs +112 -0
  59. package/framework/skills/level-1-workflows/{phase-uiux.md → phase-uiux/SKILL.md} +2 -3
  60. package/package.json +1 -1
  61. package/src/commands/project/init.js +4 -64
  62. package/src/commands/project/update.js +1 -62
  63. package/src/lib/detectors/claude-config-detector.js +1 -3
  64. package/src/utils/agents-installer.js +2 -2
  65. package/src/utils/skills-installer.js +59 -15
  66. package/.morph/context/README.md +0 -17
  67. package/framework/skills/level-2-domains/backend/api-designer.md +0 -66
  68. package/framework/skills/level-2-domains/backend/ef-modeler.md +0 -65
  69. package/framework/skills/level-3-technologies/README.md +0 -7
  70. package/framework/skills/level-4-patterns/README.md +0 -7
  71. /package/framework/{skills/level-2-domains → agents}/README.md +0 -0
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: phase-design
3
- description: >
4
- MORPH-SPEC Phase 2 (Design). Expands the approved proposal into spec.md, contracts.cs, decisions.md, and schema-analysis.md. Called by /morph-proposal after setup completes.
3
+ description: MORPH-SPEC Phase 2 (Design). Analyzes codebase/schema, then produces spec.md, contracts.cs, schema-analysis.md, and decisions.md for the feature. Use after setup phase to create a full technical specification with C# contracts based on the real database schema and architecture decision records.
5
4
  argument-hint: "[feature-name]"
6
5
  user-invocable: false
7
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep
@@ -21,8 +20,9 @@ Expanda a proposta em especificação técnica completa, contracts, decisões ar
21
20
 
22
21
  ## Ferramentas Recomendadas
23
22
 
24
- > **Ref:** `framework/skills/level-0-meta/tool-usage-guide.md` para guia completo.
23
+ > **Ref:** `framework/skills/level-0-meta/tool-usage-guide/SKILL.md` para guia completo.
25
24
  > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` para referência MCP.
25
+ > **Example:** `references/spec-example.md` — filled-in spec.md showing expected output quality.
26
26
 
27
27
  | Ação | Ferramenta | Alternativa |
28
28
  |------|------------|-------------|
@@ -78,193 +78,21 @@ Parse o JSON para obter `activeAgents`, então use standards context (já carreg
78
78
 
79
79
  **⚠️ ATENÇÃO:** Este passo é OBRIGATÓRIO antes de gerar `contracts.cs`. Previne geração de DTOs com nomes de campos errados.
80
80
 
81
- #### 2.1. Detectar Se Análise É Necessária
81
+ **Delegate para skill dedicada:**
82
82
 
83
- A análise de código é necessária se:
84
- - Feature interage com banco de dados existente
85
- - Feature usa APIs ou serviços existentes
86
- - Projeto tem código frontend/backend que será integrado
83
+ > **Ref:** `framework/skills/level-1-workflows/phase-codebase-analysis/SKILL.md` — workflow completo de análise de schema (MCP Supabase → fallback análise estática → SCHEMA-ANALYSIS.md → checkpoint de aprovação)
87
84
 
88
- **Pule este passo apenas se:**
85
+ Execute o workflow de `phase-codebase-analysis.md` para:
86
+ 1. Detectar se análise é necessária
87
+ 2. Tentar MCP Supabase (preferencial) ou análise estática (fallback)
88
+ 3. Mapear field name mismatches e type mismatches
89
+ 4. Gerar `schema-analysis.md` com findings reais
90
+ 5. Apresentar checkpoint ao usuário e aguardar aprovação
91
+
92
+ **Pule se:**
89
93
  - Feature é 100% nova (sem dependências em código existente)
90
94
  - Não há banco de dados ou APIs envolvidas
91
95
 
92
- #### 2.2. Tentar MCP Tools Primeiro (Preferencial)
93
-
94
- **Se MCP Supabase disponível:**
95
-
96
- ```javascript
97
- // Verificar se MCP está disponível (procure por ferramentas mcp__supabase__*)
98
- // Se disponível, use para obter schema real:
99
-
100
- // 1. Listar todas as tabelas
101
- await mcp__supabase__list_tables();
102
-
103
- // 2. Para cada tabela relevante, obter schema completo
104
- await mcp__supabase__get_table_schema({ table: 'leads' });
105
- await mcp__supabase__get_table_schema({ table: 'users' });
106
-
107
- // 3. Obter relacionamentos
108
- await mcp__supabase__get_relationships({ table: 'leads' });
109
-
110
- // 4. Documentar findings em SCHEMA-ANALYSIS.md
111
- ```
112
-
113
- **Se MCP Database/ORM disponível:**
114
- - Use ferramentas MCP equivalentes para PostgreSQL, MySQL, EF Core, etc.
115
- - Obtenha schema diretamente do banco
116
-
117
- #### 2.3. Fallback: Análise Manual de Código
118
-
119
- **Se MCP não disponível, use análise estática:**
120
-
121
- **Passo A: Encontrar Queries no Código**
122
-
123
- ```bash
124
- # Use Grep tool para encontrar todas as queries:
125
- pattern: "\.from\(|\.select\(|SELECT |supabase\.|context\.|dbContext\.|ef\.Database\."
126
- type: "ts,tsx,js,jsx,cs"
127
- output_mode: "files_with_matches"
128
- ```
129
-
130
- **Passo B: Ler Arquivos de Query**
131
-
132
- Para cada arquivo encontrado, use Read tool para extrair:
133
- - **Nomes de tabelas:** `from('leads')`, `DbSet<Lead>`, `FROM leads`
134
- - **Nomes de colunas:** `.select('fullname, phonenumber')`, `l.FullName`, `SELECT full_name`
135
- - **Tipos de dados:** TypeScript interfaces, C# DTOs, column types
136
- - **Relacionamentos:** JOIN clauses, navigation properties, foreign keys
137
-
138
- **Passo C: Encontrar Type Definitions**
139
-
140
- ```bash
141
- # TypeScript/JavaScript projects:
142
- Glob: "src/**/types/**/*.ts"
143
- Glob: "src/**/*.d.ts"
144
- Glob: "src/**/interfaces/*.ts"
145
-
146
- # .NET projects:
147
- Glob: "**/*Dto.cs"
148
- Glob: "**/Entities/**/*.cs"
149
- Glob: "**/Models/**/*.cs"
150
- ```
151
-
152
- Leia cada arquivo e mapeie:
153
- - Interface/Type → Database Table
154
- - Property names → Column names
155
- - Data types → SQL types
156
-
157
- **Passo D: Inferir Schema Real**
158
-
159
- Com base nos arquivos lidos, criar um mapa:
160
-
161
- ```markdown
162
- | Frontend/Code | Database | Type | Notes |
163
- |--------------|----------|------|-------|
164
- | user.name | users.fullname | string | MISMATCH! |
165
- | lead.phone | leads.phonenumber | string | MISMATCH! |
166
- | order.metadata | orders.metadata | JSONB | Complex type |
167
- | user.orders | users → orders (1:N) | relation | Foreign key: orders.user_id |
168
- ```
169
-
170
- #### 2.4. Criar SCHEMA-ANALYSIS.md
171
-
172
- Documente os findings em `.morph/features/$ARGUMENTS/1-design/schema-analysis.md`:
173
-
174
- ```markdown
175
- # Schema Analysis - {Feature Name}
176
-
177
- **Date:** {DATE}
178
- **Method:** {MCP Supabase / Manual Code Analysis}
179
-
180
- ## Tables Analyzed
181
-
182
- ### Table: leads
183
-
184
- **Source:**
185
- - MCP: supabase.list_tables()
186
- - Code: src/lib/database/queries.ts
187
-
188
- **Columns:**
189
- | Column Name | Type | Nullable | Default | Notes |
190
- |------------|------|----------|---------|-------|
191
- | id | uuid | NO | gen_random_uuid() | Primary key |
192
- | fullname | varchar(255) | NO | - | NOT 'name'! |
193
- | phonenumber | varchar(20) | YES | - | NOT 'phone'! |
194
- | metadata | jsonb | YES | {} | Complex object |
195
- | created_at | timestamptz | NO | now() | Auto-generated |
196
- | user_id | uuid | YES | - | FK to users table |
197
-
198
- **Relationships:**
199
- - leads.user_id → users.id (N:1)
200
- - leads.id ← roulette_spins.lead_id (1:N)
201
-
202
- **Indexes:**
203
- - PRIMARY KEY (id)
204
- - INDEX idx_leads_user_id ON (user_id)
205
-
206
- ### Table: users
207
- {Repetir para cada tabela}
208
-
209
- ## ⚠️ CRITICAL FINDINGS
210
-
211
- **Field Name Mismatches (MUST FIX):**
212
- - ❌ Use `fullname`, NOT `name` (column doesn't exist!)
213
- - ❌ Use `phonenumber`, NOT `phone` (column doesn't exist!)
214
-
215
- **Type Mismatches:**
216
- - ⚠️ `metadata` is JSONB, not `Record<string, string>` (use proper type)
217
-
218
- **Relationship Corrections:**
219
- - ✅ Lead → User is N:1 (NOT 1:1)
220
- - ✅ Lead → RouletteSpins is 1:N (NOT 1:1)
221
-
222
- ## Recommendations for contracts.cs
223
-
224
- Based on real schema, DTOs should use:
225
- \`\`\`csharp
226
- public record LeadDto(
227
- Guid Id,
228
- string Fullname, // NOT 'Name'!
229
- string? Phonenumber, // NOT 'Phone'! Nullable!
230
- JsonObject? Metadata, // NOT Record<string,string>!
231
- Guid? UserId, // Nullable FK
232
- DateTime CreatedAt
233
- );
234
- \`\`\`
235
- ```
236
-
237
- #### 2.5. CHECKPOINT OBRIGATÓRIO: Revisar Schema Analysis
238
-
239
- **⏸️ PAUSE - Validar findings antes de continuar:**
240
-
241
- Apresente ao usuário:
242
- - [ ] Analisei {N} arquivos de código
243
- - [ ] Identifiquei {N} tabelas: {lista}
244
- - [ ] Encontrei {N} field name mismatches
245
- - [ ] Encontrei {N} type mismatches
246
- - [ ] Mapeei {N} relacionamentos
247
- - [ ] Criei `schema-analysis.md` com todos os findings
248
-
249
- **Perguntas ao usuário:**
250
- 1. "O schema analysis está correto?"
251
- 2. "Encontrei field mismatches (fullname vs name). Confirma?"
252
- 3. "Posso prosseguir para gerar contracts.cs com base nesse schema real?"
253
-
254
- **❌ Se usuário responder "Não" ou encontrar erros:**
255
- → VOLTAR e revisar análise
256
- → Corrigir schema-analysis.md
257
- → Re-apresentar para aprovação
258
-
259
- **✅ Se usuário aprovar:**
260
- → Prosseguir para Passo 3 (Gerar spec.md)
261
-
262
- #### 2.6. Atualizar State
263
-
264
- ```bash
265
- npx morph-spec state mark-output $ARGUMENTS schema-analysis
266
- ```
267
-
268
96
  ### Passo 3: Gerar `spec.md`
269
97
 
270
98
  Crie `.morph/features/$ARGUMENTS/1-design/spec.md` com:
@@ -0,0 +1,253 @@
1
+ # Feature Specification: Photo Processing Pipeline
2
+
3
+ > Example of a well-structured spec.md. This is a filled-in reference — not a template.
4
+
5
+ | Field | Value |
6
+ |-------|-------|
7
+ | **ID** | photo-processing |
8
+ | **Status** | Approved |
9
+ | **Created** | 2025-01-15 |
10
+ | **Stack** | blazor-azure |
11
+ | **Complexity** | Medium |
12
+ | **Estimated Cost** | ~$5.50/month |
13
+ | **Agents** | Core: All / Specialists: azure-architect, dotnet-senior, blazor-builder |
14
+
15
+ ---
16
+
17
+ ## Overview
18
+
19
+ **Problem:** Users cannot submit photos for AI transformation — the core product value proposition is blocked.
20
+
21
+ **Solution:** End-to-end pipeline: upload → Blob Storage → Hangfire background job → AI processing → download link.
22
+
23
+ **Success Criteria:**
24
+ - [ ] Upload endpoint accepts .jpg/.png up to 10MB and stores in Azure Blob
25
+ - [ ] Background job processes photo and updates status to Completed within 120s (p95)
26
+ - [ ] Status polling page reflects real-time processing progress
27
+ - [ ] Failed jobs retry up to 3 times with exponential backoff
28
+
29
+ ---
30
+
31
+ ## Requirements
32
+
33
+ **Functional:**
34
+ FR1: Upload photo (.jpg/.png, max 10MB) via Blazor form
35
+ FR2: Store photo in Azure Blob Storage under `uploads/{jobId}`
36
+ FR3: Enqueue Hangfire background job for AI processing
37
+ FR4: Status polling endpoint returns `{ status, progress, createdAt }`
38
+ FR5: Download endpoint redirects to Blob URL for completed jobs
39
+
40
+ **Non-Functional:**
41
+ NFR1: Processing time < 120s for p95 of requests
42
+ NFR2: Upload endpoint < 2s response time
43
+ NFR3: Retry 3x on AI API failure with 5s/30s/120s backoff
44
+
45
+ ---
46
+
47
+ ## User Stories
48
+
49
+ ### US001: Upload Photo
50
+ **As** an authenticated user **I want** to upload a photo **so that** the AI can transform it.
51
+
52
+ **Acceptance Criteria:**
53
+ 1. Accepts .jpg and .png files only — rejects other formats with clear error
54
+ 2. Rejects files larger than 10MB with a specific error message
55
+ 3. Returns a `jobId` and redirects to `/processing/{jobId}` on success
56
+
57
+ **Edge Cases:**
58
+ - Network timeout during upload: show retry button
59
+ - Duplicate upload: create new job each time (idempotency not required)
60
+
61
+ ### US002: Track Progress
62
+ **As** a user who uploaded a photo **I want** to see real-time status **so that** I know when my photo is ready.
63
+
64
+ **Acceptance Criteria:**
65
+ 1. Page polls `/api/status/{jobId}` every 5 seconds
66
+ 2. Shows status label: Pending / Processing / Completed / Failed
67
+ 3. Shows "Download" button when status = Completed
68
+
69
+ ---
70
+
71
+ ## Technical Design
72
+
73
+ ### Stack
74
+
75
+ | Component | Technology |
76
+ |-----------|------------|
77
+ | Frontend | Blazor Server |
78
+ | Backend | .NET 10 / C# 14 Minimal API |
79
+ | Background Jobs | Hangfire (self-hosted) |
80
+ | Storage | Azure Blob Storage (LRS) |
81
+ | Database | Azure SQL |
82
+
83
+ ### Data Model
84
+
85
+ #### ProcessingJob
86
+
87
+ | Column | Type | Constraints |
88
+ |--------|------|-------------|
89
+ | Id | Guid | PK, default NEWID() |
90
+ | OriginalPhotoUrl | nvarchar(500) | NOT NULL |
91
+ | ProcessedPhotoUrl | nvarchar(500) | NULL (populated after processing) |
92
+ | Status | int | NOT NULL, default 0 (Pending) |
93
+ | ErrorMessage | nvarchar(1000) | NULL |
94
+ | RetryCount | int | NOT NULL, default 0 |
95
+ | CreatedAt | datetime2 | NOT NULL, default GETUTCDATE() |
96
+ | UpdatedAt | datetime2 | NOT NULL |
97
+
98
+ #### ProcessingStatus Enum
99
+
100
+ ```csharp
101
+ public enum ProcessingStatus
102
+ {
103
+ Pending = 0,
104
+ Processing = 1,
105
+ Completed = 2,
106
+ Failed = 100
107
+ }
108
+ ```
109
+
110
+ ### Contracts
111
+
112
+ ```csharp
113
+ // Commands
114
+ public record UploadPhotoCommand(IFormFile Photo, string? Email);
115
+ public record UploadPhotoResult(Guid JobId);
116
+
117
+ // Queries
118
+ public record GetJobStatusQuery(Guid JobId);
119
+ public record JobStatusDto(Guid JobId, ProcessingStatus Status, string? ProcessedPhotoUrl, DateTime CreatedAt);
120
+
121
+ // Service Interface
122
+ public interface IPhotoProcessingService
123
+ {
124
+ Task<UploadPhotoResult> UploadAsync(UploadPhotoCommand command, CancellationToken ct);
125
+ Task<JobStatusDto> GetStatusAsync(GetJobStatusQuery query, CancellationToken ct);
126
+ }
127
+
128
+ // Hangfire Job
129
+ public interface IPhotoProcessingJob
130
+ {
131
+ Task ProcessAsync(Guid jobId, CancellationToken ct);
132
+ }
133
+ ```
134
+
135
+ ---
136
+
137
+ ## UI/UX Design
138
+
139
+ ### Upload Page (/upload)
140
+
141
+ ```
142
+ ┌─────────────────────────────────────┐
143
+ │ Upload Photo │
144
+ │ ───────────────────────────────── │
145
+ │ [📁 Select File] photo.jpg (2.3MB) │
146
+ │ │
147
+ │ Allowed: JPG, PNG — Max: 10MB │
148
+ │ │
149
+ │ [Upload →] │
150
+ │ │
151
+ │ Error state: │
152
+ │ ⚠ File too large. Max size is 10MB. │
153
+ └─────────────────────────────────────┘
154
+ ```
155
+
156
+ ### Status Page (/processing/{jobId})
157
+
158
+ ```
159
+ ┌─────────────────────────────────────┐
160
+ │ Processing your photo │
161
+ │ ───────────────────────────────── │
162
+ │ Status: ⏳ Processing │
163
+ │ ████████░░░░░░░ 60% │
164
+ │ │
165
+ │ Started: 2025-01-15 14:32:01 │
166
+ │ │
167
+ │ [Completed state]: │
168
+ │ Status: ✅ Done! │
169
+ │ [📥 Download] │
170
+ └─────────────────────────────────────┘
171
+ ```
172
+
173
+ ---
174
+
175
+ ## Flows
176
+
177
+ ### Upload Flow
178
+ **Trigger:** User submits photo form
179
+
180
+ 1. User selects file → client validates type/size before submit
181
+ 2. `POST /api/upload` — server validates, uploads to Blob at `uploads/{jobId}/original.jpg`
182
+ 3. Create `ProcessingJob` entity (status = Pending)
183
+ 4. Enqueue Hangfire job with `jobId`
184
+ 5. Return `{ jobId }` → client redirects to `/processing/{jobId}`
185
+
186
+ **End State:** Job queued, user on status page
187
+
188
+ ### Processing Flow
189
+ **Trigger:** Hangfire executes job
190
+
191
+ 1. Load `ProcessingJob` by Id, set status = Processing
192
+ 2. Download original from Blob Storage
193
+ 3. Call AI API (`POST /transform`, multipart/form-data)
194
+ 4. On success: upload result to `uploads/{jobId}/processed.jpg`, set status = Completed
195
+ 5. On failure: increment RetryCount, set status = Failed if RetryCount >= 3
196
+
197
+ **End State:** Job = Completed (photo available) or Failed (user sees error)
198
+
199
+ ---
200
+
201
+ ## Cost Estimate
202
+
203
+ | Resource | SKU | Monthly | Justification |
204
+ |----------|-----|---------|---------------|
205
+ | Blob Storage | LRS | $0.02 | ~500 photos/month × 2 files × avg 3MB |
206
+ | Azure SQL | Basic | $4.99 | < 100k jobs/month |
207
+ | Container App | Consumption | $0.49 | Scale to zero when idle |
208
+ | Hangfire | Self-hosted | $0.00 | In-process with Container App |
209
+ | **Total** | | **~$5.50** | |
210
+
211
+ ---
212
+
213
+ ## ADRs
214
+
215
+ ### ADR-001: Hangfire over Azure Functions for Background Processing
216
+ **Status:** Accepted
217
+ **Context:** Need async processing for AI photo transformation (30–120s duration).
218
+ **Decision:** Hangfire (self-hosted in Container App)
219
+ **Alternatives:**
220
+ 1. Azure Functions — serverless, auto-scaling, but cold start latency + $10/mo for 50k executions
221
+ 2. Quartz.NET — more features (CRON, clustering), steeper learning curve
222
+ **Trade-offs:** Simplicity + zero cost vs scalability (Hangfire sufficient for MVP < 10k/month)
223
+
224
+ ### ADR-002: Polling over WebSockets for Status Updates
225
+ **Status:** Accepted
226
+ **Context:** Users need real-time feedback; SSE/WebSocket adds Blazor Hub complexity.
227
+ **Decision:** 5-second HTTP polling from Blazor component
228
+ **Trade-offs:** Slightly higher server load vs significantly simpler implementation; polling sufficient at MVP scale
229
+
230
+ ---
231
+
232
+ ## Security
233
+
234
+ | Action | Required Policy |
235
+ |--------|-----------------|
236
+ | Upload | Authenticated user |
237
+ | View status | Owner of job (check UserId) |
238
+ | Download | Owner of job (check UserId) |
239
+
240
+ ---
241
+
242
+ ## Definition of Done
243
+
244
+ - [ ] Upload endpoint working, validated with unit + integration tests
245
+ - [ ] Hangfire job processes photos end-to-end in dev environment
246
+ - [ ] Status page shows correct states (Pending/Processing/Completed/Failed)
247
+ - [ ] Code review approved
248
+ - [ ] Deployed to staging environment
249
+ - [ ] `recap.md` generated with implementation notes
250
+
251
+ ---
252
+
253
+ *MORPH-SPEC by Polymorphism Tech*
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: phase-implement
3
- description: >
4
- MORPH-SPEC Phase 5 (Implement). Executes tasks.md task-by-task with checkpoint validation every 3 tasks, producing code and recap.md. Called by /morph-apply.
3
+ description: MORPH-SPEC Phase 5 (Implement). Executes feature tasks using TDD with checkpoint validation every 3 tasks, smoke tests via Playwright, and generates code + recap.md. Use after task list approval when starting feature implementation.
5
4
  argument-hint: "[feature-name]"
6
5
  disable-model-invocation: true
7
6
  context: fork
@@ -25,8 +24,9 @@ Implemente as tasks definidas na FASE 4, com checkpoints a cada 3 tasks e recap
25
24
 
26
25
  ## Ferramentas Recomendadas
27
26
 
28
- > **Ref:** `framework/skills/level-0-meta/tool-usage-guide.md` para guia completo.
27
+ > **Ref:** `framework/skills/level-0-meta/tool-usage-guide/SKILL.md` para guia completo.
29
28
  > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` para referência MCP.
29
+ > **Example:** `references/recap-example.md` — filled-in recap.md showing expected output quality.
30
30
 
31
31
  | Ação | Ferramenta | Alternativa |
32
32
  |------|------------|-------------|
@@ -0,0 +1,132 @@
1
+ # Feature Recap: Photo Processing Pipeline
2
+
3
+ > Example of a well-structured recap.md. Filled-in reference — not a template.
4
+
5
+ ## Summary
6
+
7
+ | Field | Value |
8
+ |-------|-------|
9
+ | **Feature ID** | photo-processing |
10
+ | **Completed** | 2025-01-22 |
11
+ | **Total Tasks** | 11 / 11 |
12
+ | **Time Spent** | ~9h |
13
+ | **Agents Used** | dotnet-senior, azure-architect, blazor-builder |
14
+ | **Stack** | blazor-azure |
15
+
16
+ ---
17
+
18
+ ## Tasks Completed
19
+
20
+ | ID | Title | Category | Duration |
21
+ |----|-------|----------|----------|
22
+ | T001 | Define C# contracts and interfaces | Contract | 25min |
23
+ | T002 | Create ProcessingJob entity and enum | Domain | 30min |
24
+ | T003 | EF Core migration and DbContext setup | Infrastructure | 50min |
25
+ | T004 | Azure Blob Storage service | Infrastructure | 45min |
26
+ | T005 | Implement PhotoProcessingService | Service | 65min |
27
+ | T006 | Implement Hangfire background job | Job | 70min |
28
+ | T007 | Upload and status endpoints | API | 40min |
29
+ | T008 | Blazor upload page component | UI | 60min |
30
+ | T009 | Blazor status polling page | UI | 65min |
31
+ | T010 | Unit tests for PhotoProcessingService | Test | 55min |
32
+ | T011 | Integration tests for upload + status API | Test | 70min |
33
+
34
+ ---
35
+
36
+ ## What Was Delivered
37
+
38
+ ### Functionality
39
+ - Photo upload via Blazor form (10MB limit, .jpg/.png only)
40
+ - Azure Blob Storage integration with `uploads/{jobId}/original.jpg` path structure
41
+ - Hangfire background job with 3-retry exponential backoff (5s/30s/120s)
42
+ - Real-time status polling page (5s interval, stops on terminal state)
43
+ - Download redirect for completed jobs
44
+
45
+ ### Backend (.NET)
46
+ - Endpoints: `POST /api/upload`, `GET /api/status/{id}`, `GET /api/download/{id}`
47
+ - Services: `PhotoProcessingService`, `PhotoProcessingJob`
48
+ - Simulation: `FakeBlobStorageService`, `FakePhotoProcessingJob` for dev mode
49
+
50
+ ### Frontend (Blazor)
51
+ - Pages: `Upload.razor`, `ProcessingStatus.razor`
52
+ - Polling via `PeriodicTimer` — no SignalR dependency
53
+
54
+ ---
55
+
56
+ ## Files Created
57
+
58
+ ```
59
+ src/Domain/Entities/ProcessingJob.cs
60
+ src/Domain/Enums/ProcessingStatus.cs
61
+ src/Application/PhotoProcessing/Interfaces/IPhotoProcessingService.cs
62
+ src/Application/PhotoProcessing/Commands/UploadPhotoCommand.cs
63
+ src/Application/PhotoProcessing/Queries/GetJobStatusQuery.cs
64
+ src/Application/PhotoProcessing/DTOs/JobStatusDto.cs
65
+ src/Application/PhotoProcessing/PhotoProcessingService.cs
66
+ src/Application/PhotoProcessing/PhotoProcessingJob.cs
67
+ src/Application/PhotoProcessing/FakePhotoProcessingJob.cs
68
+ src/Infrastructure/Storage/IBlobStorageService.cs
69
+ src/Infrastructure/Storage/AzureBlobStorageService.cs
70
+ src/Infrastructure/Storage/FakeBlobStorageService.cs
71
+ src/Infrastructure/Persistence/Configurations/ProcessingJobConfiguration.cs
72
+ src/Web/Endpoints/PhotoProcessingEndpoints.cs
73
+ src/Web/Pages/Upload.razor + .cs
74
+ src/Web/Pages/ProcessingStatus.razor + .cs
75
+ tests/Unit/Application/PhotoProcessing/PhotoProcessingServiceTests.cs
76
+ tests/Integration/Api/PhotoProcessingEndpointTests.cs
77
+ tests/Integration/Fixtures/PhotoProcessingApiFixture.cs
78
+ ```
79
+
80
+ ## Files Modified
81
+
82
+ ```
83
+ src/Infrastructure/Persistence/AppDbContext.cs
84
+ src/Infrastructure/DependencyInjection.cs
85
+ src/Application/DependencyInjection.cs
86
+ src/Web/Program.cs
87
+ ```
88
+
89
+ ---
90
+
91
+ ## Architecture Decisions
92
+
93
+ | Decision | Rationale |
94
+ |----------|-----------|
95
+ | PeriodicTimer for polling (not SignalR) | Simpler, no hub overhead, sufficient at MVP scale |
96
+ | FakeBlobStorageService as Singleton | Stores in-memory dict; Scoped would lose state between requests |
97
+ | Hangfire RetryCount on entity (not Hangfire built-in) | Domain owns retry state; allows custom error messages per attempt |
98
+
99
+ See full ADRs in `decisions.md`
100
+
101
+ ---
102
+
103
+ ## Test Coverage
104
+
105
+ | Type | Files | Notes |
106
+ |------|-------|-------|
107
+ | Unit | `PhotoProcessingServiceTests.cs` | Happy path, invalid type, size limit, 404, all statuses |
108
+ | Integration | `PhotoProcessingEndpointTests.cs` | POST /upload, GET /status, GET /download (completed + pending) |
109
+
110
+ ---
111
+
112
+ ## Issues Encountered
113
+
114
+ | Issue | Resolution |
115
+ |-------|-----------|
116
+ | `FakeBlobStorageService` registered as `Scoped` — lost uploads between requests | Changed to `Singleton` per simulation-checklist.md |
117
+ | `PeriodicTimer` not stopping on component dispose | Added `CancellationTokenSource` + dispose pattern in `ProcessingStatus.razor.cs` |
118
+
119
+ ---
120
+
121
+ ## Metrics
122
+
123
+ | Metric | Value |
124
+ |--------|-------|
125
+ | Tasks Completed | 11 / 11 |
126
+ | Checkpoints Passed | 3 (after T003, T006, T009) |
127
+ | Bugs Found | 2 |
128
+ | Bugs Fixed | 2 |
129
+
130
+ ---
131
+
132
+ *MORPH-SPEC by Polymorphism Tech*
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: phase-setup
3
- description: >
4
- MORPH-SPEC Phase 1 (Setup). Reads project context, identifies the stack, activates relevant agents, and creates the feature folder structure. Called at the start of every feature.
3
+ description: MORPH-SPEC Phase 1 (Setup). Reads project context, detects tech stack, activates relevant agents via detect-agents, and confirms the feature environment. Use at the start of every MORPH-SPEC feature workflow after proposal approval to load standards and initialize the context.
5
4
  argument-hint: "[feature-name]"
6
5
  user-invocable: false
7
6
  allowed-tools: Read, Write, Edit, Bash, Glob, Grep
@@ -21,7 +20,7 @@ Inicialize o contexto e prepare o ambiente para uma feature aprovada.
21
20
 
22
21
  ## Ferramentas Recomendadas
23
22
 
24
- > **Ref:** `framework/skills/level-0-meta/tool-usage-guide.md` para guia completo.
23
+ > **Ref:** `framework/skills/level-0-meta/tool-usage-guide/SKILL.md` para guia completo.
25
24
  > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` para referência MCP.
26
25
 
27
26
  | Ação | Ferramenta | Alternativa |
@@ -1,7 +1,6 @@
1
1
  ---
2
2
  name: phase-tasks
3
- description: >
4
- MORPH-SPEC Phase 4 (Tasks). Breaks the approved design into ordered implementation tasks with dependencies and checkpoints, producing tasks.md. Called after clarifications resolve.
3
+ description: MORPH-SPEC Phase 4 (Tasks). Breaks approved spec into bottom-up ordered implementation tasks (T001...TXXX) with dependencies, checkpoints every 3 tasks, and effort estimates, producing tasks.md. Use after design and clarification phases to create a structured implementation plan before coding starts.
5
4
  argument-hint: "[feature-name]"
6
5
  disable-model-invocation: true
7
6
  user-invocable: false
@@ -22,8 +21,10 @@ Quebre a especificação em tasks executáveis, defina ordem de execução e est
22
21
 
23
22
  ## Ferramentas Recomendadas
24
23
 
25
- > **Ref:** `framework/skills/level-0-meta/tool-usage-guide.md` para guia completo.
24
+ > **Ref:** `framework/skills/level-0-meta/tool-usage-guide/SKILL.md` para guia completo.
26
25
  > **Ref:** `framework/standards/integration/mcp/mcp-tools.md` para referência MCP.
26
+ > **Example:** `references/tasks-example.md` — filled-in tasks.md showing expected granularity and format.
27
+ > **Script:** `scripts/validate-tasks.mjs` — validates tasks.md structure, T### IDs, and required fields.
27
28
 
28
29
  | Ação | Ferramenta | Alternativa |
29
30
  |------|------------|-------------|