Files
postgenerator/.planning/STATE.md
Michele d320bf04f5 docs(04-01): complete Unsplash image resolution plan
Tasks completed: 2/2
- Task 1: UnsplashService + Settings unsplash_api_key
- Task 2: Integrazione pipeline + CSV con risoluzione Unsplash

SUMMARY: .planning/phases/04-enrichment/04-01-SUMMARY.md
2026-03-09 08:12:12 +01:00

99 lines
5.0 KiB
Markdown

# Project State
## Project Reference
See: .planning/PROJECT.md (updated 2026-03-07)
**Core value:** Generare un calendario di 13 caroselli Instagram strategicamente orchestrati, pronti per Canva Bulk Create, con un click dalla Web UI.
**Current focus:** Phase 4 Plan 01 COMPLETO — integrazione Unsplash backend
## Current Position
Phase: 4 of 4 (Enrichment) — In progress
Plan: 1 of 1 in current phase — Completato
Status: Phase 4 Plan 01 completa — backend Unsplash integrato
Last activity: 2026-03-09 — Completed 04-01-PLAN.md (Unsplash image resolution)
Progress: [█████████░] 100% (9/9 piani totali)
## Performance Metrics
**Velocity:**
- Total plans completed: 9
- Average duration: ~6 min
- Total execution time: 55 min
**By Phase:**
| Phase | Plans | Total | Avg/Plan |
|-------|-------|-------|----------|
| 01-core-generation-pipeline | 4/4 COMPLETA | 33 min | 8 min |
| 02-prompt-control-output-review | 2/2 COMPLETA | 9 min | 4.5 min |
| 03-organization-layer | 2/2 COMPLETA | 8 min | 4 min |
| 04-enrichment | 1/1 COMPLETA | 5 min | 5 min |
**Recent Trend:**
- Last 5 plans: 4 min, 5 min, 3 min, 3 min, 5 min
- Trend: stabile intorno a 3-5 min
*Updated after each plan completion*
## Accumulated Context
### Decisions
Decisions are logged in PROJECT.md Key Decisions table.
Recent decisions affecting current work:
- [Setup]: FastAPI root_path SOLO via Uvicorn (--root-path), mai nel costruttore FastAPI()
- [Setup]: CSV encoding = utf-8-sig (BOM) sempre; CANVA_FIELDS locked come costante
- [Setup]: Prompt di sistema scritti IN italiano
- [Setup]: Per-item error isolation dal primo loop di generazione
- [01-01]: root_path SOLO via Uvicorn --root-path nel Dockerfile CMD
- [01-01]: API_BASE='/postgenerator/api' nel frontend — Pitfall #9 risolto
- [01-02]: CANVA_FIELDS 33 colonne con _image_keyword (non URL) — URL Unsplash in Phase 4
- [01-02]: PromptService usa ValueError per variabili mancanti
- [01-03]: LLMService._parse_retry_after() legge header HTTP per wait esatto (fallback 60s)
- [01-03]: asyncio.to_thread wrappa LLM sync calls nel background task async
- [01-03]: Settings.api_key merge: PUT non sovrascrive con None se non inclusa nel body
- [01-03]: Pipeline singleton in generate.py per mantenere _jobs tra request, con fallback da disco
- [01-04]: Palette stone/amber per design B2B non generico (non gradienti viola)
- [01-04]: Download CSV sempre via POST con edits inline (non GET originale)
- [01-04]: localResults separato in OutputReview per edit inline senza mutare cache TanStack Query
- [verification-fix]: GenerateResponse include calendar per badge PN/Schwartz nel frontend
- [02-01]: PromptService init lazy via _get_prompt_service() per sincronizzazione con lifespan directory
- [02-02]: Regen notes passate via campo tono in GenerateRequest (pragmatico, no backend changes)
- [02-02]: Edit detection manuale via JSON.stringify comparison (trascurabile con 13 post)
- [03-01]: SwipeService lazy init identico a PromptService (DATA_PATH creato nel lifespan FastAPI)
- [03-01]: IDs brevi uuid4.hex[:12] — leggibili, no rischio collisione con volumi Swipe File
- [03-01]: PUT con comportamento PATCH-like per nicchia/note — None cancella il valore
- [03-01]: Filtro nicchia derivato dinamicamente da items (no config separata)
- [03-02]: topic_overrides come dict[int, str] — chiave = slot_index, Pydantic converte str key → int
- [03-02]: Override check prima di slot.topic e prima di LLM nel _run_generation
- [03-02]: mark-used fire-and-forget (mutate senza await) per non bloccare la UI
- [03-02]: Picker inline con absolute positioning z-20, toggle click stesso slot chiude
- [04-01]: Risoluzione Unsplash UNA SOLA VOLTA dopo batch LLM, image_url_map salvata nel job JSON
- [04-01]: generate_single NON risolve Unsplash — velocita' e riuso map job originale
- [04-01]: Dizionario statico IT->EN (~30 keyword B2B) — no API di traduzione
- [04-01]: Fallback trasparente: keyword non risolte restano testuali, nessun errore bloccante
- [04-01]: Rate limit: X-Ratelimit-Remaining < 5 => stop batch, keyword restanti non risolte
### Blockers/Concerns
- [Phase 1]: Validare token usage reale per batch 13 post con claude-sonnet-4-5 — inter_request_delay=2.0s configurato, da validare in produzione
- [Phase 1]: Baseline qualita' prompt italiani da validare dopo prima generazione reale
- [Deploy]: PRIORITA' — eseguire vps-lab-deploy per testare end-to-end il sistema completo (tutte le 4 fasi complete)
- [04-01]: Frontend non aggiornato per campo unsplash_api_key in Impostazioni — funzionalita' disponibile ma non configurabile via UI (workaround: API diretta o settings.json)
## Session Continuity
Last session: 2026-03-09
Stopped at: Completed 04-01-PLAN.md (Unsplash image resolution) — Plan 1/1 Phase 4
Resume file: None
## Next Actions
1. `vps-lab-deploy` — tutte le 4 fasi sono complete, deployare su VPS e testare end-to-end
2. Aggiornare il frontend Settings per esporre il campo unsplash_api_key (opzionale, post-deploy)
3. Test reale della generazione bulk con Unsplash API key configurata