WeKnora/internal/application
tayadwx 911a1490ea
fix(wiki): enrich cited chunk content with image captions in Reduce phase 实体/摘要页面引用子块时同样使用富文本内容 (#3292)
* fix(wiki): enrich cited chunk content with image captions in Reduce phase

The citation-pass comment claims image/ocr chunks are "already merged
into the text content via reconstructEnrichedContent", but that function
has exactly one call site — the per-document summary page. The Reduce /
page-edit phase resolves cited chunks straight from the repository and
feeds the LLM bare Markdown image links with no caption or OCR context.

This mismatch is observable: on concept/entity pages generated from an
image-heavy knowledge base, the page-editing model receives
![filename](wkimg:NNN) with no way to judge the image, and empirically
either copies the image links verbatim or drops them wholesale —
including real content images. A controlled experiment where the same
image reached two pages byte-identically produced opposite keep/drop
decisions, and <image_caption> appeared in 0 of 9 outgoing page-edit
requests.

resolveCitedChunks now collects image_info for the cited text chunks
(CollectImageInfoByChunkIDs, one query per knowledge batch, outside the
per-page loop) and inlines it with EnrichContentWithImageInfo — the same
enrichment the summary path uses. Image info collection skips disabled
child chunks, so downstream decorative-image cleanup composes with this
path automatically.

* test(wiki): cover cited-chunk image enrichment in resolveCitedChunks

Add unit tests asserting that cited text chunks reach the Reduce phase
enriched with caption/OCR info from their enabled image child chunks,
that disabled children are skipped (decorative-image cleanup composes),
and that unknown chunk IDs still fall through gracefully.

---------

Co-authored-by: tayadwx <tayadwx@users.noreply.github.com>
2026-09-21 13:13:48 +08:00
..
access feat(artifacts): let users delete generated files (#3447) 2026-09-20 13:01:46 +08:00
repository fix(queue): order ClaimBatch by fail_count so retries cannot starve new work (#3444) 2026-09-21 13:00:29 +08:00
service fix(wiki): enrich cited chunk content with image captions in Reduce phase 实体/摘要页面引用子块时同样使用富文本内容 (#3292) 2026-09-21 13:13:48 +08:00