Skip to content

Add optional knowledge references to ontology concepts and metrics - #748

Open
bksahu-atlan wants to merge 3 commits into
apache:mainfrom
bksahu-atlan:codex/ossie-knowledge-refs
Open

bksahu-atlan wants to merge 3 commits into
apache:mainfrom
bksahu-atlan:codex/ossie-knowledge-refs

Conversation

@bksahu-atlan

@bksahu-atlan bksahu-atlan commented Nov 17, 2026 •

Copy link
Copy Markdown

Summary

Add optional knowledge_refs so ontology concepts and metrics can point to the
policy, definition or decision notes behind them. References belong to the
concept or metric, so the external document needs no backlink into the model.

The shared reference has a display name, a relative path, a format (json
or md), and an optional json_pointer for a JSON entry. For example:

knowledge_refs:
  - name: Cash eligibility rule
    path: ./knowledge.json
    format: json
    json_pointer: /collected_cash_eligibility

The pointer is an RFC 6901 pointer string, without a leading #. Markdown
references identify whole documents. ai_context remains inline guidance for
AI tools; knowledge_refs identifies external source material.

Schema validation does not open targets. Consumers resolve references under
their own access policy and may opt into separate CI link checks. References
do not change query semantics or imply approval, verification, or causal evidence.
Knowledge Record contents, evidence strength, Markdown anchors, and approval
workflows remain outside this proposal.

Review changes

  • Renamed reference type to format to distinguish it from ontology type.
  • Renamed deep_link to json_pointer and removed the URI-fragment # prefix
    throughout schemas, SDK, examples and tests.
  • Moved the shared contract into its own Knowledge references section and
    clarified ai_context and opt-in link checking.
  • Added schema/SDK pattern drift checks and paired acceptance/rejection cases,
    including trailing newlines. The checks account explicitly for the different
    strict-end anchors required by the validators' regex engines.
  • Merged main at 59080f6 without rewriting the published branch. Preserved
    its ontology SDK and added concept reference round-trip coverage there.

Compatibility

Existing documents need no changes. Older strict validators, SDKs or converters
may reject documents using the new field; producers targeting them should omit
it. Converter adoption is tracked in apache/ossie-converters#328.

Anyone testing the earlier version of this unmerged proposal should rename
deep_link to json_pointer, remove its leading #, and rename reference
type to format.
The change history entry remains proposed, with the PR reference included.

Validation

Checked against apache/ossie main 59080f6b925faff6f7f10dd32a7347591af14226:

  • 35 focused knowledge-reference checks passed.
  • Python SDK: 369 passed.
  • Combined SDK and validation suites: 987 passed, 268 skipped, 231 failed.
    Untouched main with the same installed dependencies: 952 passed, 268 skipped,
    the identical 231 failing test IDs. No added failures. The local sqlglot
    version is 30.4.2; main now requires at least 30.29.0 for SQL validation.
  • Generated spec-type consistency and diff whitespace checks against main passed.
  • All three example references resolve locally, including both JSON pointers.
  • Ruff is unavailable locally. No dependencies were installed, no local builds
    were run, and no SQL was executed. CI remains the authoritative lint/check run.

Discussion

The PR remains scoped to concepts and metrics. Agreement is still needed on
whether references on fields, datasets, relationships and the semantic model,
URL support through the REST spec, and an opt-in validator link-checking command
can follow separately. None of those features is implemented here.

The dev-list follow-up and maintainer review request are drafted, not sent.
The material format revision needs a new discussion deadline at least 72 hours
after the change. No consensus or approval is claimed here.

Prepared with AI assistance for contributor review.

@github-actions

Copy link
Copy Markdown

Thank you for your first contribution to Apache Ossie (incubating)!

A committer will review your PR. In the meantime, please ensure:

  • All CI checks pass
  • ASF license headers are present on new source files
  • Tests cover new functionality

No ICLA is required to contribute. If you are elected as a committer in the future, you will need an Individual Contributor License Agreement (ICLA) on file with the ASF.

Questions? Ask in the PR comments or join us on Slack.

We appreciate your contribution!

@ashlearnnext-star

Copy link
Copy Markdown
Contributor

Nice work keeping the ontology side and the metric side consistent.

One observation. The path and deep_link regex patterns exist in two places: ossie-schema.json and models.py. there is no check that the two stay identical.

the JSON Schema uses (?![\s\S]) as the end, models.py uses plain $. These differ in Python's re module, where $ also matches just before a trailing newline. I tested this against Pydantic's actual validator:

from pydantic import BaseModel, Field
 
class M(BaseModel):
    path: str = Field(..., pattern=r'^(?:\./)?[A-Za-z0-9_-][A-Za-z0-9_. -]*(?:/[A-Za-z0-9_-][A-Za-z0-9_. -]*)*$')
 
M(path='foo/bar.json\n')  # raises ValidationError

Pydantic v2's default regex engine is Rust-based, not Python's re, so $ here means strict end-of-string. No actual bug today.

probably I would consider adding a test that parses both patterns from their source files and asserts they are the same string.

@Koji-Minami

Copy link
Copy Markdown

Thanks for the proposal — I like the direction of keeping this additive and optional.

A few small suggestions, mostly aligned with JB's points:

  1. Fix the reference format first. Dropping the # from JSON pointers and renaming deep_link before implementations land would avoid a format migration later.
  2. Keep it as its own "Knowledge references" section rather than nesting under Metrics, so ontology concepts and metrics share one home for external references.
  3. One sentence on ai_context vs knowledge_refs in the spec would help authors pick the right field (e.g. ai_context is guidance for model evaluation, knowledge_refs points to the human-readable source material behind a concept).
  4. Opt-in link checking in CI sounds right — validating links only when authors opt in keeps the barrier low for new contributors.

Happy to help with the docs wording if that's useful.

@bksahu-atlan

Copy link
Copy Markdown
Author

@ashlearnnext-star Thanks for catching the drift risk. Added a guard comparing both pattern bodies and explicitly accounting for the different strict-end anchors: JSON Schema uses (?![\s\S]), while Pydantic's Rust regex uses $ and does not support lookahead. Paired schema/SDK tests now exercise the same accepted and rejected inputs, including trailing LF/CRLF, traversal paths and malformed pointer escapes. This keeps the engine-specific endings intentional and makes other pattern drift fail a test.

The locator is now named json_pointer, with a bare /... value. All 33 focused reference checks and 367 Python SDK tests pass. Fixed in 31ef7a6.

@bksahu-atlan

Copy link
Copy Markdown
Author

@Koji-Minami Thanks for the concrete suggestions. Addressed these in 31ef7a6:

  • Renamed deep_link to json_pointer; values now use /collected_cash_eligibility, without a leading #. Updated the schemas, SDK, examples and negative tests together.
  • Moved the shared contract into its own Knowledge references section, linked from concepts and metrics.
  • Clarified that ai_context carries inline AI guidance while knowledge_refs points to external source material.
  • Documented opt-in link checking in consumers' CI. Schema validation still does not open targets; no link-checking implementation is added in this PR.

Also merged current main and added round-trip coverage for its new ontology SDK. All 367 SDK tests pass. The broader run has the same 231 failing test IDs as untouched main with the existing local dependencies; the PR description records that limitation. No builds or dependency installs.

The reference-format revision needs a dev-list follow-up and a review deadline at least 72 hours after the change, per CONTRIBUTING.md. I am not treating the earlier discussion window as approval for this revision.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants