# STARTUP PROMPT — Fix Image Search in Online Knowledge

You are reviewing the ProductMCP online knowledge pipeline.
The pipeline scrapes www.prolicht.at, classifies pages via DeepSeek,
classifies images via Gemini, embeds everything with bge-m3,
and serves search via FAISS + SQLite enrichment.

## The problem

When users search for project photos (e.g. "show me Bethel project photos"),
the MCP returns product family pages with their images but NOT the actual
project reference page images. Users see product catalog shots instead of
reference project photos.

The root cause is identified across 7 issues in the uploaded
`IMPLEMENTATION-PLAN-DRAFT.md`. A detailed analysis is in the zip file.

## What you must do

Read `crawling-relations-problems-IMPLEMENTATION-PLAN-DRAFT.md` in this zip.
Implement the fixes in the order given:

1. **`pipeline_v2.py` — `build_and_embed()`**: Add image_description vector
   documents. Build text from `image_summaries.summary`, `images.ai_description`,
   category, page title, URL, segment, filename.

2. **`mcp_backend_knowledge.py` — `_enrich_results()`**: For product_family
   results, look up project_reference pages that use the same product_family
   and attach their representative images. Add debug fields for image counts.

3. **`mcp_backend_knowledge.py` — relation recall**: Remove `page_analysis`
   table join. Query `page_category` and `segment` directly from `pages`.

4. **Tool description**: Ensure `search_online_knowledge` tool description
   mentions `filter_category='project_reference'` for photo queries.

## Files you received

- All pipeline source code (11 Python files)
- Bethel page sample: `.md`, `.crawl.json`, `.images.json`, 3 images
- The implementation plan draft with specific code locations

## Rules

- Do not modify anything unrelated to the 7 issues listed.
- Do NOT strip navigation boilerplate from markdown — that's a separate problem
  tracked in `tasks/crawler-indexer-problems/001-boilerplate-family-hallucination.md`.
- After each file edit, run `python -m py_compile` and fix errors.
- Read `AGENTS.md` for project conventions.
- All `--force` flags already exist on pipeline scripts — use them only when needed.
- The coercion layer (`_coerce_result()` in pipeline_v2.py) already handles all
  known DeepSeek output quirks — do not modify it.

## Verification

After fixes, rebuild Docker and test:
```
Query: "show me photos of the Bethel Children's Centre project"
filter_category: "project_reference"
```

Expected: at least one result for Bethel with `images[]` containing
`image_id`, `image_url`, description, filename, category, quality_score.
