Evidence anchoring, selector, resolution for citations.
Find a file
tegwick 08b3105454 EANCH-WP-0001 T01: codify repo boundary and package shape
Finish SCOPE.md (boundary, maturity, deps, non-goals + capability blocks),
rewrite README.md as an extraction-oriented package doc with the initial
src/ module layout (selectors/pdf/highlight) and public API surface.
Selector types stay in citation-engine; selector behavior + viewer
contract owned here (ADR-0006 / SharedContracts §8).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-08 20:34:41 +02:00
.claude EANCH-WP-0001 T01: codify repo boundary and package shape 2026-07-08 20:34:41 +02:00
.forgejo/workflows Add Forgejo CI smoke workflow (enablement template) 2026-07-08 12:31:10 +02:00
registry Add registry/NO_CAPABILITIES.md (reuse-surface REUSE-WP-0017-T03) 2026-07-06 18:50:37 +02:00
workplans EANCH-WP-0001 T01: codify repo boundary and package shape 2026-07-08 20:34:41 +02:00
.custodian-brief.md chore(consistency): sync task status from DB [auto] 2026-07-08 20:25:55 +02:00
.gitignore Initial commit 2026-05-24 13:45:46 +00:00
.repo-classification.yaml Add .repo-classification.yaml (CUST-WP-0050 T11 agent first-pass) 2026-06-22 17:47:35 +02:00
AGENTS.md Regenerate agent instructions from state-hub templates (CUST-WP-0055 T01) 2026-07-08 14:50:20 +02:00
CLAUDE.md Normalize agent instructions and workplan frontmatter (STATE-WP-0067) 2026-06-22 23:16:24 +02:00
INTENT.md Add MVP Coordination section: code lives in citation-evidence umbrella during MVP 2026-05-24 16:51:04 +02:00
LICENSE Initial commit 2026-05-24 13:45:46 +00:00
README.md EANCH-WP-0001 T01: codify repo boundary and package shape 2026-07-08 20:34:41 +02:00
SCOPE.md EANCH-WP-0001 T01: codify repo boundary and package shape 2026-07-08 20:34:41 +02:00

evidence-anchor

Selector creation, resolution, and the DocumentViewerAdapter contract that every document viewer in the citation-evidence workspace implements. This repo turns annotations from static marks into durable, reopenable source references.

  • Owns: selector behaviorcreateSelectors, resolveSelectors, PDF selector math, the viewer-adapter contract, and highlight/scroll helpers.
  • Does not own: selector type interfaces — those live in citation-engine (shared/selector). See ADR-0006 and SharedContracts.md §8.
  • May depend on: citation-engine only (DependencyMap §4). Nothing from binder/, source/, or work/ may flow back into it.

See SCOPE.md for the boundary and INTENT.md for the long-range intent.

Status: extracting from the umbrella

The concrete anchor slice currently lives upstream in ../citation-evidence/src/anchor/. Workplan EANCH-WP-0001 moves it here as a standalone TypeScript package, wires the umbrella to consume this package, and verifies the round-trip. Shared-contract changes still happen in the umbrella (citation-evidence/wiki/), not here.

Install model

Sibling-checkout, linked-package model — this repo is checked out next to its consumers and consumed via a local link (e.g. link:../evidence-anchor), not published to a registry during MVP. Its only shared-type dependency is citation-engine, imported through the engine's public shared entrypoint (@citation-evidence/engine/shared) rather than umbrella-only @shared/* aliases.

Package layout (initial extracted version)

src/
  index.ts                      public entrypoint (re-exports the surfaces below)
  types.ts                      adapter-side types: SelectionCapture,
                                ResolvedAnchorTarget, AnchorResolution,
                                HighlightRenderOptions, DocumentViewerAdapter
  selectors/
    index.ts                    createSelectors, resolveSelectors, DEFAULT_CONTEXT_CHARS
    create.ts                   selector creation from a captured selection
    resolve.ts                  resolution + the exact-match confidence ladder
    create.test.ts
    resolve.test.ts
  pdf/
    pdf-selector-math.ts        page number + normalized page-rectangle math
    pdf-selector-math.test.ts
    pdf-viewer-adapter.tsx      concrete PDF DocumentViewerAdapter (from the spike)
  highlight/
    scroll-job.ts               scroll-to-target helper
    scroll-job.test.ts
    highlight-styles.css        highlight rendering styles
    debug-textlayer.css         optional text-layer debugging styles

Boundary rules for the layout:

  • viewer-library imports (pdfjs, react-pdf-highlighter-plus) are confined to src/pdf/ — they never appear on types.ts or on the public surface;
  • src/selectors/ is pure (no viewer/UI deps) and depends only on citation-engine shared types;
  • the public entrypoint re-exports the stable surface consumers rely on: createSelectors, resolveSelectors, the selector/resolution types, the DocumentViewerAdapter contract, and the PDF adapter.

Public API (target surface)

import {
  createSelectors,
  resolveSelectors,
  type DocumentViewerAdapter,
  type AnchorResolution,
} from "evidence-anchor";

Resolution is explicit about uncertainty — AnchorResolution.status is one of resolved / ambiguous / unresolved / stale with a 0..1 confidence, so a caller can highlight, ask the user to confirm, or mark a citation stale rather than silently highlight the wrong passage.