Implement ESRC-WP-0002/0003/0004: HTML/MD ingest, metadata, recovery
Add ingestHtml and ingestMarkdown with ADR-0003 pageless offset semantics, PDF intrinsic metadata extraction with caller-wins merge (WP-0003), and citation recovery primitives including re-ingest reconcile, local quote search, and pluggable discovery hooks (ADR-0004). Mark all three workplans finished with contract tests (80 passing).
This commit is contained in:
parent
df6acad828
commit
97437dfa18
28 changed files with 1295 additions and 69 deletions
33
src/recovery/re-ingest.ts
Normal file
33
src/recovery/re-ingest.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import type { Document, DocumentRepresentation } from "@citation-evidence/engine/shared";
|
||||
|
||||
import { reconcileFingerprint, type ReconcileResult } from "./reconcile";
|
||||
|
||||
export interface IngestOutcome {
|
||||
readonly document: Document;
|
||||
readonly representation: DocumentRepresentation;
|
||||
}
|
||||
|
||||
export type IngestFn<TOptions = void> = (
|
||||
bytes: Uint8Array,
|
||||
options?: TOptions,
|
||||
) => Promise<IngestOutcome>;
|
||||
|
||||
export interface ReIngestInput<TOptions = void> {
|
||||
readonly previous: Document;
|
||||
readonly bytes: Uint8Array;
|
||||
readonly options?: TOptions;
|
||||
}
|
||||
|
||||
export interface ReIngestResult {
|
||||
readonly outcome: IngestOutcome;
|
||||
readonly reconcile: ReconcileResult;
|
||||
}
|
||||
|
||||
export async function reIngestAndCompare<TOptions>(
|
||||
input: ReIngestInput<TOptions>,
|
||||
ingest: IngestFn<TOptions>,
|
||||
): Promise<ReIngestResult> {
|
||||
const outcome = await ingest(input.bytes, input.options);
|
||||
const reconcile = reconcileFingerprint(input.previous, outcome.document);
|
||||
return { outcome, reconcile };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue