Promote DomRange and Structural selector types for non-PDF anchoring
All checks were successful
CI Smoke / host-smoke (push) Successful in 1s
CI Smoke / container-smoke (push) Successful in 9s

Define real DomRangeSelector, StructuralSelector, StructureMap, and
containerPath fields so evidence-anchor can implement HTML/Markdown
selector creation and resolution. Update SharedContracts.md with field
shapes and DomSelectionCapture payload.
This commit is contained in:
tegwick 2026-07-09 09:18:42 +02:00
parent 67a3d82dfa
commit 86d10e7e90
3 changed files with 111 additions and 12 deletions

View file

@ -148,6 +148,38 @@ 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[]; // child-index path from document root
interface DomRangeSelector {
type: "DomRangeSelector";
startPath: DomNodePath;
startOffset: number;
endPath: DomNodePath;
endOffset: number;
}
interface StructuralPathSegment {
kind: "heading" | "section" | "block";
index: number;
level?: number; // headings only
label?: string;
}
interface StructuralSelector {
type: "StructuralSelector";
path: readonly StructuralPathSegment[];
startOffset: number;
endOffset: number;
}
```
`StructureMap` on `DocumentRepresentation` maps canonical-text spans to
structural paths (sorted, non-overlapping). Ingest pipelines may omit it;
viewer adapters populate it 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 +250,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;
```
---