diff --git a/wiki/SharedContracts.md b/wiki/SharedContracts.md index c222ef2..4662736 100644 --- a/wiki/SharedContracts.md +++ b/wiki/SharedContracts.md @@ -148,6 +148,37 @@ StructuralSelector heading/section/AST path FragmentSelector exported fragment / deep link (export-only) ``` +Field shapes (non-PDF selectors, EANCH-WP-0003): + +```ts +type DomNodePath = readonly number[]; + +interface DomRangeSelector { + type: "DomRangeSelector"; + startPath: DomNodePath; + startOffset: number; + endPath: DomNodePath; + endOffset: number; +} + +interface StructuralPathSegment { + kind: "heading" | "section" | "block"; + index: number; + level?: number; + label?: string; +} + +interface StructuralSelector { + type: "StructuralSelector"; + path: readonly StructuralPathSegment[]; + startOffset: number; + endOffset: number; +} +``` + +`StructureMap` on `DocumentRepresentation` maps canonical-text spans to +structural paths. Ingest may omit it; viewer adapters populate at selection time. + **Selector redundancy rule:** when an annotation is created, the system stores *all selector types that are available* for that document representation, not just one. Resolution tries them in order of expected confidence and stops at @@ -218,8 +249,32 @@ interface DocumentViewerAdapter { } ``` -MVP delivers a single `PDFViewerAdapter`. HTML and Markdown adapters are -deferred. +MVP delivers a single `PDFViewerAdapter`. HTML and Markdown adapters ship in +`evidence-anchor/dom`. + +`SelectionCapture` is a discriminated union: + +```ts +interface PdfSelectionCapture { + kind: "pdf"; + text: string; + page: number; + rects: readonly NormalizedRect[]; + boundingRect?: NormalizedRect; +} + +interface DomSelectionCapture { + kind: "dom"; + text: string; + startPath: DomNodePath; + startOffset: number; + endPath: DomNodePath; + endOffset: number; + structuralPath?: readonly StructuralPathSegment[]; +} + +type SelectionCapture = PdfSelectionCapture | DomSelectionCapture; +``` ---