evidence-to-target binding and active evidence state
```
**evidence-anchor** should operate close to document representations and viewers, but it should not become a viewer implementation itself.
It should define the anchoring contract and provide reusable anchoring logic.
---
## Design Principles
### Selector Redundancy
A durable citation should not rely on a single selector.
Where possible, the system should store multiple selectors that can support each other:
```text
visual selectors
text selectors
structural selectors
context selectors
```
### Viewer Independence
Anchors should not depend on one specific PDF viewer, Markdown renderer, HTML renderer, or frontend framework.
Viewer adapters may provide selection and rendering details, but the anchor model should remain portable.
### Format Neutrality
The anchoring model should work across paginated and non-paginated documents.
PDFs, Markdown, HTML, plain text, and future formats should share the same resolution concepts.
### Confidence Over Certainty
Anchor resolution should return a confidence level, not just success or failure.
Some matches are exact. Some are probable. Some are ambiguous. Some are unresolved.
The API should make this explicit.
### Human Confirmation for Ambiguity
When multiple possible matches exist or fuzzy matching is uncertain, the repository should support workflows that ask the user or calling system to confirm the correct target.
### Preserve the Quote
Even if an anchor can no longer be resolved, the original quote and context should remain available through the annotation or evidence item.
### No Silent Misleading Match
It is better to report an unresolved or ambiguous citation than to confidently highlight the wrong passage.
---
## Initial Selector Types
The first version should support or prepare for these selector concepts:
```text id="qtvj9s"
TextQuoteSelector
exact selected text plus prefix and suffix context
TextPositionSelector
canonical start and end offsets in normalized text
PdfRectSelector
page number and normalized page rectangles
PdfPageTextSelector
page number plus page-local text offsets
DomRangeSelector
DOM path and range offsets for rendered HTML
StructuralSelector
heading, section, block, or AST path information
FragmentSelector
optional exported fragment or deep-link representation
```
The repository should align with W3C Web Annotation selector concepts where practical, without forcing all internal logic into JSON-LD.
---
## Anchor Resolution Strategy
A typical resolution pipeline should be:
```text id="eug5uu"
1. Check document and representation identity.
2. Try exact position-based selectors.
3. Verify resolved text against the stored quote.
4. Try PDF page and rectangle selectors where applicable.
5. Try text quote matching with prefix and suffix.
6. Try structural or heading context.
7. Try fuzzy quote matching.
8. Rank candidate matches by confidence.
9. Return resolved, ambiguous, stale, or unresolved status.
```
The caller should receive enough information to decide whether to:
* highlight the passage,
* ask the user to confirm,
* mark the citation as stale,
* manually reattach the annotation.
---
## Core Interfaces
The repository should eventually provide interfaces similar to: