Skip to content

Add an offline terminology snapshot cache and versioned loader #884

Description

@maziyarpanahi

Summary

Loading large free vocabularies on every run is slow, and repeated terminology-server lookups are unnecessary for stable concepts. A versioned, content-addressed offline snapshot cache lets grounding load indexes fast and reuse prior lookups, fully local-first.

Scope

  • Add clinical/grounding/snapshot_cache.py with a versioned, content-addressed on-disk cache for built vocabulary indexes
  • Store index artifacts plus a manifest with system URI, release version, and content hash
  • Provide load-or-build semantics and integrity verification on load
  • Expose a cache directory honoring OPENMED_OFFLINE and a clear miss/hit API

Acceptance criteria

  • First load builds and persists a snapshot; second load reads it without rebuilding
  • Corrupted or hash-mismatched snapshots are rejected and rebuilt
  • Cache respects the offline flag and stores no raw PHI or restricted concept text by default
  • Snapshot manifest is reproducible and version-pinned

Out of scope

  • Downloading vocabulary releases (loaders handle that)
  • Caching any restricted terminology content without explicit user opt-in

Files

  • openmed/clinical/grounding/snapshot_cache.py
  • tests/unit/clinical/grounding/test_snapshot_cache.py

Task: OM-527 · Milestone: v2.2 · Priority: P1 · Size: M
Depends on: OM-510 · Blocks: —
Roadmap: v2.2 trustworthy clinical data exchange follow-on wave
Spec: PLANS/V2/EXECUTION/tasks/OM-527.md

Metadata

Metadata

Assignees

No one assigned

    Labels

    P1HighfeatureNew capabilityroadmap-v2OpenMed V2 roadmap backlog

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions