Extract binder package from citation-evidence (EBIND-WP-0001)
All checks were successful
CI Smoke / host-smoke (push) Successful in 0s
CI Smoke / container-smoke (push) Successful in 2s

Extracts citation-evidence/src/binder/ into this repo as the standalone
@citation-evidence/evidence-binder package: headless binding service +
in-memory link repo, active-state machine, the SharedContracts §7
rect-registry contract (registry, change pumps, hooks, SVG overlay), and
the target-neutral reference FormRenderer.

- toolchain mirrors sibling extracted repos (pnpm/tsc/vitest/eslint);
  imports rewritten from @shared/@engine aliases to the engine's
  @citation-evidence/engine package specifiers
- dependency boundary (engine + anchor only; no source/work/umbrella)
  enforced via eslint no-restricted-imports
- docs: extraction inventory + contract deltas, ADR-0001 (reference UI
  kept as supported exports), refreshed README/SCOPE/INTENT, populated
  capabilities index
- typecheck + lint green, 37 tests passing

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
tegwick 2026-07-09 01:36:33 +02:00
parent 87d4eb3006
commit a10f080f12
36 changed files with 6643 additions and 170 deletions

View file

@ -0,0 +1,49 @@
# ADR-0001 — Binder-owned reference UI surface
- Status: accepted
- Date: 2026-07-08
- Workplan: EBIND-WP-0001 (T05)
## Context
The extracted binder slice includes two small React components:
- `FormRenderer.tsx` — renders a `FormSchema` as an evidence-backed form. Each
field registers itself with the rect registry under `kind="field"`, focuses a
target via the active-state machine, and shows a link-count chip. This is the
component that produces the `field` leg of the visual-guide triple.
- `FieldDefinitionForm.tsx` — a shared label/type editor used by `FormRenderer`'s
add-field and edit-field flows.
The architectural rule is that the binder is *form-friendly but target-neutral*:
it must not depend on `citation-work` and must not assume any particular host
application.
## Decision
**Keep both components as supported binder exports.**
- `FormRenderer` is contractual: it is the reference implementation of the
"form field publishes a `field` rect and drives active-target focus" half of
the rect-registry contract (SharedContracts §7). Demoting it to an example
would leave the §7 field-side contract without an in-repo reference.
- `FieldDefinitionForm` is retained as a supporting export because `FormRenderer`
depends on it directly; splitting them across the package/example boundary
would break that import.
Both remain **target-neutral**: they operate purely on `FormSchema` /
`EvidenceTarget` and the binder's own hooks. They take no dependency on
`citation-work`, `evidence-source`, or the umbrella. The umbrella owns the
*composition* (wiring `FormRenderer` to persistence, sidebars, and the viewer)
in `citation-evidence/src/app/**`; the binder owns only the renderer itself.
## Consequences
- `src/index.ts` continues to export `FormRenderer` (and its
`FormSchema` / `FormFieldSchema` / `FormRendererProps` types); the umbrella
imports them unchanged after cutover.
- The package surface stays "headless core + rect-registry contract + one
reference form renderer" rather than a broad UI kit. Future richer UI belongs
in host apps, not here.
- If a later workplan needs a genuinely illustrative demo, it goes under an
`examples/` tree, not the package root, so the subsystem boundary stays sharp.

View file

@ -0,0 +1,73 @@
# Extraction inventory & contract deltas (EBIND-WP-0001-T01)
Locks the extraction boundary for pulling `citation-evidence/src/binder/` into
this repository. Authority for the shared contracts remains the umbrella wiki
(`../citation-evidence/wiki/SharedContracts.md`,
`../citation-evidence/wiki/DependencyMap.md`) until the cutover is complete.
## 1. Files that extract into this repo
All of `citation-evidence/src/binder/` moves to `evidence-binder/src/`:
| Concern | Files |
| --- | --- |
| Headless link repo | `repos/in-memory-links.ts`, `repos/index.ts` |
| Binding service | `services/bindings.ts` (+ `.test.ts`), `services/index.ts` |
| Active-state machine | `state/active.ts` (+ `.test.ts`), `state/index.ts` |
| Provider composition | `BinderProvider.tsx` |
| Visual guide (rect registry) | `visual-guide/rect-registry.ts` (+ `.test.ts`), `visual-guide/events.ts`, `visual-guide/react-hooks.ts` (+ `.dom.test.tsx`), `visual-guide/Overlay.tsx` (+ `.dom.test.tsx`), `visual-guide/index.ts` |
| Reference UI | `FormRenderer.tsx` (+ `FormRenderer.dom.test.tsx`), `FieldDefinitionForm.tsx` |
| Barrel | `index.ts` |
The upstream `src/binder/README.md` is **not** carried over — this repo's
top-level `README.md` supersedes it.
## 2. Files that remain umbrella-only
Everything that composes binder with the rest of the app stays in the umbrella
(`citation-evidence/src/app/**`): `FormsApp.tsx`, `HighlightRectBridge.tsx`,
`ActiveEvidenceChips.tsx`, `CaptureLinkPersister.tsx`, `capture-persistence.ts`,
`App.tsx`. These are consumers of the binder, not part of it.
## 3. Import-alias rewrite
Upstream binder files used the umbrella's internal path aliases. On extraction
they are rewritten to the engine's published package specifiers (the same
convention `evidence-anchor` uses):
| Upstream alias | Extracted specifier |
| --- | --- |
| `@shared/evidence-link`, `@shared/ids` | `@citation-evidence/engine/shared` |
| `@engine/events` | `@citation-evidence/engine` |
No source imported `@binder/*`, `@work/*`, `@source/*`, or `@app/*`, so no
forbidden edge existed in the slice. The binder MVP slice imports **only** from
`citation-engine` (shared types + event bus). It does not currently import
`evidence-anchor`, which is an *allowed but unused* edge (DependencyMap §2).
## 4. Contract deltas resolved
- **`EvidenceTarget` naming / target vocabulary.** No drift. The engine's
`EvidenceTarget` (`{ targetType, targetId }`) and the closed
`EvidenceTargetType` catalogue (`form-field`, `claim`, `requirement`,
`decision`, `document-section`) are canonical and consumed as-is. The MVP only
exercises `form-field`. `INTENT.md` previously listed extra target kinds
("tasks, or other information objects"); that is aspirational prose, not a
competing enum, and is left as narrative.
- **Dropped relation values `derived-from` / `needs-check`.** These are **not**
members of the canonical `EvidenceRelation` enum (`supports`, `contradicts`,
`explains`, `qualifies`, `source-for`, `context-for`). The extracted package
does **not** reintroduce them; any earlier INTENT mention of them is dropped
from the implemented surface.
- **Event vocabulary / removal semantics.** The binding service emits only
canonical bus events: `EvidenceLinkCreated`, `EvidenceLinkUpdated`,
`EvidenceLinkRemoved` (hard-delete; rejected-status path deferred), and
`EvidenceItemActivated` / `FormFieldActivated`. All are members of the engine's
`EngineEvent` union — no local event vocabulary is introduced.
## 5. Forbidden dependency edges (called out before copy)
Per DependencyMap §2, `evidence-binder` may depend on `citation-engine` and
`evidence-anchor`, and must **not** depend on `evidence-source`,
`citation-work`, or the umbrella `citation-evidence`. This boundary is enforced
mechanically by `eslint.config.js` (`no-restricted-imports`).