Skip to content

Cli 2: linked.app.json, the ontology index layout, core 3 - #349

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

flyon merged 28 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, plus the move to @_linked/core ^3.0.0 (published) and the package template's ranges (defaults/package/package.json: core ^3.0.0, cli ^2.0.0). Locally against core 3.0.0: test:unit 105 suites passed, 1319 tests passed, 1 skipped. The app template's move to linked.app.json lands in linked-fw/app-template next; the dual-copy e2e clones that template.

Changesets

  • patch (app-json-wording.md): Comments and the architecture notes name linked.app.json, not the removed linked.config.js.
  • major (app-settings-in-linked-app-json.md): linked.app.json holds every setting of an app; linked.config.js is no longer read.
    Breaking.
    • An app with a linked.config.js (or lincd.config.js) is refused when its server starts (linked start, linked serve-app, a compiled server) and when it is built (linked build-app); the error shows the JSON to move its settings into. Move them into linked.app.json and delete the file.
    • Schema version 1 gains cssMode (tailwind | postcss), syncShapesOnBoot, datasetCloneScript, publish (staticAssets, releasePrefix) and server (rpcExposure, rawQueries, apiOnly, cachePaths, cacheTimeout). Each is checked; an unknown key, also inside server or publish, is refused. linked prefixes keeps them when it adds prefixes.
    • LINKED_RPC_EXPOSURE, when set, wins over server.rpcExposure; a value other than warn or enforce is refused at start.
    • defineConfig (@_linked/cli/defineConfig and the package entry) is removed: nothing reads a settings module any more.
    • Types: ModuleConfig, AdjustedModuleConfig (the old webpack build's) and LinkedServerConfig.multiCore are removed; LinkedConfig is the configuration the cli gives LinkedServer (cssMode, syncShapesOnBoot, server), and loses datasetCloneScript. New: AppServerSettings, CssMode, RpcExposureMode, RawQueriesMode. server.loadAppComponent and server.loadRoutes are set by the cli only.
    • resolveLinkedConfigPath and LINKED_CONFIG_FILES (@_linked/cli/commands/start) are removed; readDatasetCloneScript is synchronous.
      Fixed. linked generate-ontology replaces a side-effect import of a src/ontologies/<name>.register.js that no longer exists (a register module deleted by hand) with the import of the ontology index, as it does for the register modules it removes itself.
  • minor (dataset-clone-script.md): linked worktree add --dataset <name> and linked branch start <m> --worktree --dataset <name> now print how to fill the new dataset from the app's own clone script instead of fixed script paths:
    • The app adds an npm script clone-dataset to its root package.json that copies its data into the dataset named by its one argument. The hint is then Clone the data into <name> first (from <root>): npm run clone-dataset -- <name>.
    • To use another script name, set datasetCloneScript in linked.config.js: defineConfig({datasetCloneScript: 'data:clone'}) (new optional LinkedConfig key).
    • Without the script (or when datasetCloneScript names a script package.json lacks), a warning says the dataset starts empty unless it is cloned by hand, and how to add the script.
      New exports from the worktree command module: datasetCloneHint, datasetCloneMessages, readDatasetCloneScript, DEFAULT_DATASET_CLONE_SCRIPT, appPort; DEFAULT_APP_PORT (4040) from the start command.
      Wording: worktree add without --port names the app's own port (its .env PORT, else 4040) as the main checkout's, and branch land says "Restart the app on …". See docs/integration-branches-and-worktrees.md, "Cloning a dataset".
  • patch (debuginfo-stale-todo.md): Removes a stale commented-out TODO about linked.config.json from debugInfo.
  • patch (host-app-generic.md): Comments and docs describe the host app generically.
  • patch (land-build-order.md): One dependency order for release PRs, checkout and branch land, with the build tool ordered as linked build-all orders it: the build tool's own dependencies, then the build tool (@_linked/cli), then everything else. The packages that devDepend on the build tool while it depends on one of them (@_linked/core) formed a cycle, which fell back to name order and could put a package before the build tool. branch land therefore built such a package with the old build tool. When the build tool fails to build in branch land, the packages after it are not built (and so not pushed).
  • patch (namespace-iri-characters.md): linkedOntologies namespaces and the namespaces of linked.app.json prefixes refuse the characters that cannot appear in a SPARQL or Turtle IRI (<, >, ", {, }, |, ^, backtick, backslash, whitespace and control characters). NAMESPACE_IRI is exported from utils/ontologyConfig.
  • major (ontology-index-and-app-prefixes.md): One ontology index per package, and an app's own prefix map in linked.app.json.
    Ontology modules (breaking). linked generate-ontology writes, per package:
    • src/ontologies/<module>.ts for each generated ontology: only its terms, each export const Term = {id: '<namespace>Term'}; (the value createNameSpace(namespace)('Term') returns). It imports nothing; use createNameSpace from @_linked/core/utils/NameSpace where code needs a namespace function.
    • src/ontologies/index.ts: imports every ontology module of the package (those with "generated": false too) and registers them all with one registerOntologies([{name, namespace, terms, data, suggestedPrefix}], import.meta.url) call. registerOntologies comes from the package's src/package.ts (linkedPackage(...)), so it needs the @_linked/core major that provides it.
    • The package entry (src/index.ts[x]) imports ./ontologies/index.js; side-effect imports of a removed <module>.register.js become an import of the index.
    • <module>.data.ts and <module>.register.ts are no longer generated: the command removes the ones it wrote before. Their exports (ns, dataFiles, loadData, _ontologyResource) are gone; import createNameSpace from core instead of ns.
    • linked build's ontology check also fails when the entry does not import the index or such a file is left. Run linked generate-ontology and commit the result.
    • A module written by hand ("generated": false) no longer registers itself: the index does.
    • create-package --kind ontology and create-ontology write this layout; the package template's src/package.ts exports registerOntologies instead of linkedOntology.
    • The build's shape check expects a package's ontologies to register through ontologies/index.js (or src/ontologies/index.ts before it is built).
    • @_linked/cli/utils/ontologyModules: generateOntologyModules(specs, handWritten?) returns every module of a package (terms modules and src/ontologies/index.ts); new generateOntologyIndexModule; generateOntologyDataModule and generateOntologyRegisterModule are removed; OntologyModuleSpec.ontology is removed. generatePackageOntologies returns {ontologies, files, edits, remove}.
      linked.app.json (new). An app's declarative settings at its root: {"$schema": "https://linked.cm/schema/app/1.json", "schemaVersion": 1, "prefixes": {"<prefix>": "<namespace>"}}. The schema ships as schema/app/1.json; an unknown schemaVersion or key is refused; a prefix is ^[A-Za-z][A-Za-z0-9_]*$.
  • minor (ontology-module-and-hand-written.md): A linkedOntologies entry names its module and may keep its modules written by hand.
    • "module" (optional, the same pattern as a name, default the name) is the modules' file name in src/ontologies/: a generated ontology's files are <module>.ts, <module>.data.ts and <module>.register.ts, imported as <package>/ontologies/<module>. The registration still uses the name: linkedOntology(terms, ns, '<name>', …). Two entries with one module are refused.
    • "generated": false (default true) declares an ontology whose modules hold more than the generator writes. linked generate-ontology writes nothing for it and linked build skips its staleness check, but its data must carry the same vann triples, and the build refuses it without them:
      "linkedOntologies": {
        "core": {"namespace": "https://example.org/core/", "module": "linked-core", "generated": false}
      }
    • New pure module @_linked/cli/utils/ontologyConfig: readOntologyConfigs(pkgJson) returns {name, namespace, module, generated, data} per ontology, sorted by name. OntologyConfig, ONTOLOGIES_KEY, ONTOLOGY_NAMESPACE and readOntologyConfigs move there from @_linked/cli/utils/generateOntology.
    • OntologyModuleSpec.module (optional) names the generated files.
  • minor (ontology-names-and-vann-prefix.md): Ontologies are keyed by their name within the package, and their suggested prefix is data.
    • package.json "linkedOntologies" is keyed by the ontology's name (lowercase letters and digits, single - or _ between them). The name names the modules (src/ontologies/<name>.ts, .data.ts, .register.ts) and is the third argument of the generated linkedOntology(terms, ns, '<name>', loadData, dataFiles). It is no longer a prefix.
    • linked generate-ontology reads the suggested prefix from the vann:preferredNamespacePrefix of the ontology's owl:Ontology node and writes Prefix.add('<that prefix>', '<namespace>') in <name>.data.ts.
    • A package without vann data now fails its build (and linked generate-ontology): every ontology's owl:Ontology node must carry exactly one vann:preferredNamespacePrefix and one vann:preferredNamespaceUri equal to its configured namespace. The message names the package, the ontology and its files, and shows the triples to add. To fix it, add to one of the ontology's data files (for a published vocabulary shipped unedited, a src/data/<name>-added.ttl listed in its data):
      @prefix owl: <http://www.w3.org/2002/07/owl#> .
      @prefix vann: <http://purl.org/vocab/vann/> .
      <http://example.org/ont/> a owl:Ontology ;
          vann:preferredNamespacePrefix "ex" ;
          vann:preferredNamespaceUri "http://example.org/ont/" .
      Write the prefix the package registers today, so its Turtle output does not change, then run linked generate-ontology.

Verification

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

flyon and others added 28 commits November 2, 2026 01:07
…ne-dataset script (or datasetCloneScript), warn when it has none; port hint names the app's port

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ead from the ontology's vann data, refused without it

generate-ontology names the modules and the linkedOntology registration by the
linkedOntologies key (lowercase), and writes Prefix.add from the
vann:preferredNamespacePrefix of the ontology's owl:Ontology node. The build and the
command refuse an ontology without that prefix, or whose vann:preferredNamespaceUri is
not its namespace, naming the package, the ontology, its files and the triples to add.
The ontology scaffold writes both triples.
…module" and "generated": false; the declarations read by a pure readOntologyConfigs
…package registering every ontology; the template and create-ontology write that layout
…linked prefixes, and generate-ontology in an app), the map loaded at server start and into the client bundle; the ontology index calls registerOntologies with the module URL
…datasetCloneScript, publish, server); linked.config.js is refused; LINKED_RPC_EXPOSURE wins over server.rpcExposure; defineConfig and the webpack module types removed
…urtle IRI

