US02-06: Deliver Workflow, Safety, Library, Analysis, and Stats Views #59

Merged
domverse merged 1 commits from us/US02-06-workflow-safety-library-analysis-stats-views into main 2026-08-09 20:10:59 +02:00
Owner

Stacked on #58 (US02-05). Ports safety review and the Photo Analyzer Library/Analyze/Stats views onto the shared API + service layer, adds the Workflow home, and enforces the pipeline gates + one-mutating-job policy.

Backend

  • Migration 0005 + modelssafety_reviews (append-only; latest row is the current decision) and analysis_results (donor photos schema re-keyed to asset_id).
  • SafetyService — persist scores/decisions, filtered review queue, and the EXIF safety checkpoint (mutually-exclusive sfw/nsfw keyword written, read back, current_sha256 refreshed) that upload eligibility depends on.
  • AnalysisService — the privacy gate: the vision provider is called only for canonical, confirmed-SFW assets; nsfw/undecided are recorded skipped without a request. Provider is an injected adapter (real Gemini call extracted from photo_analyzer.analyze_image; a fake in tests).
  • LibraryService — Library search + Stats ported from webapp/query.py (LIKE search instead of FTS5; facets, top tags, years, albums, people).
  • WorkflowService + GET /api/v1/workflow — per-stage readiness derived from source tables (counts, blockers, last-run, action, active_job). Safety scoring and analysis run as durable jobs under the library_write lock; a second mutating job is refused.
  • Routes — workflow, safety, analysis, library.

Frontend

Five views (frontend/js/views.js) on the US02-05 shell: Workflow stepper (status text+icon, not colour alone; actions disabled with a reason while a job runs), Safety review (filter tabs, decide, persists across reload), Library (search + cards), Analyze (counts + live job log via the SSE adapter), Stats. Shared DOM helpers → dom.js. Workflow is the home route.

Acceptance

  • Cards show counts, blockers, last-run, action, details — not colour alone ✓
  • Safety decisions persist + prevent NSFW reaching analysis, keep upload eligibility ✓
  • Library/Analyze/Stats on shared APIs ✓
  • Read-only browsing during jobs; conflicting actions explain why disabled ✓

Tests (215 pass)

  • integration test_safety_analysis.py: provider-call privacy (nsfw never reaches the provider), sfw→nsfw flip drops eligibility, decision persistence, one-mutating-job rejection, workflow counts, exiftool safety-keyword write/verify
  • e2e test_workflow_views.py: Workflow cards, actions disabled+explained during a job, safety decide-persists-across-reload, Library search, Stats, Analyze counts
  • traceability map updated for US02-05 + US02-06

🤖 Generated with Claude Code

