////

[rosaic-knowledge-agent] RKA's Google Drive loader only ingested .txt (28 files), silently skipping ~793

RKA's Google Drive loader only ingested .txt (28 files), silently skipping 793 important files: 146 pdf, 103 pptx, 96 docx, 354 csv, 44 hwpx (Korean Hangul XML), 32 hwp (Korean Hangul binary OLE), 18 xlsx. The bulk of co

////

Problem#

RKA's Google Drive loader only ingested .txt (28 files), silently skipping ~793 important files: 146 pdf, 103 pptx, 96 docx, 354 csv, 44 hwpx (Korean Hangul XML), 32 hwp (Korean Hangul binary OLE), 18 xlsx. The bulk of company knowledge was never entering the graph.

Solution#

Added rka/ingest/document_text.py: a per-extension extractor registry (txt/md/csv/tsv/docx/pptx/pdf/xlsx/hwp/hwpx). Libraries: python-docx (paragraphs + tables), python-pptx (slides + tables, prefix '[Slide N]'), PyMuPDF/fitz (page.get_text('text')), openpyxl (read_only+data_only, '[Sheet: name]'), pyhwp for HWP 5.0 binary via programmatic API from hwp5.xmlmodel import Hwp5File; from hwp5.hwp5txt import TextTransform; TextTransform().transform_hwp5_to_text(hwp, io.BytesIO()), and HWPX via stdlib zipfile+ElementTree (text is in Contents/section*.xml elements grouped by ; match by local-name to ignore the hp: namespace prefix). cp949/euc-kr decode fallback for Korean files (_TEXT_ENCODINGS tuple, try utf-8-sig/utf-8/cp949/euc-kr). gdrive_loader walks all SUPPORTED_EXTENSIONS; per-file parse failures raise DocumentParseError which the loader logs+skips so one bad file never aborts the batch. Smoke-tested all 8 formats on real Drive files - all extract clean Korean text. Merged to master 5eacb15, 325 tests.

Failure Modes#

(1) HWP (.hwp) is binary OLE compound, NOT XML - needs pyhwp; HWPX (.hwpx) is a zip of OWPML XML - totally different, parse with zipfile. Don't confuse them. (2) To run a parallel feature in a separate git worktree while another agent edits the main tree, the shared editable-install (.venv) still imports rka from the MAIN tree path, so worktree edits aren't seen by tests; fix by running PYTHONPATH=<worktree> .venv/bin/python -m pytest so the worktree shadows the editable install. (3) git branch -d refuses a branch merged to master if current HEAD is a different feature branch - it checks against HEAD, not master; verify with git branch --contains <sha> then use -D. (4) Some CSVs are huge ML data dumps (231K chars) not documents - downstream routing should decide relevance.