linkedOntologies namespaces and linked.app.json prefix namespaces share
NAMESPACE_IRI, exported from utils/ontologyConfig.
land built the landed packages in release order, which follows only the
dependencies a package.json lists, so a package that runs `npx linked`
without listing @_linked/cli could build before it with the old tool.
Use build-all's order (orderBuildToolFirst) instead, and skip the rest
when the build tool fails to build.
The earlier commit misnamed the cause. auth does list @_linked/cli (as a
devDependency), but cli depends on core and core devDepends on cli. With
that cycle no repo was ready, so dependencyOrder fell back to rel order
for everything left, which put auth before cli.

dependencyOrder now orders the build tool as build-all does: edges to it
count as satisfied, its own dependencies come first, then the tool, then
the rest. Release PRs, checkout and land share this one order, and land
no longer has an ordering of its own.
@flyon

flyon commented Nov 24, 2026

Copy link
Copy Markdown
Contributor Author

Merged with "Dual-copy e2e" red as a one-off, approved exception ("Build & Test" is green). The e2e scaffolds the app template's main, which still has linked.config.js and the 2.x framework set; with this cli (core ^3) that is a refused config and two copies of core. Expected to fail until the coordinated set and the template are published, per the release plan; re-run once they are.

@flyon
flyon merged commit 3ee94df into main Nov 24, 2026
2 of 3 checks passed
@linked-fw-release linked-fw-release Bot mentioned this pull request Nov 24, 2026
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