Stacked on #58 (US02-05). Ports safety review and the Photo Analyzer Library/Analyze/Stats views onto the shared API + service layer, adds the Workflow home, and enforces the pipeline gates + one-mutating-job policy. ## Backend - **Migration 0005 + models** — `safety_reviews` (append-only; latest row is the current decision) and `analysis_results` (donor `photos` schema re-keyed to `asset_id`). - **SafetyService** — persist scores/decisions, filtered review queue, and the EXIF safety checkpoint (mutually-exclusive `sfw`/`nsfw` keyword written, read back, `current_sha256` refreshed) that upload eligibility depends on. - **AnalysisService** — the privacy gate: the vision provider is called **only** for canonical, confirmed-SFW assets; nsfw/undecided are recorded skipped without a request. Provider is an injected adapter (real Gemini call extracted from `photo_analyzer.analyze_image`; a fake in tests). - **LibraryService** — Library search + Stats ported from `webapp/query.py` (LIKE search instead of FTS5; facets, top tags, years, albums, people). - **WorkflowService + `GET /api/v1/workflow`** — per-stage readiness derived from source tables (counts, blockers, last-run, action, `active_job`). Safety scoring and analysis run as durable jobs under the `library_write` lock; a second mutating job is refused. - **Routes** — workflow, safety, analysis, library. ## Frontend Five views (`frontend/js/views.js`) on the US02-05 shell: Workflow stepper (status text+icon, not colour alone; actions disabled with a reason while a job runs), Safety review (filter tabs, decide, persists across reload), Library (search + cards), Analyze (counts + live job log via the SSE adapter), Stats. Shared DOM helpers → `dom.js`. Workflow is the home route. ## Acceptance - Cards show counts, blockers, last-run, action, details — not colour alone ✓ - Safety decisions persist + prevent NSFW reaching analysis, keep upload eligibility ✓ - Library/Analyze/Stats on shared APIs ✓ - Read-only browsing during jobs; conflicting actions explain why disabled ✓ ## Tests (215 pass) - integration `test_safety_analysis.py`: provider-call privacy (nsfw never reaches the provider), sfw→nsfw flip drops eligibility, decision persistence, one-mutating-job rejection, workflow counts, exiftool safety-keyword write/verify - e2e `test_workflow_views.py`: Workflow cards, actions disabled+explained during a job, safety decide-persists-across-reload, Library search, Stats, Analyze counts - traceability map updated for US02-05 + US02-06 🤖 Generated with [Claude Code](https://claude.com/claude-code)
domverse changed target branch from us/US02-05-build-the-static-application-shell to main 2026-08-09 20:10:50 +02:00
domverse added 1 commit 2026-08-09 20:10:50 +02:00
Ports the safety review and the Photo Analyzer Library/Analyze/Stats
experiences onto the shared API + service layer, and adds the Workflow
home, enforcing the pipeline gates and the one-mutating-job policy.

Backend
- migration 0005 + models: safety_reviews (append-only, latest row is the
  current decision) and analysis_results (donor photos schema re-keyed to
  asset_id).
- SafetyService: persist scores/decisions, review queue with filters, and
  the EXIF safety checkpoint (mutually-exclusive sfw/nsfw keyword written,
  read back, current_sha256 refreshed) that upload eligibility depends on.
- AnalysisService: the privacy gate — the vision provider is called ONLY for
  canonical, confirmed-SFW assets; nsfw/undecided are recorded skipped without
  a request. Provider is an injected adapter (real OpenAI-compatible Gemini
  call extracted from photo_analyzer.analyze_image; a fake in tests).
- LibraryService: Library search + Stats read model ported from webapp/query.py
  (LIKE search in place of FTS5; facets, top tags, years, albums, people).
- WorkflowService + GET /api/v1/workflow: per-stage readiness derived from the
  source tables — counts, blockers, last-run, action, and an active_job that
  drives read-only-during-jobs. Safety scoring and analysis run as durable jobs
  under the library_write lock via new domain handlers, so a second mutating
  job is refused.
- routes: workflow, safety (queue/counts/decisions/jobs), analysis
  (counts/results/jobs), library (assets/facets/stats).

Frontend
- five views (frontend/js/views.js) on the US02-05 shell: Workflow stepper
  (status text+icon, not colour alone; actions disabled with a reason while a
  job runs), Safety review (filter tabs, decide, persists across reload),
  Library (search + cards), Analyze (counts + live job log via the SSE
  adapter), Stats. Shared DOM helpers extracted to dom.js; Workflow is the home
  route.

Tests
- integration: provider-call privacy (nsfw never reaches the provider),
  sfw→nsfw flip drops analysis eligibility, decision persistence, one-mutating-
  job rejection, workflow counts, and the exiftool safety-keyword write/verify.
- e2e: Workflow cards, actions disabled+explained during a job, safety
  decide-persists-across-reload, Library search, Stats, Analyze counts.
- traceability map updated for US02-05 and US02-06.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
domverse merged commit b59bc93fcb into main 2026-08-09 20:10:59 +02:00
Sign in to join this conversation.