2026-06-22 23:16:24 +02:00
|
|
|
# SCOPE
|
|
|
|
|
|
|
|
|
|
> This file helps you quickly understand what this repository is about,
|
|
|
|
|
> when it is relevant, and when it is not.
|
|
|
|
|
> It is intentionally lightweight and may be incomplete.
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## One-liner
|
|
|
|
|
|
2026-07-09 01:48:28 +02:00
|
|
|
Headless document ingest that turns PDF, HTML, and Markdown bytes into
|
|
|
|
|
engine-owned evidence contracts (fingerprint, canonical text, page/offset maps).
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Core Idea
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
The rest of the citation-evidence ecosystem (anchoring, evidence linking,
|
|
|
|
|
binders) needs a stable, runtime-agnostic way to go from *raw document bytes*
|
|
|
|
|
to a `Document` + `DocumentRepresentation`. This repo owns that transformation
|
2026-07-09 01:48:28 +02:00
|
|
|
for PDF, HTML, and Markdown — pure over bytes, no persistence, no viewer,
|
|
|
|
|
no UI framework.
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## In Scope
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- PDF byte ingest → `{ document, representation }` (`ingestPdf`)
|
2026-07-09 01:48:28 +02:00
|
|
|
- HTML byte ingest → `{ document, representation }` (`ingestHtml`)
|
|
|
|
|
- Markdown byte ingest → `{ document, representation }` (`ingestMarkdown`)
|
2026-07-08 20:55:28 +02:00
|
|
|
- PDF text extraction → canonical text + page map + gap-free offset map (`extractPdf`)
|
2026-07-09 01:48:28 +02:00
|
|
|
- PDF intrinsic metadata extraction with caller-wins merge (`extractPdfMetadata`)
|
2026-07-08 20:55:28 +02:00
|
|
|
- SHA-256 byte fingerprinting (`fingerprintBytes`)
|
2026-07-09 01:48:28 +02:00
|
|
|
- Citation recovery primitives: re-ingest/reconcile, local quote search, discovery hooks
|
2026-07-08 20:55:28 +02:00
|
|
|
- Browser upload helpers behind a separate entry point (`createPdfByteStore`, `ingestPdfFromFile`)
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Out of Scope
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- Persisting documents or representations (caller's job)
|
|
|
|
|
- Viewer URL resolution and blob-vs-fixture policy (stays in `citation-evidence`)
|
2026-07-09 01:48:28 +02:00
|
|
|
- Stale selector detection and anchor resolution (stays in `evidence-anchor`)
|
|
|
|
|
- Network-backed external source discovery implementations (host registers hooks)
|
2026-07-08 20:55:28 +02:00
|
|
|
- Defining domain contracts — those are owned by `citation-engine`
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Relevant When
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- You have PDF bytes and need engine-shaped evidence contracts
|
|
|
|
|
- You need a deterministic content fingerprint of document bytes
|
|
|
|
|
- You are wiring a new consumer to ingest without pulling in a viewer
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Not Relevant When
|
|
|
|
|
|
2026-07-09 01:48:28 +02:00
|
|
|
- You need formats beyond PDF/HTML/Markdown (not yet implemented)
|
2026-07-08 20:55:28 +02:00
|
|
|
- You need viewer/session/UI behavior (see `citation-evidence`)
|
|
|
|
|
- You are changing the `Document`/`DocumentRepresentation` contract (see `citation-engine`)
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Current State
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- Status: active
|
2026-07-09 01:48:28 +02:00
|
|
|
- Implementation: partial (PDF/HTML/MD ingest, metadata enrichment, recovery primitives)
|
2026-07-08 20:55:28 +02:00
|
|
|
- Stability: evolving
|
|
|
|
|
- Usage: internal (consumed by `citation-evidence` across the repo boundary)
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## How It Fits
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- Upstream dependencies: `citation-engine` (`@citation-evidence/engine/shared`)
|
|
|
|
|
- Downstream consumers: `citation-evidence` (umbrella app)
|
|
|
|
|
- Often used with: `citation-engine`, `citation-evidence`
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Terminology
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- Preferred terms: ingest, canonical text, fingerprint, representation
|
|
|
|
|
- Also known as: "source" (its former location was `citation-evidence/src/source/`)
|
|
|
|
|
- Potentially confusing terms: "representation" (a derived view of a document, not the document itself)
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Related / Overlapping Repositories
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- `citation-engine` — owns the shared `Document`/`DocumentRepresentation` contracts this repo produces
|
|
|
|
|
- `citation-evidence` — umbrella app that consumes this ingest core; still owns viewer-url resolution
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Getting Oriented
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- Start with: `README.md`, then `docs/ADR-0001-extraction-boundary.md`
|
2026-07-09 01:48:28 +02:00
|
|
|
- Key files / directories: `src/pdf/`, `src/html/`, `src/markdown/`, `src/recovery/`, `src/browser/`
|
2026-07-08 20:55:28 +02:00
|
|
|
- Entry points: `src/index.ts` (headless), `src/browser/index.ts` (browser)
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Provided Capabilities
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
- `capability.infotech.pdf-evidence-ingest` — headless PDF → evidence contracts
|
|
|
|
|
(see `registry/capabilities/`)
|
2026-06-22 23:16:24 +02:00
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
## Notes
|
|
|
|
|
|
2026-07-08 20:55:28 +02:00
|
|
|
Fixture corpus is owned upstream by `citation-evidence` and resolved from a
|
|
|
|
|
sibling checkout (ADR-0002); it is not duplicated here.
|