Skip to content

Add minischema/profile mechanism and new field types (ontology, quantity, relative_quantity)#13

Open
stevevanhooser wants to merge 1 commit into
mainfrom
claude/consolidate-treatment-docs-44kHG
Open

Add minischema/profile mechanism and new field types (ontology, quantity, relative_quantity)#13
stevevanhooser wants to merge 1 commit into
mainfrom
claude/consolidate-treatment-docs-44kHG

Conversation

@stevevanhooser
Copy link
Copy Markdown
Contributor

Summary

This PR introduces a new minischema (profile) mechanism for V_beta schemas, enabling reusable schema fragments that define the shape of structure fields at runtime. It also adds three new field types (ontology, quantity, relative_quantity) to support richer semantic and measurement data. The treatment family is consolidated from three separate schemas into a single generic treatment schema that delegates its manipulation field shape to profiles.

Key Changes

  • New meta-schema: profile_meta.json validates profile (minischema) files with type-specific constraint rules:

    • quantity fields require canonical_unit and canonical_unit_label
    • relative_quantity fields additionally require a reference anchor
    • ontology fields forbid canonical_unit
  • Updated meta-schema: did_schema_meta.json now:

    • Accepts three new field types: ontology, quantity, relative_quantity
    • Supports _shape_from_minischema: true on structure fields to delegate shape to profiles
    • Uses conditional validation to enforce _fields presence when shape is not delegated
  • New canonical profile: profiles/virus_injection.json demonstrates the profile mechanism with:

    • Ontology fields for virus construct and serotype (with descendant constraints)
    • Quantity fields for volume (nanoliters) and titer (genome copies/mL)
    • Relative quantity field for injection onset relative to session start
    • Optional fields for injection rate and promoter
  • Treatment consolidation:

    • Retired treatment_drug.json and virus_injection.json schemas
    • Updated treatment.json to use _shape_from_minischema: true on the manipulation field
    • Bumped treatment._class_version to 2.0.0 (breaking change)
    • Fixed schema reference from base/schema.json to base.json
  • Comprehensive test suite: tests/test_minischema.py validates:

    • Meta-schemas are valid Draft 7 schemas
    • New types and profiles validate correctly
    • Type-specific constraint rules are enforced
    • Retired schemas are absent
    • All existing V_beta schemas still validate against updated meta-schema
  • Documentation updates: V_beta_SPEC.md and V_beta_notes.md document the new types, profile mechanism, and consolidation rationale

Implementation Details

  • Profiles are self-contained JSON files under schemas/V_beta/profiles/ with their own versioning and maturity levels
  • The _shape_from_minischema flag allows structure fields to omit inline _fields when shape is supplied at runtime via a document's _minischema key
  • Quantity and relative_quantity types use a canonical unit pattern: the document stores a canonical numeric value (keyed by canonical_unit_label) plus source_value and source_unit for provenance
  • Profile inheritance via the extends field enables profile composition (e.g., organism-specific or route-specific virus injection profiles)

https://claude.ai/code/session_011acLkncHaNtT8YnEeVjWAA

Replace the per-kind treatment schemas (treatment_drug, virus_injection)
with a single generic treatment document whose manipulation field's shape
is delegated to a named profile (minischema). This removes schema-file
proliferation for the treatment family while preserving rigor via
ontology-anchored profiles and keeping search tractable via canonical
units, promoted fields, and profile_id references.

Meta-schema changes:
- Add ontology, quantity, relative_quantity to the type enum.
- Add _shape_from_minischema (boolean) on structure fields; when true,
  the nested _fields is not required.

New: profile_meta.json validates profile files; type-specific _constraints
rules (canonical_unit + canonical_unit_label on quantity; add reference
on relative_quantity; descendant_of permitted on ontology).

New: schemas/V_beta/profiles/virus_injection.json canonical profile.

treatment.json rewritten as a generic document with a single
manipulation field that delegates its shape via _shape_from_minischema.
Version bumped to 2.0.0.

Retired: treatment_drug.json, virus_injection.json. stimulus_bath
intentionally retained (it's a stimulus approach, not a treatment).

Tests: tests/test_minischema.py covers new types, _shape_from_minischema
conditional, profile validation, canonical profile contents, and
regression over all existing V_beta schemas against the updated
meta-schema. 28 new tests, all passing.

Follow-on work (drug_treatment profile, mammalian stereotaxic profile,
cross-profile canonical-unit registry) captured in Ideas.md.
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.

2 participants