Skip to content

Data layer phase 1: Seam and link ids #424

Closed
5 of 5 issues completed
Closed

Description

@imnasnainaec

Phase 1 of the data layer plan.

WebView sees: Faster Save and picker. Releasable because: the repository sits behind today's getDraft/saveDraft; the WebView still owns the edits. Needs: #407 (done).

Scope

Every read and write of interlinear data goes through the repository, and links get ids. The WebView doesn't change, apart from Save and the picker getting faster.

  • Link ids. TokenAnalysisLink and SegmentAnalysisLink gain an id, and the reducers and the PT9 converter (mergeLanguageAnalyses) write one on every new link. A saved interlinear project with any link that has no id loads as empty, as does each draft book holding one, with a log entry. There's no version bump and no migration.
  • Picks by rule. Where the reducers pick one record by list order, they pick by rule instead, so 3d to 3i port rules rather than order. The latest updatedAt, then the smallest id, wins an approval tie, for words and segments alike. A merge folds the edited payload into the identical one with the earliest createdAt, then the smallest id.
  • Repository. An async interface plus an in-memory implementation over today's envelope and per-book shards. getDraft and saveDraft keep their contracts but route through it, and an autosave still rewrites only the shards whose JSON changed, as on main. It keeps projectStorage's guards, such as refusing to overwrite a record written by a newer build. It also runs in Node with file-backed storage, so the Data layer: capture a performance baseline before the database migration #407 harness can seed its tiers without PAPI once 1d and 4c break seeding over PAPI.
  • Conformance suite. It runs against the in-memory implementation, stays for good, and is the bar any later backend must pass.
  • Save in the host. The pending autosave is the WebView's debounce timer, so before Save or Save As the WebView sends its pending saveDraft and waits for it. The host then copies the draft into the interlinear project. The WebView sends only metadata.
  • Project summaries. The existing InterlinearProjectSummary, stored on every project write instead of built per request, so the picker and getPt9ImportForSource read summaries for the requested source only.

Surface: no new WebView calls; Save takes metadata only.

Done when: Save and the picker send no analysis.

Performance checkpoint

After What to check Baseline (large-loadable)
Phase 1 Bytes per Save and per picker response Save 74.9 MB; picker 83.9 MB

Plan context

Decisions · The seam · Contract rules · Cross-book answers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions