Ontology Governance RFC for Data Contracts¶
Status¶
- Draft
- Author: PyCharter team
- Target release: phased rollout over 2-3 releases
Context¶
PyCharter already has the core building blocks:
- Ontology relationship and concept-type control via
ontology_schema.yaml - Contract-level
ontologysection support - Ontology collaboration primitives (branches, proposals, reviews)
- RDF / JSON-LD / SHACL capabilities
What is missing is a clear operating model that connects ontology governance to contract lifecycle and validation behavior.
Problem Statement¶
Today, ontology is available but not yet fully operationalized as a governed semantic layer for contracts.
Main gaps:
- Ontology payload in contracts is structurally permissive (
dict[str, Any]) and can drift. - Approval workflow is generic and not policy-aware by concept tier/change type.
- Contract validations do not consistently consume ontology relationships as executable checks.
- No explicit contract semantic quality gates (coverage, mapping health, impact checks).
Goals¶
- Make ontology first-class and governed, without over-constraining early adoption.
- Keep contracts focused on field-to-concept binding, not full concept redefinition.
- Convert ontology into practical value:
- Better data validation
- Better ownership/stakeholder routing
- Better impact analysis and change safety
- Use existing ontology proposal/review UI and APIs as the governance control point.
Non-goals¶
- Full OWL reasoner or advanced inference engine in this phase.
- Enforcing 100% semantic coverage from day one.
- Replacing JSON Schema validations with ontology validations.
Industry-Informed Pattern¶
Adopt a split model seen in ontology-centric data platforms:
- Central Concept Registry (global truth):
- Concept definitions, tiers, node kinds, lifecycle
- Allowed predicate catalog
- Contract Semantic Bindings (local truth):
- Field -> concept binding
- Local relationship hints and lineage references
- Governed change workflow:
- Proposals + approvals + merge gates
- Runtime policy enforcement:
- Validation checks and routing derived from ontology
This follows the same core direction as ontology-first enterprise platforms (for example, Palantir-style object/link governance), while remaining lightweight in PyCharter’s current architecture.
Proposed Conceptual Model¶
1) Ontology Registry¶
System of record for:
concept_id, label, definition, owner, tier, concept_type, status- Relationships between concepts (
is_a,depends_on,governs, etc.) - Allowed relationship types from
ontology_schema.yaml
2) Contract Semantic Bindings¶
Each data contract contains only semantic mappings for its fields:
ontology:
version: "1.1.0"
field_bindings:
customer_id:
concept_id: CustomerIdentifier
confidence: high
relationships:
- type: references
target_field: customers.id
total_amount:
concept_id: MonetaryAmount
relationships:
- type: derived_from
target_field: line_items.extended_amount
lineage:
source_system: billing_service
Notes:
concept_idmust resolve in the registry.relationships.typemust be in allowed predicate set.- Contracts should not redefine concept definitions unless in an explicit exception path.
3) Governance Policy¶
Governance depends on concept tier and change type:
coreconcepts:- Require central steward + domain owner approvals.
domainconcepts:- Require domain owner approval.
freeconcepts:- Single approval or auto-merge with audit trail (configurable).
Change types:
- Add concept
- Update concept definition/tier/node_kind
- Deprecate concept
- Add/remove concept relationship
- Remap contract field to a different concept
Integration With Current PyCharter Components¶
Contract Parser and Schema¶
Current:
ontologyaccepted but mostly opaque.
Proposed:
- Add strict Pydantic models for
ontology.field_bindings. - Enforce:
concept_idrequired- Known relationship types only
- Optional confidence enum (
low,medium,high) - Preserve backward compatibility:
- Continue reading existing
fieldsshape - Normalize to canonical
field_bindingsinternally
Target files:
src/pycharter/db/schemas/data_contract.pysrc/pycharter/contract_parser/parser.pysrc/pycharter/wiki/ontology/validator.py
Ontology collaboration layer¶
Current:
- Proposals/reviews exist, but policy logic is thin.
Proposed:
- Add policy evaluator:
- Determine required approvers based on impacted concept tier + change type.
- Add merge gates:
- Ontology schema validation
- Relationship catalog validation
- SHACL validation (when RDF artifacts are available)
- Impact report generation
- Persist governance metadata:
- Required approvals
- Approval evidence
- Gate run results
Target files:
src/pycharter/wiki/collaboration/proposals.pysrc/pycharter/wiki/collaboration/review.pysrc/pycharter/wiki/collaboration/permissions.pysrc/pycharter/db/models/semantic/(proposal-related models; extend as needed)
Ontology UI proposal flow¶
Use existing /ontology/proposals flow and add ontology-specific UX:
- Proposal type selector (
concept_change,mapping_change,relationship_change). - Auto-generated impact panel:
- affected contracts
- affected fields
- owners to notify
- Merge gate status panel:
- pass/fail per gate
- Approval requirement panel:
- who must approve and why
Target files:
src/pycharter/ui/src/app/ontology/proposals/page.tsxsrc/pycharter/ui/src/components/ontology/CreateProposalModal.tsxsrc/pycharter/ui/src/components/ontology/ReviewList.tsx
Runtime Use in Data Contracts¶
Ontology should power concrete checks and operations:
- Semantic coverage check
% required fields mapped to concept_id- Fail/warn thresholds by contract tier.
- Referential integrity quality checks
referencesrelationships become foreign-key quality checks.- Derivation lineage checks
derived_fromrelationships require valid upstream mapping evidence.- Policy checks
- e.g.
pii-tagged concepts require masking/governance metadata. - Stakeholder routing
- Validation incidents route to concept owners + contract owners.
API Changes (Draft)¶
Add or extend endpoints under the semantic API:
POST /api/v1/semantic/proposals:- include
proposal_type,change_set,impact_preview POST /api/v1/semantic/proposals/{id}/validate:- runs merge gates; returns structured results
GET /api/v1/semantic/contracts/{contract_id}/semantic-health:- coverage, invalid mappings, deprecated concept usage
GET /api/v1/semantic/concepts/{concept_id}/impact:- contract and field usage graph
Data Model Changes (Draft)¶
Proposed additive changes:
proposalstable:proposal_typerequired_approvalsgate_status(JSON)reviewstable:- optional
review_scope(concept/mapping/global) - optional mapping audit table:
contract_id,field_path,concept_id,status,changed_by, timestamps
Keep existing concepts, concept_relationships, field_concepts models as base.
Rollout Plan¶
Phase 0 (Foundation)¶
- Formalize canonical ontology-in-contract schema (
field_bindings). - Add normalizer for legacy
fieldsshape. - Add semantic health report endpoint (read-only).
Exit criteria:
- Existing contracts continue to parse.
- Semantic health can be computed for all active contracts.
Phase 1 (Governed Proposals)¶
- Add proposal types and policy-aware approval requirements.
- Add merge validation endpoint and UI gate display.
- Require successful gates before merge for
coreconcepts.
Exit criteria:
- Core ontology changes blocked unless policy + gates pass.
Phase 2 (Contract Enforcement)¶
- Add semantic coverage policy checks to contract validation.
- Add
referencesandderived_fromquality checks. - Add incident routing to concept + contract owners.
Exit criteria:
- Ontology adds measurable validation and governance value in production workflows.
Phase 3 (Optimization)¶
- Add impact simulation before concept deprecations.
- Add recommendation tooling for unmapped fields (assisted mapping).
- Add analytics dashboard (coverage, change lead time, validation defect trends).
Success Metrics¶
- Semantic coverage rate by contract/domain.
- % contracts using deprecated concepts.
- Proposal lead time (open -> merged).
- Rejected/rolled-back ontology changes.
- Validation defects detected via ontology-derived rules.
- Mean time to route and resolve data incidents.
Risks and Mitigations¶
- Over-governance slows teams.
- Mitigation: tiered policy; lighter defaults for
free/domain. - Taxonomy sprawl.
- Mitigation: concept de-dup checks and required broader/owner metadata.
- Mapping quality inconsistency.
- Mitigation: confidence levels + review requirements + health score visibility.
- Backward compatibility issues.
- Mitigation: normalization layer and phased enforcement.
Open Questions¶
- Should
field -> conceptbe one-to-one or many-to-many by default? - Should
same_as/equivalent_tobe auto-collapsed in lineage/discovery views? - Should domain admins be able to override core concept mappings locally?
- What minimum semantic coverage is required per contract maturity tier?
Recommended Next Implementation Slice¶
Build the smallest vertical slice first:
- Canonical
field_bindingsschema + parser normalizer. - Semantic health endpoint.
- Proposal validation endpoint with:
- relationship-type validation
- concept existence check
- coverage delta report
This delivers immediate value with low migration risk and sets up stricter governance later.