tegwick 779ae0d317 Implement CE-WP-0005 T01-T08: demo app — sessions, uploads, ZIP archive
Turn the MVP into a self-contained demo. Users now:
  1. Land on an empty-state and create a named session.
  2. Drag-drop or pick arbitrary PDFs into that session.
  3. Annotate, build evidence, link to form fields — all session-scoped.
  4. Export the whole session as a single .zip archive (manifest +
     per-document PDFs).
  5. Import a .zip back — into a new session, or merged into an
     existing one (documents deduped by SHA-256 fingerprint;
     annotations/evidence/links added additively).

Architecture:
- New shared types: SessionId, Session, SessionArchiveManifest +
  parseSessionArchiveManifest with schema-version validation.
- SessionService (engine/services/sessions.ts) handles lifecycle
  (create/rename/delete/setActive) + emits 4 new events through its
  own bus; SharedContracts.md §4 lists the additions.
- SessionProvider (work/SessionContext.tsx) owns the cross-session
  state: service, per-session PdfByteStore registry, per-session
  version counter that drives EngineProvider remounts after imports.
- EngineProvider becomes session-aware (sessionId prop drives per-
  session localStorage keys). Bumping engineRevision after
  restoreFromStorage forces consumers to re-render so restored repos
  show up immediately.
- PdfByteStore (source/pdf/byte-store.ts) holds Uint8Array bytes per
  document and mints blob URLs; ingestPdfFromFile is the upload
  entry-point that wraps the existing ingestPdf pipeline.
- ADR-0008 locks the ZIP layout (manifest.json + documents/<id>.pdf),
  the manifest schema (schemaVersion 1), and the merge-on-collision
  policy. JSZip is the only new dependency.
- App.tsx restructured: SessionProvider at the root, EngineProvider
  keyed by ${sessionId}:${version}, hash routing #/s/<id>[/forms/demo],
  SessionMenu top-bar, CreateFirstSession empty state.
- New DocumentRemoved event for per-document delete cleanup in
  CollectionList; engine.documents.remove() is the new service method.

Tests:
- Unit: 16 SessionService lifecycle + persistence tests;
  per-session snapshot round-trip; PdfByteStore + ingestPdfFromFile;
  SessionArchive parser; exportSessionZip + importSessionZip with
  create + merge + corrupt-archive paths.
- DOM: UploadDropzone, session-scoped CollectionList delete,
  SessionMenu create/switch/rename, routing parser.
- E2E: tests/integration/session-export-reimport.dom.test.tsx walks
  the full create → annotate → export → reimport flow and asserts
  the additive merge (deduped doc + doubled evidence rows).
- Legacy E2Es updated to use a seed-session helper instead of the
  removed fixture-button flow.

Known limitation (documented in ADR-0008): re-importing your own
freshly-exported ZIP creates duplicate annotations. Forward pointer
left for an importBundleId follow-up.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-26 14:57:28 +02:00
2026-05-24 13:20:45 +00:00

citation-evidence

A document-centered evidence workspace for capturing, managing, presenting, and re-opening citations. The umbrella over the six-package design described in INTENT.md and wiki/ArchitectureOverview.md.

During the MVP all code lives here under src/ (see "Repository layout" below). Sister repos hold INTENT only — code migrates outward when each subsystem stabilises.

Documentation

Where What
INTENT.md Project intent, scope, the umbrella-first decision
wiki/ PRD, Architecture, SharedContracts, DependencyMap
docs/decisions/ ADRs (architecturally significant decisions)
workplans/ Ralph-driven workplans that implement the MVP slice
history/ Time-stamped assessments and post-mortems

The canonical contracts are in wiki/SharedContracts.md; the partition boundaries are in wiki/DependencyMap.md. Both are referenced from every workplan and from each sister repo's INTENT.md.

Repository layout

src/
  shared/   # vocabulary, types, pure helpers      → becomes part of citation-engine
  engine/   # services, repositories, event bus    → becomes part of citation-engine
  anchor/   # selector creation/resolution, viewer adapter contract → becomes evidence-anchor
  source/   # ingest, fingerprint, extraction, recovery → becomes evidence-source
  binder/   # evidence-to-target binding, visual guide → becomes evidence-binder
  work/     # review UI (sidebar, viewer shell)    → becomes citation-work
  app/      # the reference workspace shell        → stays in citation-evidence

The dependency-edge rules between partitions are enforced by ESLint via eslint-plugin-boundaries (see eslint.config.js). Extraction to a sister repo is intended to be a git mv plus a package.json cut — nothing more.

Sister repos

Peers under ~/; each holds INTENT.md only during MVP:

Dev workflow

Requirements: Node 20 LTS (see .nvmrc) and pnpm 9.

pnpm install
pnpm dev        # vite dev server (once src/app/ has a real entry)
pnpm test       # vitest one-shot
pnpm test:watch
pnpm lint       # eslint with boundary rules
pnpm typecheck  # tsc --noEmit
pnpm build      # production bundle

Workplans (Ralph)

Workplans drive incremental implementation through the ralph loop. The harness lives in ~/ralph-workplan/; see workplans/README.md for the active list and ordering.

/ralph-workplan workplans/CE-WP-0001-foundations.md

The loop self-retires when every task in the file has status: done and the workplan's frontmatter status: done.

Description
document-centered evidence workspace for capturing, managing, presenting, and re-opening citations
Readme MIT-0 1.1 MiB
Languages
TypeScript 97.1%
Shell 1.3%
CSS 0.8%
JavaScript 0.6%
Makefile 0.1%