Skip to content

feat(018): rich data element model — reproschema + PROV-O + ontology + similarity#15

Merged
satra merged 5 commits into
mainfrom
018-rich-data-model
Mar 20, 2026
Merged

feat(018): rich data element model — reproschema + PROV-O + ontology + similarity#15
satra merged 5 commits into
mainfrom
018-rich-data-model

Conversation

@satra

@satra satra commented Mar 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Enriches the library data model with reproschema-aligned fields, W3C PROV-O provenance, ontology verification, and semantic similarity with SKOS alias detection.

Model changes:

  • SemanticIdentity: +response_options, +min_value/max_value (IN hash), +question_text/value_domain (NOT in hash)
  • ProvenanceEntry: +generated_at, +attributed_to, +activity, +derived_from (W3C PROV-O)
  • ResponseOption model for structured choices with ontology links

Extractors enriched: BIDS (response_options, min/max, value_domain), AIND (response_options, min/max, question_text from title), DANDI (response_options from enums, min/max from Pydantic validators)

Underscore reclassification: AIND _Abcam etc. → ValueConcepts (elements 3395→2697, values 596→1207)

New CLI commands: verify, ontology refresh, similarity, detect-aliases

New modules: ontology_cache.py, ontology_fetch.py, verify.py, similarity.py, alias_detection.py

Test plan

  • 60/60 pytest tests (15 new: similarity scoring, range overlap, valueset Jaccard, ontology verification)
  • Lint clean (ruff check + format)
  • 2,697 elements validated (0 violations)

🤖 Generated with Claude Code

satra and others added 4 commits March 20, 2026 18:07
Models:
- ResponseOption (value, label, ontology_term) for structured choices
- SemanticIdentity: +response_options, +question_text, +value_domain,
  +min_value, +max_value (reproschema-aligned)
- ProvenanceEntry: +generated_at, +attributed_to, +activity, +derived_from
  (W3C PROV-O enriched flat)
- ActivityType enum (ingestion, curation, enrichment, migration)

Hashing:
- min_value/max_value IN hash (different ranges = different element)
- response_options IN hash (sorted by value for determinism)
- question_text, value_domain EXCLUDED from hash
- constraints.minimum/maximum EXCLUDED (deprecated by min_value/max_value)

Dependencies: +requests (base), +sentence-transformers (optional [similarity])
ontology-cache/ directory created

45/45 tests, lint clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…late

- ingest.py: auto-populates generated_at, attributed_to, activity on all
  provenance entries; resolves response_option values to ValueConcept URIs
- BIDS extractor: response_options from enum, min/max from numeric constraints,
  value_domain (categorical/numeric/text/boolean)
- AIND extractor: response_options from enum, min/max from JSON Schema
  minimum/maximum/exclusiveMinimum, question_text from title
- DANDI extractor: response_options from Enum annotations, min/max from
  Pydantic ge/le/gt/lt metadata
- Re-ingested: 3,395 elements (210 with response_options, 40 with ranges,
  250 with PROV-O). 0 violations, 45/45 tests, lint clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- AIND extractor: $defs starting with _ (e.g., _Abcam, _Nikon) filtered
  from element extraction, reclassified as ValueConcepts via extract_aind_values()
- Source-qualified tags: aind.{schema}.{parent_class}.{value}
- ingest.py: _ingest_extracted_values() writes AIND vendor values to values/
- Element count: 3,395 → 2,697 (698 underscore entries removed)
- Value count: 596 → 1,207 (611 new ValueConcepts from underscore entries)
- 0 violations, 45/45 tests, lint clean

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…ilarity + alias detection

Phase 5 (Ontology):
- ontology_cache.py: OntologyCache class (load/lookup/save YAML term files)
- ontology_fetch.py: fetch terms from OLS API (NCIT, PATO, HP, OBI, NCBITaxon)
- verify.py: check term existence + deprecated flag + label similarity
- CLI: `verify` (check elements), `ontology refresh` (update cache from OLS)

Phase 6 (Similarity):
- similarity.py: name_similarity (sentence-transformers or difflib fallback),
  range_overlap_score (intersection/union), valueset_jaccard (Jaccard index),
  compute_similarity (weighted composite), map_to_skos (exactMatch/closeMatch/
  broadMatch/narrowMatch/relatedMatch)
- alias_detection.py: detect_aliases (pairwise scan, skip different data_types)
- CLI: `similarity` (compare two files), `detect-aliases` (scan all, threshold)

15 new tests (range overlap, valueset Jaccard, similarity scoring,
ontology verification: valid/missing/deprecated terms)
60/60 total tests, lint clean.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request introduces a comprehensive upgrade to the library's data modeling capabilities, focusing on integrating advanced semantic features and robust provenance tracking. By adopting reproschema alignment and W3C PROV-O, the changes aim to create a richer, more interoperable, and semantically aware data infrastructure. The update also streamlines data element definitions by replacing rigid constraints with more flexible value domains and adds new tools for ontology management and data similarity analysis.

Highlights

  • Data Model Enrichment: The library's data model has been significantly enhanced to align with reproschema standards, incorporate W3C PROV-O for provenance tracking, and support ontology verification and semantic similarity.
  • SemanticIdentity and Provenance Updates: The SemanticIdentity model now includes response_options, min_value/max_value, question_text, and value_domain fields. A new ProvenanceEntry model has been introduced to capture generated_at, attributed_to, activity, and derived_from information.
  • Refined Data Element Definitions: Many data element YAML files were updated to include a value_domain (e.g., text, numeric, boolean) and detailed provenance information, while several files with hardcoded allowed_values or specific ChannelCount fields were removed to promote a more flexible, ontology-driven approach.
  • New CLI Commands and Modules: New CLI commands (verify, ontology refresh, similarity, detect-aliases) and corresponding modules (ontology_cache.py, ontology_fetch.py, verify.py, similarity.py, alias_detection.py) have been added to support the new semantic capabilities.
  • Extractor Enhancements: Existing data extractors (BIDS, AIND, DANDI) have been enriched to leverage the new response_options, min/max values, and value_domain fields.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

… polish

- Full re-ingest: 2,697 elements + 482 schemas + 1,207 values (0 violations)
- Ontology verify: 27 warnings (terms not in cache — cache empty, expected)
- Alias detection: 10 candidates at threshold 0.7 (name, sex, status matches)
- Backend: SemanticInput updated with response_options, min/max, question_text
- Frontend: ElementDetail shows ranges, question_text, response_options badges,
  PROV-O provenance (activity, generated_at, attributed_to)
- TypeScript types: SemanticIdentity + ProvenanceEntry enriched with new fields
- README updated with current counts and new features
- 53/53 frontend tests, 60/60 library tests
- All 49 tasks marked complete

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@satra
satra merged commit 0eda984 into main Mar 20, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant