Import PDF and EPUB knowledge
Status: Ready
Article ID: 027
Truth label: Limited
Audience: Knowledge operator
Reader outcome: Ingest an approved text PDF or EPUB while preserving page or chapter provenance and respecting the server-side file-access boundary.
Related articles: 007, 026, 028
Target week: 11
Last verified: 2026-09-13
Technical reviewer: Codex source audit
Editorial reviewer: Codex editorial audit
Two paths into Brain
This lesson covers the direct ingestion route, which reads a file or directory on the Brain host into a knowledge collection. For a book you intend to reason with, the Sources workflow in Cortex is the better path: it uploads the file, lets you review the extraction and its quality report, preview passage boundaries, publish the source under a stable id, and later replace or retire it. See Sources and influences. The checks below apply to both.
Approve the source first
Before ingestion, confirm that the material may be stored, embedded, searched, backed up, and possibly included in a model prompt. Check copyright, contract, client confidentiality, provider policy, retention, and deletion needs.
Use a copy with no annotations or attachments that would expose private data. Do not ingest raw traces, credential files, exports of client systems, or an entire directory simply because the route accepts a path.
Know what the loader preserves
For a text PDF, Brain extracts each page with content and records title, optional author, page number, and page count. For an EPUB, it follows the linear spine, extracts readable HTML text, and records title, optional author, language, chapter label, chapter index, and archive member.
Brain then splits each page or chapter into overlapping chunks while retaining the segment metadata. Search results can therefore point back to a page or chapter rather than citing an unmarked block from the whole book.
Understand selection and safety checks
Directory ingestion supports text, Markdown, source, structured-text, PDF,
and EPUB extensions while ignoring common hidden and dependency directories.
When the same base filename has both EPUB and PDF forms, the selector prefers
EPUB and records the PDF as a duplicate-format skip. For influence libraries,
an influence_pack.toml file declares source rules (match, glob, dir) that
determine how passages are tagged for reasoning lenses.
The loader rejects oversized files, excessive PDF pages, oversized PDF streams, unsafe EPUB archive paths, excessive members, and large expanded archives. Encrypted PDFs without an empty password are not ingested.
Ingest one controlled path
The ingestion request names a server-side file or directory path, collection,
and optional project or influence id. Brain enforces collection guarding on
POST /knowledge/ingest, rejecting attempts to overwrite protected
prompt-bearing collections such as voice_examples. Start with one approved
file. Review the result for selected files, skipped duplicates, segments,
chunks, and errors.
Then search for several known passages. Verify the returned source, title, page or chapter, and nearby text against the original. Successful chunk creation is not proof that extraction retained tables, footnotes, formulas, or reading order correctly.
Plan correction and removal
Record the source owner, file hash or edition, ingestion date, collection, and reviewer outside the prose itself. When a source changes, re-ingest it through the same resolved path so prior chunks for that source are replaced.
If the source must be withdrawn, remove its documents from the collection and handle backups under the applicable retention procedure. Search the index after removal to confirm that the record is no longer returned.
Current limits
The ingestion path is resolved on the Brain server. While collection guarding
protects system collections such as voice_examples, the route remains
operator-only. Extraction is text-based and can lose complex layout. Current
knowledge and direct-document scope controls are not complete confidential
multi-client isolation.
Next lesson
Continue with Why scanned documents need OCR.
Derivative map
- Weekly package: WEEK-11
- Long video: VIDEO-W11-LONG
- Shorts: SHORT-W11-PROBLEM, SHORT-W11-MECHANISM, SHORT-W11-WARNING
- Email: EMAIL-W11
- LinkedIn: LI-W11-A, LI-W11-B
- X: X-W11-A, X-W11-B
- Visual: VISUAL-W11
Review record
- PDF, EPUB, selection, chunking, provenance, replacement, and safety behavior checked against current source.
- Rights, server-side path, scope, layout, retention, and deletion limits reviewed.
- Procedure starts with one approved file and exposes no private path.
- Internal links and repository voice reviewed.
Review completed: 2026-09-03
Re-audited against the running product: 2026-09-13