generated from coulomb/repo-seed
Establish shared-contracts home, dependency map, MVP workplans, and umbrella-first strategy
- INTENT.md: declare umbrella as the home for shared contracts; document umbrella-first MVP decision (code lives here until subsystems stabilize) - wiki/SharedContracts.md: vocabulary, state enums, relation types, selector taxonomy, event vocabulary, viewer adapter contract, canonical text normalization, rect-registry contract - wiki/DependencyMap.md: allowed dependency edges; folder layout + lint-rule strategy during umbrella-first phase - history/2026-05-24-initial-assessment.md: alignment review, technical risks, and the umbrella-first pivot rationale - workplans/CE-WP-0001..0004: four ralph-compatible workplans covering foundations, PDF review slice, form binding + visual guide, and citation card export — implementing PRD §20 end-to-end Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
246
workplans/CE-WP-0001-foundations.md
Normal file
246
workplans/CE-WP-0001-foundations.md
Normal file
@@ -0,0 +1,246 @@
|
||||
---
|
||||
id: CE-WP-0001
|
||||
type: workplan
|
||||
title: "Foundations — TS scaffold, folder layout, lint boundaries, normalization, fixtures"
|
||||
domain: citation_evidence
|
||||
repo: citation-evidence
|
||||
repo_id: a677c189-b4e2-4f2a-9e48-faa482c277e6
|
||||
status: todo
|
||||
owner: Bernd
|
||||
created: 2026-05-24
|
||||
updated: 2026-05-24
|
||||
spec_refs:
|
||||
- wiki/ProductRequirementsDocument.md
|
||||
- wiki/ArchitectureOverview.md
|
||||
- wiki/SharedContracts.md
|
||||
- wiki/DependencyMap.md
|
||||
---
|
||||
|
||||
# CE-WP-0001 — Foundations
|
||||
|
||||
Establish the skeleton of the umbrella-first MVP: a TypeScript project with
|
||||
a folder layout that mirrors the future subsystem split (so that extracting
|
||||
to sister repos later is a `git mv` plus a `package.json` cut), lint rules
|
||||
that enforce the dependency map at the folder level, the versioned
|
||||
canonical-text normalization function, and a small but representative PDF
|
||||
fixtures corpus.
|
||||
|
||||
No product features yet. This workplan exists so that everything from
|
||||
`CE-WP-0002` onward has somewhere to land.
|
||||
|
||||
## Decisions captured here
|
||||
|
||||
Each task below corresponds to a Phase-0 ADR. The ADR lives at
|
||||
`docs/decisions/ADR-NNNN-<slug>.md`. If a task involves a choice that wasn't
|
||||
already decided, the agent stops and asks Bernd before writing code.
|
||||
|
||||
## Dependency Order
|
||||
|
||||
```
|
||||
T01 (toolchain decision + package.json)
|
||||
└─ T02 (folder layout per DependencyMap §4)
|
||||
└─ T03 (lint rules enforcing dep edges)
|
||||
└─ T04 (canonical text normalization v1, versioned)
|
||||
└─ T05 (fixtures: 5+ representative PDFs + a manifest)
|
||||
└─ T06 (README upgrade + dev workflow doc)
|
||||
└─ T07 (write the six pending ADRs as stubs)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## T01 — Toolchain + package.json + tsconfig
|
||||
|
||||
```task
|
||||
id: CE-WP-0001-T01
|
||||
priority: critical
|
||||
status: todo
|
||||
```
|
||||
|
||||
Decide the TS toolchain (vite vs tsc-only vs Next.js) and write a single
|
||||
`package.json` at the repo root. Decisions to lock in this task as an ADR
|
||||
(`docs/decisions/ADR-0001-toolchain.md`):
|
||||
|
||||
- Bundler: vite (recommended, fastest dev loop for a React MVP)
|
||||
- Package manager: pnpm (recommended, plays well with future workspace split)
|
||||
- React 18+
|
||||
- Strict TS
|
||||
|
||||
Deliverables:
|
||||
- `package.json` with `dev`, `build`, `test`, `lint`, `typecheck` scripts
|
||||
- `tsconfig.json` with strict mode, paths for the `src/` partitions
|
||||
- `.nvmrc` pinning Node version
|
||||
- `docs/decisions/ADR-0001-toolchain.md` written and committed
|
||||
|
||||
Do not install application dependencies yet — just the toolchain.
|
||||
|
||||
---
|
||||
|
||||
## T02 — Folder layout matching DependencyMap §4
|
||||
|
||||
```task
|
||||
id: CE-WP-0001-T02
|
||||
priority: critical
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
Create the source folder layout:
|
||||
|
||||
```
|
||||
src/
|
||||
shared/ # will become @citation-evidence/engine (types + contracts)
|
||||
engine/ # will become @citation-evidence/engine (services)
|
||||
anchor/ # will become @citation-evidence/anchor
|
||||
source/ # will become @citation-evidence/source
|
||||
work/ # will become @citation-evidence/work (UI)
|
||||
binder/ # will become @citation-evidence/binder
|
||||
app/ # the reference workspace shell
|
||||
```
|
||||
|
||||
Each folder gets:
|
||||
- A one-line `README.md` stating its future home
|
||||
- An `index.ts` that re-exports its public API (empty for now)
|
||||
|
||||
Add path aliases in `tsconfig.json`: `@shared/*`, `@engine/*`, etc.
|
||||
|
||||
---
|
||||
|
||||
## T03 — Lint rules enforcing dependency edges
|
||||
|
||||
```task
|
||||
id: CE-WP-0001-T03
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T02]
|
||||
```
|
||||
|
||||
Install `eslint-plugin-boundaries` (or equivalent) and configure rules per
|
||||
`wiki/DependencyMap.md` §4:
|
||||
|
||||
| Folder | May import from |
|
||||
|--------------|--------------------------------------------------|
|
||||
| `shared/` | (nothing internal) |
|
||||
| `engine/` | `shared/` |
|
||||
| `anchor/` | `shared/`, `engine/` |
|
||||
| `source/` | `shared/`, `engine/` |
|
||||
| `binder/` | `shared/`, `engine/`, `anchor/` |
|
||||
| `work/` | `shared/`, `engine/`, `anchor/`, `source/` |
|
||||
| `app/` | any |
|
||||
|
||||
Add a failing test fixture that imports `source/` from `binder/` and confirm
|
||||
lint catches it; remove the fixture afterward.
|
||||
|
||||
`npm run lint` must pass on a clean tree.
|
||||
|
||||
---
|
||||
|
||||
## T04 — Canonical text normalization v1
|
||||
|
||||
```task
|
||||
id: CE-WP-0001-T04
|
||||
priority: critical
|
||||
status: todo
|
||||
depends_on: [T02]
|
||||
```
|
||||
|
||||
Implement `src/shared/text/normalize.ts` per `wiki/SharedContracts.md` §6:
|
||||
|
||||
1. Unicode NFC
|
||||
2. Normalize line endings to `\n`
|
||||
3. Collapse horizontal whitespace runs to a single space
|
||||
4. Strip soft hyphens (U+00AD)
|
||||
5. Preserve paragraph boundaries (`\n\n`)
|
||||
|
||||
Public API:
|
||||
|
||||
```ts
|
||||
export const NORMALIZE_VERSION = 1;
|
||||
export function normalize(input: string): { text: string; version: number };
|
||||
```
|
||||
|
||||
Include unit tests covering: ligatures, CRLF input, soft-hyphenated German,
|
||||
mixed whitespace, paragraph preservation.
|
||||
|
||||
Stored selectors will record this version number so that future normalization
|
||||
changes can be detected as a migration concern.
|
||||
|
||||
---
|
||||
|
||||
## T05 — PDF fixtures corpus + manifest
|
||||
|
||||
```task
|
||||
id: CE-WP-0001-T05
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
Assemble `fixtures/pdfs/` with at least 5 representative PDFs:
|
||||
|
||||
- A simple single-column text PDF
|
||||
- A two-column academic PDF (e.g. ACM-style)
|
||||
- A German PDF with umlauts and soft hyphens
|
||||
- A form PDF (e.g. a public-sector application form)
|
||||
- A PDF with a heading hierarchy
|
||||
|
||||
Write `fixtures/pdfs/manifest.json` recording for each:
|
||||
- filename
|
||||
- short description
|
||||
- expected page count
|
||||
- one short "known-good quote" with the page number it appears on (used by
|
||||
CE-WP-0002 selector tests)
|
||||
|
||||
Keep each PDF small (< 1 MB) and check sources/licenses into
|
||||
`fixtures/pdfs/SOURCES.md`. Public-domain or Bernd-authored only.
|
||||
|
||||
---
|
||||
|
||||
## T06 — README upgrade + dev workflow doc
|
||||
|
||||
```task
|
||||
id: CE-WP-0001-T06
|
||||
priority: medium
|
||||
status: todo
|
||||
depends_on: [T01, T02]
|
||||
```
|
||||
|
||||
Replace the one-line `README.md` with a real one:
|
||||
|
||||
- What citation-evidence is (one paragraph from INTENT)
|
||||
- Repository layout (point at `src/` partitions and what each becomes)
|
||||
- Where to find docs (`wiki/`, `docs/decisions/`, `history/`, `workplans/`)
|
||||
- Dev workflow: `pnpm install`, `pnpm dev`, `pnpm test`, `pnpm lint`
|
||||
- Pointer to `~/ralph-workplan/` for how workplans are driven
|
||||
|
||||
Add a one-paragraph `README.md` in each of the five sister repos pointing
|
||||
back at this umbrella + reminding readers that code lives upstream during
|
||||
the MVP phase.
|
||||
|
||||
---
|
||||
|
||||
## T07 — Stub the six pending ADRs
|
||||
|
||||
```task
|
||||
id: CE-WP-0001-T07
|
||||
priority: medium
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
Create stub files in `docs/decisions/` for each ADR mentioned in
|
||||
`wiki/SharedContracts.md` §10:
|
||||
|
||||
- `ADR-0001-toolchain.md` (filled in by T01)
|
||||
- `ADR-0002-monorepo-vs-polyrepo.md`
|
||||
- `ADR-0003-w3c-mapping-scope.md`
|
||||
- `ADR-0004-pdf-viewer-library.md`
|
||||
- `ADR-0005-persistence.md`
|
||||
- `ADR-0006-selector-ownership-split.md`
|
||||
|
||||
Each stub: title, status (`proposed` for 2-6), context (one paragraph
|
||||
explaining what the decision is about and why it matters), options (bullet
|
||||
list with pros/cons), decision (blank), consequences (blank).
|
||||
|
||||
These are not decisions yet — they are *the questions that must be answered
|
||||
before the relevant code lands*. The MVP can proceed without 2-6 being
|
||||
resolved because no extraction or persistence happens until later workplans.
|
||||
283
workplans/CE-WP-0002-pdf-review-slice.md
Normal file
283
workplans/CE-WP-0002-pdf-review-slice.md
Normal file
@@ -0,0 +1,283 @@
|
||||
---
|
||||
id: CE-WP-0002
|
||||
type: workplan
|
||||
title: "PDF review slice — engine types, anchor, source, viewer, sidebar, click-to-reopen"
|
||||
domain: citation_evidence
|
||||
repo: citation-evidence
|
||||
repo_id: a677c189-b4e2-4f2a-9e48-faa482c277e6
|
||||
status: todo
|
||||
owner: Bernd
|
||||
created: 2026-05-24
|
||||
updated: 2026-05-24
|
||||
depends_on_workplan: CE-WP-0001
|
||||
spec_refs:
|
||||
- wiki/ProductRequirementsDocument.md
|
||||
- wiki/ArchitectureOverview.md
|
||||
- wiki/SharedContracts.md
|
||||
---
|
||||
|
||||
# CE-WP-0002 — PDF Review Slice
|
||||
|
||||
The first vertical product slice. After this workplan, a user can:
|
||||
|
||||
1. Open the app, see a collection of fixture PDFs.
|
||||
2. Open one PDF in a viewer.
|
||||
3. Select text, add a one-line comment, save as an evidence item.
|
||||
4. See the evidence item appear in a sidebar.
|
||||
5. Click the evidence item and have the PDF jump to and highlight the
|
||||
passage — even after a full page reload.
|
||||
|
||||
No forms, no Markdown/HTML, no recovery, no export. Those come later.
|
||||
|
||||
This workplan exercises the riskiest architectural assumption (PDF selector
|
||||
round-trip with viewer independence) on the simplest possible feature set.
|
||||
|
||||
## Risk-driven order
|
||||
|
||||
T01 and T02 are the spike from the assessment: prove the
|
||||
`react-pdf-highlighter-plus` integration can store and reload selectors
|
||||
without leaking viewer types into engine code. If that breaks, the rest of
|
||||
the workplan stops and a new ADR is required for ADR-0004 (PDF viewer choice).
|
||||
|
||||
## Dependency Order
|
||||
|
||||
```
|
||||
T01 (engine types: Document, Representation, Annotation, Selector, EvidenceItem)
|
||||
└─ T02 (PDF viewer adapter spike — store + reload selectors as JSON)
|
||||
└─ T03 (evidence-source: PDF ingest, fingerprint, canonical text)
|
||||
└─ T04 (evidence-anchor: TextQuote + TextPosition resolution against representation)
|
||||
└─ T05 (in-memory repositories + engine services)
|
||||
└─ T06 (citation-work UI: collection list + viewer shell + sidebar)
|
||||
└─ T07 (annotation create flow)
|
||||
└─ T08 (click-to-reopen flow)
|
||||
└─ T09 (end-to-end test of PRD scenario steps 1-4)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## T01 — Engine types in `src/shared/`
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T01
|
||||
priority: critical
|
||||
status: todo
|
||||
```
|
||||
|
||||
Translate the type definitions in `wiki/SharedContracts.md` §1 and §3 into
|
||||
TypeScript under `src/shared/`:
|
||||
|
||||
- `src/shared/document.ts` — `Document`, `DocumentRepresentation`, `PageMap`,
|
||||
`OffsetMap`
|
||||
- `src/shared/selector.ts` — `Selector` discriminated union with at minimum
|
||||
`TextQuoteSelector`, `TextPositionSelector`, `PdfRectSelector`,
|
||||
`PdfPageTextSelector`. Other selector kinds defined as `never`-typed stubs
|
||||
for now.
|
||||
- `src/shared/annotation.ts` — `Annotation` with `selectors`, `quote`,
|
||||
`note`, `normalizeVersion`
|
||||
- `src/shared/evidence.ts` — `EvidenceItem`, `EvidenceItem.status` enum per
|
||||
§2.2
|
||||
- `src/shared/ids.ts` — branded ID types and a `newId(prefix)` helper
|
||||
|
||||
No services, no behavior. Pure data shapes + the ID helper.
|
||||
|
||||
Add JSDoc on each type pointing at the §-reference in
|
||||
`wiki/SharedContracts.md` it implements.
|
||||
|
||||
---
|
||||
|
||||
## T02 — PDF viewer adapter spike
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T02
|
||||
priority: critical
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
**This is the architectural spike.** Build a throwaway
|
||||
`src/anchor/pdf-viewer-adapter-spike.tsx` that:
|
||||
|
||||
1. Loads `fixtures/pdfs/simple.pdf` using `react-pdf-highlighter-plus`
|
||||
(assumed; if a better library appears, document it in ADR-0004 before
|
||||
committing).
|
||||
2. Lets the user select text and produces selectors per `T01` shapes.
|
||||
3. Serializes the selectors to a JSON blob in `localStorage`.
|
||||
4. On reload, reads the blob, asks the adapter to resolve, scrolls to the
|
||||
passage, and renders a highlight.
|
||||
|
||||
Success criteria:
|
||||
- Reload-and-resolve works for all fixture PDFs.
|
||||
- No PDF.js or `react-pdf-highlighter-plus` types appear in any file under
|
||||
`src/shared/` or `src/engine/`.
|
||||
- The adapter's public surface matches the contract in
|
||||
`wiki/SharedContracts.md` §5.
|
||||
|
||||
If success criteria fail: stop. Write a short note in
|
||||
`docs/decisions/ADR-0004-pdf-viewer-library.md` describing the failure mode
|
||||
and proposed alternative. Do not proceed with T03+.
|
||||
|
||||
---
|
||||
|
||||
## T03 — `src/source/`: PDF ingest, fingerprint, canonical text
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T03
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T02]
|
||||
```
|
||||
|
||||
Implement under `src/source/pdf/`:
|
||||
|
||||
- `ingest.ts` — `ingestPdf(file: File | Buffer): Promise<{ document: Document; representation: DocumentRepresentation }>`
|
||||
- `fingerprint.ts` — stable SHA-256 of bytes
|
||||
- `extract.ts` — uses PDF.js to extract page text; runs `normalize()` from
|
||||
T04 of WP-0001 over the canonical text; builds the `PageMap` and
|
||||
`OffsetMap` per `Document.DocumentRepresentation`
|
||||
|
||||
Tests use the fixture corpus from `CE-WP-0001-T05`. For each fixture,
|
||||
extracted canonical text must contain the manifest's known-good quote.
|
||||
|
||||
---
|
||||
|
||||
## T04 — `src/anchor/`: TextQuote and TextPosition resolution
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T04
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T01, T03]
|
||||
```
|
||||
|
||||
Implement under `src/anchor/`:
|
||||
|
||||
- `selectors/create.ts` — given a `SelectionCapture` from the adapter, build
|
||||
the maximal set of available selectors (always `TextQuoteSelector` with
|
||||
prefix/suffix; `TextPositionSelector` when the representation provides
|
||||
offsets; PDF rect/text selectors when on PDF)
|
||||
- `selectors/resolve.ts` — implements the resolution strategy from
|
||||
`wiki/ArchitectureOverview.md` §7 (try position, verify quote, fall back
|
||||
through quote+prefix/suffix, return `AnchorResolution`)
|
||||
- `selectors/types.ts` — `AnchorResolution`, `SelectionCapture`,
|
||||
`ResolvedAnchorTarget`
|
||||
|
||||
Fuzzy matching is out of scope here — return `unresolved` if exact+prefix/suffix
|
||||
fails. Fuzzy is a later workplan.
|
||||
|
||||
Unit tests using fixtures: for each fixture+known-quote pair, create
|
||||
selectors then immediately resolve them; resolution must succeed with
|
||||
confidence ≥ 0.9.
|
||||
|
||||
---
|
||||
|
||||
## T05 — In-memory repositories + engine services
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T05
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
Under `src/engine/`:
|
||||
|
||||
- `repos/in-memory.ts` — `Map`-backed implementations of
|
||||
`DocumentRepository`, `AnnotationRepository`, `EvidenceItemRepository`
|
||||
- `services/documents.ts`, `services/annotations.ts`, `services/evidence.ts`
|
||||
— thin orchestration layer that creates IDs, calls repos, and emits the
|
||||
events from `wiki/SharedContracts.md` §4
|
||||
- `events/bus.ts` — minimal pub/sub. Synchronous for MVP.
|
||||
|
||||
No persistence to disk yet. ADR-0005 (persistence) is still pending.
|
||||
|
||||
---
|
||||
|
||||
## T06 — `src/work/`: collection list + viewer shell + sidebar
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T06
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T02, T05]
|
||||
```
|
||||
|
||||
Under `src/work/` and `src/app/`:
|
||||
|
||||
- `src/app/App.tsx` — three-pane layout per Architecture §12.1: collection
|
||||
list (left), viewer (centre), evidence sidebar (right)
|
||||
- `src/work/CollectionList.tsx` — lists `fixtures/pdfs/manifest.json`
|
||||
entries; click to load
|
||||
- `src/work/ViewerShell.tsx` — hosts the viewer adapter from T02 wrapped
|
||||
cleanly; viewer adapter API is the only surface `work/` uses
|
||||
- `src/work/EvidenceSidebar.tsx` — lists evidence items for the current
|
||||
document, shows quote + commentary + status
|
||||
|
||||
No styling beyond minimum legibility. CSS in Tailwind or vanilla — pick one,
|
||||
note in ADR-0001 if it wasn't already.
|
||||
|
||||
---
|
||||
|
||||
## T07 — Annotation create flow
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T07
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T04, T05, T06]
|
||||
```
|
||||
|
||||
Wire selection → annotation → evidence item:
|
||||
|
||||
1. User selects text in the viewer.
|
||||
2. A small toolbar appears with a comment input + Save button.
|
||||
3. On Save: adapter produces `SelectionCapture` → anchor creates `Selector[]`
|
||||
→ engine creates `Annotation` → engine creates `EvidenceItem` with the
|
||||
commentary → sidebar updates.
|
||||
|
||||
Active state lives in a single React context for now; no Redux/Zustand.
|
||||
|
||||
---
|
||||
|
||||
## T08 — Click-to-reopen flow
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T08
|
||||
priority: critical
|
||||
status: todo
|
||||
depends_on: [T04, T06, T07]
|
||||
```
|
||||
|
||||
Implement the round trip:
|
||||
|
||||
1. User clicks an evidence item in the sidebar.
|
||||
2. Engine loads the annotation → anchor resolves selectors against the
|
||||
current representation → adapter scrolls to and highlights the target.
|
||||
|
||||
Critically, this must also work **after a page reload**. Persistence to
|
||||
`localStorage` is acceptable for MVP (decide explicitly in
|
||||
`ADR-0005-persistence.md` that we are deferring real persistence).
|
||||
|
||||
---
|
||||
|
||||
## T09 — End-to-end test of PRD scenario steps 1-4
|
||||
|
||||
```task
|
||||
id: CE-WP-0002-T09
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T07, T08]
|
||||
```
|
||||
|
||||
Write a Playwright (or similar) E2E test that:
|
||||
|
||||
1. Opens the app.
|
||||
2. Picks `simple.pdf`.
|
||||
3. Programmatically selects the known-good quote from the manifest.
|
||||
4. Saves an evidence item with a comment.
|
||||
5. Verifies the item appears in the sidebar.
|
||||
6. Reloads the page.
|
||||
7. Clicks the evidence item.
|
||||
8. Verifies the highlight is rendered on the expected page.
|
||||
|
||||
This is the contract for "MVP slice 1 works". If it passes, CE-WP-0003 may
|
||||
begin.
|
||||
246
workplans/CE-WP-0003-form-binding-visual-guide.md
Normal file
246
workplans/CE-WP-0003-form-binding-visual-guide.md
Normal file
@@ -0,0 +1,246 @@
|
||||
---
|
||||
id: CE-WP-0003
|
||||
type: workplan
|
||||
title: "Form binding + visual guide — EvidenceLink, rect registry, SVG overlay"
|
||||
domain: citation_evidence
|
||||
repo: citation-evidence
|
||||
repo_id: a677c189-b4e2-4f2a-9e48-faa482c277e6
|
||||
status: todo
|
||||
owner: Bernd
|
||||
created: 2026-05-24
|
||||
updated: 2026-05-24
|
||||
depends_on_workplan: CE-WP-0002
|
||||
spec_refs:
|
||||
- wiki/ProductRequirementsDocument.md
|
||||
- wiki/ArchitectureOverview.md
|
||||
- wiki/SharedContracts.md
|
||||
---
|
||||
|
||||
# CE-WP-0003 — Form Binding + Visual Guide
|
||||
|
||||
Build the evidence-backed form mode and the SVG visual guide overlay.
|
||||
After this workplan, a user can:
|
||||
|
||||
1. Open a form next to the document viewer.
|
||||
2. Drag (or click-to-link) an evidence item from the sidebar onto a form
|
||||
field.
|
||||
3. Click a form field → its linked evidence items appear → the active
|
||||
evidence's source passage is scrolled into view and highlighted → an SVG
|
||||
guide visually connects the field, the evidence card, and the highlight.
|
||||
4. Cycle through multiple evidence items on the same field.
|
||||
|
||||
This is the workplan that stress-tests the rect-registry contract from
|
||||
`wiki/SharedContracts.md` §7. The form, the evidence card, and the viewer's
|
||||
highlight all need to publish rects to a single overlay that re-renders on
|
||||
scroll/resize/focus.
|
||||
|
||||
## Dependency Order
|
||||
|
||||
```
|
||||
T01 (EvidenceLink + EvidenceSet types + relation/status enums)
|
||||
└─ T02 (binding service + in-memory link repo + active-state machine)
|
||||
└─ T03 (rect registry — the contract from SharedContracts.md §7)
|
||||
└─ T04 (form schema + simple field renderer)
|
||||
└─ T05 (side-by-side layout + drag-or-click to link)
|
||||
└─ T06 (active-evidence cycling on a field)
|
||||
└─ T07 (SVG visual guide overlay)
|
||||
└─ T08 (E2E test of PRD scenario steps 5-9)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## T01 — `EvidenceLink` + `EvidenceSet` types
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T01
|
||||
priority: critical
|
||||
status: todo
|
||||
```
|
||||
|
||||
Add under `src/shared/`:
|
||||
|
||||
- `src/shared/evidence-link.ts` — `EvidenceLink`, `EvidenceLink.status`
|
||||
enum per SharedContracts §2.4, `EvidenceLink.relation` enum per §2.5,
|
||||
`EvidenceTarget` generic shape
|
||||
- `src/shared/evidence-set.ts` — `EvidenceSet` with `activeEvidenceItemId`
|
||||
|
||||
No services. Pure shapes.
|
||||
|
||||
Add a unit test asserting that the union of all enum values matches the
|
||||
`SharedContracts.md` lists exactly — if someone adds a value without
|
||||
updating the doc, the test fails.
|
||||
|
||||
---
|
||||
|
||||
## T02 — Binding service + in-memory link repo + active-state machine
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T02
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
Under `src/binder/`:
|
||||
|
||||
- `repos/in-memory-links.ts` — Map-backed `EvidenceLinkRepository`
|
||||
- `services/bindings.ts` — `linkEvidenceToTarget`, `unlinkEvidence`,
|
||||
`listEvidenceForTarget`, `setActiveEvidence`
|
||||
- `state/active.ts` — a small machine tracking
|
||||
`(activeTarget, activeEvidenceItem, activeAnnotation)`. Exposed as a React
|
||||
context.
|
||||
|
||||
Emit the events from SharedContracts §4 (`EvidenceLinkCreated`,
|
||||
`EvidenceItemActivated`, `FormFieldActivated`).
|
||||
|
||||
---
|
||||
|
||||
## T03 — Rect registry (the SharedContracts §7 contract)
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T03
|
||||
priority: critical
|
||||
status: todo
|
||||
depends_on: [T02]
|
||||
```
|
||||
|
||||
Implement under `src/binder/visual-guide/`:
|
||||
|
||||
- `rect-registry.ts` — `RectRegistry` with `register`, `getRect`,
|
||||
`subscribe` per SharedContracts §7
|
||||
- `react-hooks.ts` — `useRegisterRect(kind, id, ref)` for components to
|
||||
register a ref-derived rect
|
||||
- `events.ts` — registry emits `rect-changed` events on
|
||||
scroll/resize/focus/active-evidence-change (use ResizeObserver +
|
||||
IntersectionObserver + window resize + window scroll listeners)
|
||||
|
||||
Unit tests: register a fake field, evidence card, and highlight; mutate
|
||||
their bounding rects; assert subscribers fire with the new rects.
|
||||
|
||||
**This contract must not change after T03.** Three subsystems will depend on
|
||||
it in T05/T06/T07.
|
||||
|
||||
---
|
||||
|
||||
## T04 — Form schema + simple field renderer
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T04
|
||||
priority: medium
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
A deliberately minimal form schema lives in `src/app/forms/demo-schema.ts`:
|
||||
|
||||
```ts
|
||||
type FormFieldSchema =
|
||||
| { type: "text"; id: string; label: string }
|
||||
| { type: "textarea"; id: string; label: string }
|
||||
| { type: "date"; id: string; label: string };
|
||||
```
|
||||
|
||||
JSON Schema is **not** used yet — defer that to a later ADR. The MVP form
|
||||
just needs to render 3-4 fields and accept evidence links.
|
||||
|
||||
- `src/work/FormRenderer.tsx` renders the schema as a basic form
|
||||
- Each field registers itself with the rect registry as kind `"field"` with
|
||||
the field's `id`
|
||||
|
||||
---
|
||||
|
||||
## T05 — Side-by-side layout + link evidence to field
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T05
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T02, T04]
|
||||
```
|
||||
|
||||
A new app route `/forms/demo` shows the side-by-side layout from Architecture
|
||||
§12.2:
|
||||
|
||||
- Left: `FormRenderer` with a demo schema (3 fields)
|
||||
- Right: viewer (reusing `ViewerShell` from CE-WP-0002)
|
||||
- Bottom strip or popover: evidence list
|
||||
|
||||
Linking interaction: click an evidence item, then click a field → link
|
||||
created. (Drag-and-drop is a polish item, not MVP.) Visual indication on
|
||||
linked fields (e.g. a chip showing the count of linked evidence items).
|
||||
|
||||
---
|
||||
|
||||
## T06 — Active-evidence cycling on a field
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T06
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T05]
|
||||
```
|
||||
|
||||
When a field is focused:
|
||||
|
||||
1. Binder loads the field's evidence set.
|
||||
2. The first evidence item becomes active.
|
||||
3. The viewer scrolls to and highlights its annotation.
|
||||
4. Keyboard `Tab`/`Shift-Tab` within the field's evidence chips cycles
|
||||
active evidence; viewer scrolls accordingly.
|
||||
5. The evidence sidebar highlights the active evidence card.
|
||||
|
||||
Each evidence card registers itself with the rect registry as
|
||||
`"evidence-card"`.
|
||||
|
||||
---
|
||||
|
||||
## T07 — SVG visual guide overlay
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T07
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T03, T06]
|
||||
```
|
||||
|
||||
Implement `src/binder/visual-guide/Overlay.tsx`:
|
||||
|
||||
- Single absolutely-positioned SVG covering the viewport
|
||||
- Subscribes to the rect registry
|
||||
- On every change, redraws two curves: `field → evidence-card` and
|
||||
`evidence-card → highlight`
|
||||
- Active-only — only the currently active triple gets drawn
|
||||
- Throttled to animation frames
|
||||
|
||||
Acceptance: scroll the viewer, resize the window, change active evidence —
|
||||
the guide tracks every change without visible lag.
|
||||
|
||||
The viewer adapter from CE-WP-0002 must expose
|
||||
`getHighlightClientRects(annotationId)` so the highlight's rect can be
|
||||
registered.
|
||||
|
||||
---
|
||||
|
||||
## T08 — E2E test of PRD scenario steps 5-9
|
||||
|
||||
```task
|
||||
id: CE-WP-0003-T08
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T05, T07]
|
||||
```
|
||||
|
||||
Extend the Playwright E2E from CE-WP-0002-T09:
|
||||
|
||||
5. Navigate to `/forms/demo`.
|
||||
6. Link the previously-created evidence item to the "summary" field.
|
||||
7. Click the "summary" field.
|
||||
8. Assert the field, the evidence card, and the highlight all have an
|
||||
`aria-current="true"` (or equivalent active marker).
|
||||
9. Assert the SVG overlay contains exactly two `<path>` elements (one
|
||||
field→card, one card→highlight).
|
||||
10. Scroll the viewer; assert the SVG paths' endpoints update within the
|
||||
next animation frame.
|
||||
|
||||
If this passes, the form-binding slice is complete and CE-WP-0004 may run
|
||||
in parallel with any deferred polish work.
|
||||
164
workplans/CE-WP-0004-citation-card-export.md
Normal file
164
workplans/CE-WP-0004-citation-card-export.md
Normal file
@@ -0,0 +1,164 @@
|
||||
---
|
||||
id: CE-WP-0004
|
||||
type: workplan
|
||||
title: "Citation card export — Markdown and HTML renderers, sidebar export"
|
||||
domain: citation_evidence
|
||||
repo: citation-evidence
|
||||
repo_id: a677c189-b4e2-4f2a-9e48-faa482c277e6
|
||||
status: todo
|
||||
owner: Bernd
|
||||
created: 2026-05-24
|
||||
updated: 2026-05-24
|
||||
depends_on_workplan: CE-WP-0002
|
||||
spec_refs:
|
||||
- wiki/ProductRequirementsDocument.md
|
||||
- wiki/ArchitectureOverview.md
|
||||
- wiki/SharedContracts.md
|
||||
---
|
||||
|
||||
# CE-WP-0004 — Citation Card Export
|
||||
|
||||
The final step of the MVP scenario: turn an evidence item into a portable
|
||||
Markdown or HTML citation card.
|
||||
|
||||
After this workplan, a user can:
|
||||
|
||||
1. Click "Export" on an evidence item in the sidebar.
|
||||
2. Choose Markdown or HTML.
|
||||
3. Get a clipboard-ready citation card with quote, source label,
|
||||
commentary, and a link back to source context.
|
||||
|
||||
This workplan can run in parallel with CE-WP-0003 once CE-WP-0002 is done —
|
||||
it touches different code paths.
|
||||
|
||||
## Dependency Order
|
||||
|
||||
```
|
||||
T01 (CitationCard type + open-context URL convention)
|
||||
└─ T02 (Markdown renderer)
|
||||
└─ T03 (HTML renderer)
|
||||
└─ T04 (sidebar Export button + copy-to-clipboard)
|
||||
└─ T05 (E2E test of PRD scenario step 10)
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## T01 — `CitationCard` type + open-context URL convention
|
||||
|
||||
```task
|
||||
id: CE-WP-0004-T01
|
||||
priority: high
|
||||
status: todo
|
||||
```
|
||||
|
||||
Under `src/shared/`:
|
||||
|
||||
- `src/shared/citation-card.ts` — `CitationCard` per Architecture §4.7
|
||||
- `src/shared/open-context-url.ts` — function `openContextUrl(annotationId)`
|
||||
returning a URL of the form
|
||||
`/viewer?document=<docId>&annotation=<annId>` (per Architecture §14.3)
|
||||
|
||||
The URL is the deep link that an exported card uses to reopen the source
|
||||
context in this MVP. When persistence becomes real (post-MVP), the URL
|
||||
scheme stays the same.
|
||||
|
||||
---
|
||||
|
||||
## T02 — Markdown citation card renderer
|
||||
|
||||
```task
|
||||
id: CE-WP-0004-T02
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
Under `src/engine/rendering/`:
|
||||
|
||||
- `markdown.ts` — `renderCitationCardMarkdown(evidenceItem, document, annotation): string`
|
||||
|
||||
Output format (lock this in `docs/decisions/ADR-0007-citation-card-format.md`):
|
||||
|
||||
```markdown
|
||||
> {quote}
|
||||
|
||||
— *{sourceLabel}* · [Open source]({openContextUrl})
|
||||
|
||||
{commentary}
|
||||
```
|
||||
|
||||
Where `sourceLabel` is `document.title` if present, else the filename, else
|
||||
the document URI.
|
||||
|
||||
Unit tests: snapshot a few rendered cards against fixtures.
|
||||
|
||||
---
|
||||
|
||||
## T03 — HTML citation card renderer
|
||||
|
||||
```task
|
||||
id: CE-WP-0004-T03
|
||||
priority: high
|
||||
status: todo
|
||||
depends_on: [T01]
|
||||
```
|
||||
|
||||
Under `src/engine/rendering/`:
|
||||
|
||||
- `html.ts` — `renderCitationCardHtml(evidenceItem, document, annotation): string`
|
||||
|
||||
Output: a single `<aside class="citation-card">` element with `<blockquote>`,
|
||||
`<cite>`, `<a>` (open context), and `<div class="commentary">`. Inline
|
||||
styles avoided — host page provides CSS. Sanitize commentary as plain text
|
||||
(no raw HTML pass-through).
|
||||
|
||||
Web component `<citation-card>` from Architecture §14.2 is *not* in scope
|
||||
here — it ships in a later workplan.
|
||||
|
||||
---
|
||||
|
||||
## T04 — Sidebar Export button + copy-to-clipboard
|
||||
|
||||
```task
|
||||
id: CE-WP-0004-T04
|
||||
priority: medium
|
||||
status: todo
|
||||
depends_on: [T02, T03]
|
||||
```
|
||||
|
||||
Add to `src/work/EvidenceSidebar.tsx`:
|
||||
|
||||
- Per evidence item: an "Export" affordance (icon button or menu)
|
||||
- On click: small popover with two buttons, "Copy as Markdown" and
|
||||
"Copy as HTML"
|
||||
- On click: render via T02/T03 and write to clipboard with the standard
|
||||
`navigator.clipboard` API; show a transient confirmation toast
|
||||
|
||||
Keyboard shortcut `Cmd/Ctrl+Shift+C` exports the active evidence item as
|
||||
Markdown (the most common action).
|
||||
|
||||
---
|
||||
|
||||
## T05 — E2E test of PRD scenario step 10
|
||||
|
||||
```task
|
||||
id: CE-WP-0004-T05
|
||||
priority: medium
|
||||
status: todo
|
||||
depends_on: [T04]
|
||||
```
|
||||
|
||||
Extend the Playwright E2E:
|
||||
|
||||
10. After the earlier steps, click Export → Copy as Markdown on the saved
|
||||
evidence item.
|
||||
11. Read the clipboard; assert it contains the quote text, the document
|
||||
title, the commentary, and a URL matching the
|
||||
`/viewer?document=...&annotation=...` shape.
|
||||
|
||||
If this passes, MVP scenario steps 1-10 are all green and the
|
||||
umbrella-first MVP is *done* for the first reference scenario from PRD §20.
|
||||
|
||||
The next workplan (post-MVP) would be `CE-WP-0005` to either extract the
|
||||
first stable subsystem (likely `citation-engine`) into its own repo or to
|
||||
add Markdown/HTML document support.
|
||||
41
workplans/README.md
Normal file
41
workplans/README.md
Normal file
@@ -0,0 +1,41 @@
|
||||
# MVP Workplans
|
||||
|
||||
These four workplans implement the **first reference scenario** from
|
||||
`wiki/ProductRequirementsDocument.md` §20 — end-to-end PDF evidence
|
||||
capture → form binding → citation card export — entirely inside the
|
||||
`citation-evidence` repository.
|
||||
|
||||
| Workplan | Title | Status |
|
||||
|----------|----------------------------------------|--------|
|
||||
| `CE-WP-0001` | Foundations — scaffold, folders, lint rules, normalize, fixtures | todo |
|
||||
| `CE-WP-0002` | PDF review slice — engine types, anchor, source, viewer, sidebar | todo |
|
||||
| `CE-WP-0003` | Form binding + visual guide — EvidenceLink, rect registry, overlay | todo |
|
||||
| `CE-WP-0004` | Citation card export — Markdown + HTML renderers, sidebar export | todo |
|
||||
|
||||
## Order
|
||||
|
||||
Strictly sequential. `CE-WP-0002` depends on the folder/lint scaffolding from
|
||||
`CE-WP-0001`. `CE-WP-0003` and `CE-WP-0004` depend on the engine types,
|
||||
viewer adapter, and sidebar from `CE-WP-0002`.
|
||||
|
||||
## How to run a workplan
|
||||
|
||||
```
|
||||
/ralph-workplan workplans/CE-WP-0001-foundations.md
|
||||
```
|
||||
|
||||
Ralph drives the loop and retires automatically when all tasks in the
|
||||
workplan are marked `done`. See `~/.claude/plugins/ralph-workplan/ralph-workplan.md`.
|
||||
|
||||
## Acceptance for MVP
|
||||
|
||||
The first reference scenario from PRD §20 runs end-to-end:
|
||||
|
||||
1. Create a collection
|
||||
2. Upload a PDF
|
||||
3. Select a passage, add commentary, create an evidence item
|
||||
4. Open a side-by-side form
|
||||
5. Link the evidence item to a form field
|
||||
6. Focus the field → field, evidence card, and PDF passage all highlighted
|
||||
7. SVG guide visible between field → card → highlight
|
||||
8. Export evidence as a Markdown citation card
|
||||
Reference in New Issue
Block a user