# Evidence Desk

**Work in progress — a working local retrieval prototype by Neha Desai.**

Find exact passages across a small text library, inspect their source context, and export a traceable evidence bundle. AI synthesis is planned; this version does not call an LLM or generate answers.

Live demo: https://neha-pd.github.io/evidence-desk/

## What works today

- Three explicitly fictional sample policies.
- Add text documents, import `.txt` files, inspect and remove sources.
- BM25 keyword retrieval across document paragraphs, with the top three matching passages.
- Exact source text, query-term highlights and clickable passage citations.
- Export a JSON evidence bundle with question, exact passages, matched terms and source identifiers.
- Browser-local persistence and confirmation before deleting or restoring samples.
- Responsive layouts, native dialogs, keyboard focus and live status feedback.

## Run locally

No dependencies, API keys or build step. From this directory:

```sh
python3 -m http.server 8124 --bind 127.0.0.1
```

Open http://127.0.0.1:8124. Use localhost or HTTPS for secure-context APIs.

## Architecture

Plain HTML/CSS/JavaScript. Documents are split on blank lines into paragraphs. Unicode tokenization lowercases words and removes common English stopwords. BM25 uses `k1=1.2` and `b=0.75`; it ranks exact token matches with inverse document frequency and paragraph-length normalization. The three highest nonzero results are shown. Ranking numbers are positions, not confidence or accuracy scores.

All imported text is rendered with `textContent` / text nodes, including highlighted segments; it is never interpreted as HTML. No external scripts, analytics, retrieval servers or document uploads. Manrope is served locally with its SIL Open Font License in `assets/OFL.txt`. Browser localStorage stores the document library; the current query is session state. Files and exports are handled with browser APIs.

## Honest limits

No semantic retrieval, stemming, OCR, PDF/DOCX support, multilingual stopword tuning, authentication, cloud sync or LLM synthesis. Keyword overlap is not proof that a passage answers a question. Empty matches explicitly show no result. This prototype supports 20 documents, 50,000 characters per document and 300,000 total characters. A paragraph is a blank-line-delimited unit; long unbroken text remains one long passage.

localStorage is **not encrypted**. Anyone with access to this browser profile may read its stored documents. Do not use shared devices for sensitive material. A storage failure falls back to session-only state. No production security or accuracy certification is claimed.

## AI / RAG roadmap

A future version could add semantic retrieval and reranking, then an optional backend model provider for answers constrained to retrieved sources. This needs explicit data-sharing controls, server-side credential management, prompt-injection isolation, source-entailment checks, abstention and retrieval evaluation. None of that is represented as active functionality today.

## Validation

Native Chromium checks cover source addition, keyword search, exact citations/highlights, no-match handling, text injection safety, persistence, source deletion, `.txt` import, evidence export and mobile layout. The project is a portfolio prototype with fictional examples, not a deployed enterprise AI system.


## Redesigned research workspace

The source library can be filtered by title without changing what the evidence search retrieves. Its document and passage counts derive from the stored text. Mobile places the research flow first, with a Sources jump link to the library. The .txt import control is a native labeled file input inside a styled upload surface.

Theme follows the system on first visit; the header toggle stores an explicit light/dark preference. The original BM25 ranking, exact text rendering, import size/type limits, confirmation dialogs and JSON evidence export are retained. No LLM, cloud integration or fake collaboration controls were added.

Primary visual references and original implementation decisions are recorded in `artifacts/design-references.md`. Browser captures of the new interface and functional/automated-accessibility reports are in `artifacts/`. Run `python tests/browser.py http://127.0.0.1:8872` using Python Playwright/Chromium. The optional axe scan currently expects the workspace development tool at `../../reports/qa-tools/node_modules/axe-core/axe.min.js`; it is not shipped or used by the app. Automated checks do not replace a full screen-reader review.
