Implement CE-WP-0003 T01-T08: form binding + visual guide overlay

T01 EvidenceLink/EvidenceSet types
  - src/shared/evidence-link.ts: status (§2.4), relation (§2.5), target
  - src/shared/evidence-set.ts: ordered group + activeEvidenceItemId
  - enum-conformance test parses SharedContracts.md and asserts the
    runtime lists match exactly

T02 Binding service + in-memory link repo + active-state machine
  - src/binder/repos/in-memory-links.ts: Map-backed EvidenceLinkRepository
  - src/binder/services/bindings.ts: link/unlink/list/update/setActive
    emitting §4 EvidenceLinkCreated / EvidenceLinkUpdated /
    EvidenceItemActivated
  - src/binder/state/active.ts: (target, evidence, annotation) reducer
    + ActiveStateProvider + useActiveState hook
  - extended engine/events/types.ts with EvidenceLinkCreated,
    EvidenceLinkUpdated, FormFieldActivated payloads

T03 Rect registry (SharedContracts §7 — contract FROZEN)
  - src/binder/visual-guide/rect-registry.ts: register/getRect/subscribe
    + invalidate + getVersion for useSyncExternalStore
  - events.ts: scroll/resize/focus pumps via window + ResizeObserver +
    IntersectionObserver, rAF-throttled
  - react-hooks.ts: RectRegistryProvider, useRegisterRect(kind,id,ref),
    useRectRegistryVersion

T04 Form schema + renderer
  - src/app/forms/demo-schema.ts: text/textarea/date minimal schema
  - src/binder/FormRenderer.tsx: renders schema, each field registers
    as rect kind="field"; active field gets aria-current="true"
  - placed in binder/ (not work/) because work cannot import binder per
    DependencyMap.md §2 and the renderer needs the rect-registry hook;
    workplan T04 was amended in-place to document this

T05 Side-by-side Forms layout + click-to-link
  - src/app/forms/FormsApp.tsx + src/app/App.tsx top-bar router with
    hash route #/forms/demo
  - BinderProvider mounted at app root so links survive tab switching
  - stage-evidence-then-click-field linking interaction with banner
    + per-field link-count chip

T06 Active-evidence cycling
  - src/app/forms/ActiveEvidenceChips.tsx: chips per active target,
    Tab cycles natively, first chip auto-activates on field focus,
    each chip registers as rect kind="evidence-card"
  - ScrollBridge in FormsApp wires activeAnnotationId to viewer scroll
  - EvidenceSidebar + EvidenceStrip highlight the active item via the
    new useLastActivatedEvidence hook in work/EngineContext

T07 SVG visual-guide overlay
  - src/binder/visual-guide/Overlay.tsx: single fixed-positioned SVG,
    draws field→card and card→highlight bezier curves for the active
    triple, rAF-throttled via the registry
  - src/anchor exposes getHighlightClientRects(annotationId); the
    spike viewer wraps highlights in [data-highlight-id] so the helper
    can locate them
  - src/app/forms/HighlightRectBridge.tsx: registers the active
    annotation's rect via that helper

T08 End-to-end test (PRD scenario steps 5-9)
  - tests/integration/forms-overlay-e2e.dom.test.tsx: full path from
    Review-mode capture through Forms-mode link to active triple +
    aria-current assertions + 2 SVG paths in the overlay
  - additional integration coverage: forms-link-flow + forms-active-cycling

Gates: typecheck ✓ · lint ✓ · build ✓ · 152/152 tests across 21 files.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-05-25 15:53:17 +02:00
parent d54daf2e61
commit 8607c252c4
40 changed files with 3321 additions and 41 deletions

View File

@@ -8,10 +8,10 @@ repo_id: a677c189-b4e2-4f2a-9e48-faa482c277e6
topic_slug: citation_evidence_mvp
topic_id: 96fa8e80-9f74-40f2-84cd-644e9747b9ec
state_hub_workstream_id: 7b5b7235-57e3-4835-8fa6-376bb518fe2d
status: todo
status: done
owner: Bernd
created: 2026-05-24
updated: 2026-05-24
updated: 2026-05-25
depends_on_workplan: CE-WP-0002
spec_refs:
- wiki/ProductRequirementsDocument.md
@@ -58,7 +58,7 @@ T01 (EvidenceLink + EvidenceSet types + relation/status enums)
id: CE-WP-0003-T01
state_hub_task_id: 120b9b5a-9ca3-4dff-8c26-1b5c2e832dc4
priority: critical
status: todo
status: done
```
Add under `src/shared/`:
@@ -82,7 +82,7 @@ updating the doc, the test fails.
id: CE-WP-0003-T02
state_hub_task_id: f17e251d-4fd7-4ef3-b35c-e8e0dfb3a455
priority: high
status: todo
status: done
depends_on: [T01]
```
@@ -106,7 +106,7 @@ Emit the events from SharedContracts §4 (`EvidenceLinkCreated`,
id: CE-WP-0003-T03
state_hub_task_id: d3b853ef-7afe-491f-b40b-b6e980a23478
priority: critical
status: todo
status: done
depends_on: [T02]
```
@@ -134,7 +134,7 @@ it in T05/T06/T07.
id: CE-WP-0003-T04
state_hub_task_id: f42e1ecc-351c-4248-8872-1a25e79d3640
priority: medium
status: todo
status: done
depends_on: [T01]
```
@@ -150,7 +150,12 @@ type FormFieldSchema =
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
- `src/binder/FormRenderer.tsx` renders the schema as a basic form
(relocated from `src/work/` per `wiki/DependencyMap.md` §2/§5 — `work`
cannot import `binder`, but FormRenderer needs `useRegisterRect` from
`binder/visual-guide`. The "evidence-backed form" composition belongs
in `binder/`; `app/` mounts both `work` panes and `binder` panes
side-by-side.)
- Each field registers itself with the rect registry as kind `"field"` with
the field's `id`
@@ -162,7 +167,7 @@ just needs to render 3-4 fields and accept evidence links.
id: CE-WP-0003-T05
state_hub_task_id: 100fb1ca-6168-4e5d-9dc5-f051e6f9ff61
priority: high
status: todo
status: done
depends_on: [T02, T04]
```
@@ -185,7 +190,7 @@ linked fields (e.g. a chip showing the count of linked evidence items).
id: CE-WP-0003-T06
state_hub_task_id: e3bdf1d3-c7a1-484c-8895-8d103e7f9fe6
priority: high
status: todo
status: done
depends_on: [T05]
```
@@ -209,7 +214,7 @@ Each evidence card registers itself with the rect registry as
id: CE-WP-0003-T07
state_hub_task_id: e2ec50be-d9c5-47dd-b801-9c1afb01e6fd
priority: high
status: todo
status: done
depends_on: [T03, T06]
```
@@ -237,7 +242,7 @@ registered.
id: CE-WP-0003-T08
state_hub_task_id: e6754c8e-f9e2-435a-af28-31a693c6d9a8
priority: high
status: todo
status: done
depends_on: [T05, T07]
```