Skip to content

Core 3: registerOntologies, prefixes from the app's map - #424

Merged
flyon merged 17 commits into
mainfrom
dev--coordinated-major
Nov 24, 2026
Merged

flyon merged 17 commits into
mainfrom
dev--coordinated-major

Conversation

@flyon

@flyon flyon commented Nov 24, 2026

Copy link
Copy Markdown
Contributor

Part of the coordinated major of the @_linked packages: ontologies register with registerOntologies (core 3), prefixes belong to the app, and the cli 2 ontology layout.

Merges dev (with main merged in) into main. Locally: built with the cli 2 code (✔ Build successful), npm test 2892 passed, 623 skipped.

Changesets

  • patch (inline-rule-comments.md): Comments state the IRI and routing rules inline.
  • patch (load-ontology-files-doc.md): @_linked/core/ontology/loadOntologyFiles: its documentation describes how registerOntologies loads an ontology's data files.
  • minor (ontology-name.md): linkedOntology(terms, ns, name, loadData?, dataFiles?): the third argument is the ontology's name within its package (unique in the package, need not equal the module's file name), not a prefix. OntologyRegistration.prefix is now .name, and the registry is keyed by package and name. A registration an older copy of core wrote (a prefix, no name) is skipped with one warning. linkedOntology still registers the name as a prefix with Prefix.
  • patch (ontology-vann-data.md): The ontology is declared in package.json "linkedOntologies" and its data states its suggested prefix and namespace (vann:preferredNamespacePrefix, vann:preferredNamespaceUri); the module stays hand-written ("generated": false). No import path or export changes.
  • major (scoped-prefixes.md): Prefixes are the app's, and ontologies register with one call per package.
    • registerOntologies(ontologies, moduleUrl) replaces linkedOntology, which is removed. A package's src/ontologies/index.ts imports its terms modules (only {id} literals) and registers them all: registerOntologies([{name, namespace, terms, data?, suggestedPrefix?}], import.meta.url), data relative to moduleUrl. It registers no prefix. OntologyRegistration has namespace and suggestedPrefix instead of ns; suggestedPrefixes() lists {packageName, name, namespace, prefix}.
    • registerInstalledOntologies imports <pkg>/ontologies/index instead of ontologies/*.register modules.
    • No ontology registers a prefix, core's own included (rdf, rdfs, owl, xsd, shacl, sd, prov, core; the deprecated linked_core label is gone). An app loads its map with Prefix.load(map) (replaces the map in use; PrefixMap is Record<prefix, namespace>); Prefix.toMap() returns it.
    • An unknown prefix throws UnknownPrefixError (naming the prefix and the value) wherever a prefixed name is expanded: Prefix.toFull, query subjects (.for('ex:a')), update().for and delete ids (which were never expanded before), and property path steps (which were written as <p:x> with a warning). A string with :// or the scheme http, https, urn, mailto, did, file or data is a full IRI (Prefix.isFullIri).
    • Expansion and compaction take an optional explicit map, for code acting for another app: Prefix.toFull, toPrefixed, toPrefixedIfPossible, getFullURI, getPrefix, findMatch, resolveUriOrThrow, resolveNodeId, pathRefIri, expandPrefixedName.
    • Removed: Prefix.toFullIfPossible, resolvePrefixedUri, expandRegisteredPrefixedName (now expandPrefixedName, which throws), linked-core.register. linked-core.ts exports coreOntology only (no ns, _self, dataFiles, loadData).

Verification

CI (Build & Test) on this PR, built with the cli 2 release commit through the shared workflow's cli-version.

flyon added 17 commits November 2, 2026 01:07
…pansion and compaction; an unknown prefix throws
…ore's ontology index; tests declare their prefixes
…d, backlog 120; older registrations without a namespace skipped; major changeset
Copilot AI balanced review requested due to automatic review settings November 24, 2026 13:43
@flyon
flyon merged commit c8c4b4b into main Nov 24, 2026
3 checks passed
@linked-fw-release linked-fw-release Bot mentioned this pull request Nov 24, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The locked CLI version ignores module and generated, causing a clean install followed by a build to fail because expected generated files are absent.

2 open issues
What changed in this PR

This PR prepares @_linked/core for the coordinated core 3 release, separating ontology registration from application-owned prefixes and adopting the CLI 2 ontology layout.

Changes:

  • Moves ontology registration to package-level indexes and updates registry consumers, fixtures, and tests.
  • Removes automatic prefix registration and adds strict prefix expansion with optional explicit maps.
  • Updates migration notes and documentation, replacing host-specific references with generic examples.
File Description
src/​utils/​ShapeClass.ts Generalizes host-app comments.
src/​utils/​NodeReference.ts Adds strict, map-aware identifier resolution.
src/​utils/​LinkedStorage.ts Clarifies routing comments.
src/​utils/​graphRegistryCache.ts Generalizes invalidation comments.
src/​tests/​sync-targets.test.ts Migrates ontology fixtures.
src/​tests/​sync-routed.test.ts Migrates routed-sync fixtures.
src/​tests/​sync-routed-fuseki.test.ts Migrates live-sync fixtures.
src/​tests/​sparql-prefixed-names.test.ts Uses neutral example prefixes and IRIs.
src/​tests/​shape-graphs.test.ts Uses an example-domain graph IRI.
src/​tests/​shape-graphs-fuseki.test.ts Uses an example-domain live-test IRI.
src/​tests/​shape-check.test.ts Migrates mirror-ontology registration.
src/​tests/​shape-check-no-n3.test.ts Migrates in-memory ontology registration.
src/​tests/​shape-check-multiple-inheritance.test.ts Generalizes inheritance fixtures.
src/​tests/​shacl-syncshapes.test.ts Generalizes multi-writer descriptions.
src/​tests/​shacl-serialization-ontology.test.ts Tests removal of the deprecated prefix.
src/​tests/​setup-prefixes.ts Loads the test application's prefix map.
src/​tests/​security-path-injection.test.ts Expects unknown path prefixes to throw.
src/​tests/​query-error-cause.test.ts Generalizes the motivating example.
src/​tests/​property-path-sparql.test.ts Tests strict path-prefix handling.
src/​tests/​prefix-scoped.test.ts Covers explicit maps and strict expansion.
src/​tests/​prefix-resolution.test.ts Updates URI-resolution coverage.
src/​tests/​ontology-sync.test.ts Migrates ontology-sync fixtures.
src/​tests/​ontology-sync-fuseki.test.ts Migrates live ontology fixtures.
src/​tests/​mutation-builder.test.ts Generalizes an untyped-caller comment.
src/​tests/​metadata.test.ts States the shape IRI rule inline.
src/​tests/​import-package-module-callers.test.ts Expects ontology-index imports.
src/​tests/​hierarchy-probe.test.ts Migrates hierarchy-probe registration.
src/​tests/​graph-targets-measure-fuseki.test.ts Migrates measurement fixtures.
src/​tests/​graph-targets-fuseki.test.ts Migrates graph-target fixtures.
src/​tests/​graph-routing.test.ts Generalizes lazy-root commentary.
src/​tests/​graph-content.test.ts Migrates multi-file ontology fixtures.
src/​tests/​gap1-fixes.test.ts Updates the unknown-prefix error assertion.
src/​tests/​fixtures/​installed/​with-ontology/​lib/​esm/​package.js Exposes the new registration API.
src/​tests/​fixtures/​installed/​with-ontology/​lib/​esm/​ontologies/​pets.register.js Removes per-ontology registration.
src/​tests/​fixtures/​installed/​with-ontology/​lib/​esm/​ontologies/​pets.js Keeps only literal term references.
src/​tests/​fixtures/​installed/​with-ontology/​lib/​esm/​ontologies/​index.js Adds package-level registration.
src/​tests/​fixtures/​installed/​source-only/​src/​package.ts Exposes the new registration API.
src/​tests/​fixtures/​installed/​source-only/​src/​ontologies/​index.ts Adds source-only package registration.
src/​tests/​fixtures/​installed/​source-only/​src/​ontologies/​birds.ts Keeps only literal term references.
src/​tests/​fixtures/​installed/​source-only/​src/​ontologies/​birds.register.ts Removes legacy registration.
src/​tests/​fixtures/​installed/​README.md Documents the index-based fixture layout.
src/​tests/​fixtures/​installed/​broken/​lib/​esm/​ontologies/​index.js Adds a failing ontology index.
src/​tests/​fixtures/​installed/​broken/​lib/​esm/​ontologies/​broken.register.js Removes the legacy failure fixture.
src/​tests/​display-metadata.test.ts Generalizes a test description.
src/​tests/​core-ontology.test.ts Tests index registration and ontology names.
src/​tests/​class-hierarchy.test.ts Migrates hierarchy-data registration.
src/​test-helpers/​register-test-ontology.ts Adds in-memory ontology registration for tests.
src/​sparql/​SparqlDataset.ts Generalizes cache-identity commentary.
src/​sparql/​graphScope.ts Removes a host-specific plan reference.
src/​shapes/​syncTargets.ts Reads registration namespace strings.
src/​shapes/​syncShapes.ts States synchronization rules inline.
src/​shapes/​syncShapeGraphs.ts States the graph IRI scheme inline.
src/​shapes/​SHACL.ts Clarifies identity-root and slug comments.
src/​shapes/​checkShapeHierarchy.ts Uses registration namespaces directly.
src/​queries/​UpdateBuilder.ts Expands prefixed string target IDs.
src/​queries/​SelectQuery.ts Generalizes inference documentation.
src/​queries/​resolveShape.ts Generalizes catalog-resolution commentary.
src/​queries/​graphRecords.ts Generalizes gateway commentary.
src/​queries/​DeleteBuilder.ts Expands prefixed string delete IDs.
src/​paths/​propertyPathSafety.ts Adds strict, map-aware path expansion.
src/​paths/​pathExprToSparql.ts Replaces prefix warnings with strict resolution.
src/​package.ts Exports registerOntologies.
src/​ontology/​syncOntologies.ts Uses namespace strings for default-graph sweeps.
src/​ontology/​registryData.ts Uses ontology names and filters legacy entries.
src/​ontology/​loadOntologyFiles.ts Documents index-relative data loading.
src/​ontologies/​xsd.ts Removes automatic prefix registration.
src/​ontologies/​shacl.ts Removes automatic prefix registration.
src/​ontologies/​sd.ts Removes automatic prefix registration.
src/​ontologies/​rdfs.ts Removes automatic prefix registration.
src/​ontologies/​rdf.ts Removes automatic prefix registration.
src/​ontologies/​prov.ts Removes automatic prefix registration.
src/​ontologies/​owl.ts Removes automatic prefix registration.
src/​ontologies/​linked-core.register.ts Removes legacy core registration.
src/​ontologies/​index.ts Registers core through the package index.
src/​index.ts Loads the ontology index.
src/​data/​core.ttl Adds suggested prefix and namespace metadata.
package.json Declares the hand-written core ontology.
jest.config.cjs Loads test prefixes during setup.
docs/​reports/​121-load-ontology-files-doc.md Records the loader documentation update.
docs/​reports/​118-linked-vocabularies-vann.md Records vocabulary metadata changes.
docs/​reports/​116-ontology-name.md Records the ontology-name migration.
docs/​reports/​115-no-host-app-mentions.md Records host-reference cleanup.
docs/​reports/​112-one-read-method-core.md Generalizes historical host references.
docs/​reports/​110-default-read-graphs.md Generalizes historical host references.
docs/​reports/​109-triples-terms-reads.md Generalizes historical host references.
docs/​reports/​107-sort-filter-depth-and-quantifier-casts.md Generalizes historical host references.
docs/​reports/​106-reserved-combinator-labels.md Generalizes verification references.
docs/​reports/​105-sort-and-leaf-path-edges.md Generalizes historical host references.
docs/​reports/​104-node-type-in-select-dsl.md Generalizes historical host references.
docs/​reports/​103-store-transactions.md Generalizes transaction consumer references.
docs/​reports/​102-object-predicate-triples-reads-and-attributed-to.md Generalizes consumer examples.
docs/​reports/​101-sort-keeps-instances.md Generalizes consumer examples and references.
docs/​reports/​100-shapeless-delete-every-data-graph.md Generalizes host-policy references.
docs/​reports/​099-shapeless-delete.md Generalizes historical host references.
docs/​reports/​098-select-subject-paging.md Generalizes paging consumer references.
docs/​reports/​097-feature-check-callback-errors.md Generalizes the reported consumer failure.
docs/​reports/​094-select-typing-gaps.md Generalizes consumer examples and paths.
docs/​reports/​093-triples-reads.md Generalizes examples and local paths.
docs/​reports/​092-two-copies-built-jest-module-cache.md Generalizes historical environment references.
docs/​reports/​091-propertyshape-in-names-list-without-registering-it.md Generalizes historical consumer references.
docs/​reports/​090-dsl-property-name-collisions.md Generalizes the motivating example.
docs/​reports/​087-graph-record-empty-field.md Generalizes affected consumer references.
docs/​reports/​086-components-graph-record.md Generalizes host examples and paths.
docs/​reports/​085-component-index-terms.md Generalizes plan and worktree references.
docs/​reports/​083-ontology-status-individuals.md Generalizes ontology consumer references.
docs/​reports/​081-backlog-batch-callbacks-data-only-relations-registered-packages.md Generalizes historical integration references.
docs/​reports/​080-package-kinds-and-npm-out-of-core.md Generalizes historical verification references.
docs/​reports/​077-path-steps-loadstores-client-stub.md Generalizes environment references.
docs/​reports/​057-graph-targets.md Generalizes host-managed app terminology.
docs/​reports/​055-graph-review-fixes.md Generalizes host integration references.
docs/​reports/​054-nested-create-ids.md Generalizes dependent-app references.
docs/​reports/​053-graph-routing-forms.md Generalizes historical routing references.
docs/​reports/​052-shape-graphs.md Generalizes shape-graph integration references.
docs/​reports/​051-graph-routing.md Generalizes routing examples and references.
docs/​reports/​050-ontology-sync-on-package-graphs.md Generalizes ontology-sync consumer references.
docs/​reports/​049-reads-from-graphs.md Generalizes graph-reader references.
docs/​reports/​048-graph-query-and-the-graph-api.md Generalizes graph API integration references.
docs/​reports/​047-register-source-ontologies.md Generalizes source-package examples.
docs/​reports/​046-order-and-page-by-subject.md Generalizes paging examples.
docs/​reports/​045-register-installed-ontologies.md Generalizes the originating plan reference.
docs/​reports/​044-the-no-inference-workarounds-go.md Generalizes inference consumer references.
docs/​reports/​043-class-hierarchy-and-validate-by-class.md Generalizes hierarchy examples.
docs/​reports/​042-store-inference-ontology-sync-and-shape-check.md Generalizes integration references.
docs/​reports/​041-unresolved-shape-errors-name-the-property.md Generalizes error-consumer references.
docs/​reports/​040-shape-sync-skips-unchanged-shapes.md Generalizes synchronization motivation.
docs/​reports/​038-load-stores-module-loader.md Generalizes the originating plan reference.
docs/​reports/​037-shape-catalog-scope.md Generalizes catalog consumer references.
docs/​reports/​030-root-count.md Generalizes pagination motivation.
docs/​reports/​028-shape-exists.md Generalizes existence-check examples.
docs/​reports/​025-update-replace-contains-cascade.md Generalizes an integration follow-up.
docs/​reports/​021-targeted-query-execution.md Generalizes targeted-execution examples.
docs/​reports/​016-shacl-rdf-serialization.md Generalizes architecture references.
docs/​reports/​014-projected-optional-traversals.md Removes host-specific absolute links.
docs/​plans/​002-shape-upsert.md Generalizes upsert consumer references.
docs/​backlog/​120-explicit-prefix-map-in-query-builds.md Records deferred query-level prefix maps.
docs/​backlog/​091-create-as-other-shape.md Generalizes the provenance discussion source.
docs/​backlog/​070-graph-routing-per-read-cost.md Generalizes routing performance context.
docs/​backlog/​069-per-instance-graph-functions.md Generalizes per-instance graph examples.
docs/​backlog/​068-default-graph-shapes-of-removed-packages.md Generalizes cleanup examples.
docs/​backlog/​064-package-version-in-ontology-graph-records.md Generalizes the source reference.
docs/​backlog/​062-ontology-review-lows.md Removes a host-specific plan reference.
docs/​backlog/​059-property-inference-subpropertyof.md Generalizes inference context.
docs/​backlog/​049-cached-keyed-by-function-identity.md Generalizes cache consumer references.
docs/​backlog/​046-provenance-scoped-shape-pruning.md Generalizes pruning examples.
docs/​backlog/​033-no-live-shape-instances.md Generalizes the motivating incident.
docs/​backlog/​024-fulltext-search-primitive.md Generalizes search examples and history.
docs/​backlog/​014-prefixed-uris-in-json.md Updates references to strict prefix APIs.
docs/​architecture/​loading-package-modules.md Documents ontology-index loading.
.changeset/​scoped-prefixes.md Describes the major registration and prefix migration.
.changeset/​ontology-vann-data.md Describes ontology declaration metadata.
.changeset/​ontology-name.md Describes the name-based registry migration.
.changeset/​load-ontology-files-doc.md Records the loader documentation patch.
.changeset/​inline-rule-comments.md Records inline rule clarification.

Review effort: Balanced

Comment thread package.json
Comment on lines +114 to +115
"module": "linked-core",
"generated": false
"@_linked/core": minor
---

`linkedOntology(terms, ns, name, loadData?, dataFiles?)`: the third argument is the ontology's name within its package (unique in the package, need not equal the module's file name), not a prefix. `OntologyRegistration.prefix` is now `.name`, and the registry is keyed by package and name. A registration an older copy of core wrote (a `prefix`, no `name`) is skipped with one warning. `linkedOntology` still registers the name as a prefix with `Prefix`.
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