feat(media): controlled PDF text derivations
Motivation
This continues the useful direction from #33 by @RaviTharuma. Memorix can already register PDFs as controlled assets; page/chunk text extraction needs to be a managed derivative with the same lifecycle, not an optional runtime dependency hidden behind one MCP tool.
Scope
- Explicit PDF asset to page/chunk text derivatives with page/source provenance.
- A supported extraction dependency/provider contract suitable for global npm installation.
- Bounded page, byte, and timeout policy before any extraction starts.
- CLI as the complete management surface, with a bounded MCP operation and searchable text projection.
- Deletion, quota cleanup, and reindex behavior that remove or rebuild derived text consistently.
Acceptance
- Corrupt, encrypted, empty, oversized, and multipage PDFs have focused tests.
- CLI, MCP, and documentation describe the same behavior.
- The extractor never makes a PDF available for retrieval before its provenance and bounds are recorded.
Credit
Created to preserve and evolve the design contribution in #33. The original PR remains the source of the initial page-chunking proposal.
Proposed implementation plan: (1) define one shared controlled-derivative contract with asset hash, source reference, status, provenance, page/byte/time bounds, cancellation, cleanup, and reindex semantics; (2) add explicit PDF import and page/chunk text derivation; (3) expose complete CLI management plus a bounded MCP operation and searchable text projection; (4) cover corrupt, encrypted, empty, oversized, and multipage PDFs, provenance gating, deletion, quota, and reindex in focused tests and docs. Extraction must be explicit and must never happen merely because retrieval touched an asset. The implementation will preserve and credit #33/RaviTharuma.
Implementation is now in PR #187: https://github.com/AVIDS2/memorix/pull/187\n\nThe first slice is intentionally explicit and controlled: import stores the verified PDF only; derive-pdf extracts bounded page-aware text; --attach creates searchable page-range projections. It uses the shared derivation metadata contract so #174 audio can reuse the same persistence boundary. Focused tests, MCP integration tests, full build/lint, the full repository test suite, and a real Windows CLI smoke have passed. This issue should remain open until the PR is reviewed and merged, then we can add reindex/cleanup-specific acceptance if needed.
Implemented and merged in #187. The merged slice provides explicit controlled PDF import, bounded page-aware extraction, durable derivation metadata and failure audit, optional searchable page-range attachment, and the same bounded MCP operation. It passed local full tests, Windows/Ubuntu CI, packaged CLI checks, and a real Windows CLI smoke. Closing as complete; #174 should reuse this derivation contract for audio.