Summary
When an app initializes a ConceptApi registry pointing to a dev API (e.g., https://dev.bartoc.org/api/) and then loads schemes from BARTOC, subsequent operations on those schemes may silently use production instead. This happens because cdk.registryForScheme(scheme) (and helpers that call it, like scheme._getTop()) resolve a registry from scheme.API, which in BARTOC entries typically points at production (https://bartoc.org/api/).
This makes concept browsing/search inconsistent in dev bartoc.org: parts of the UI and scripts hit prod even though the global configuration says dev.
Expected behavior
If the application is configured to use ConceptApi against https://dev.bartoc.org/api/, all vocabulary operations during a dev run should hit dev unless explicitly overridden by the app.
Minimal reproduction
import { cdk, addAllProviders } from "cocoda-sdk"
addAllProviders()
const registry = cdk.initializeRegistry({
provider: "ConceptApi",
api: "https://dev.bartoc.org/api/",
})
;(async () => {
const schemes = await registry.getSchemes({
params: { uri: "http://bartoc.org/en/node/20002", limit: 10 },
})
const scheme = schemes[0]
console.log("global registry _api:", registry._api) // -> https://dev.bartoc.org/api/
console.log("resolved _api:", cdk.registryForScheme(scheme)._api)
// -> https://bartoc.org/api/ (from scheme.API)
// This hits prod:
try {
const topViaScheme = await scheme._getTop()
console.log("topViaScheme:", topViaScheme.length)
} catch (e) {
console.error(e)
}
// This hits dev (only because we explicitly call our registry):
const topViaDev = await registry.getTop({ scheme })
console.log("topViaDev:", topViaDev.length)
})()
Root cause
registryForScheme(scheme, dataType="concepts"):
- returns
scheme._registry if set;
- otherwise iterates over
scheme.API and instantiates a provider for the first matching endpoint; result is cached by type+url.
In environments where BARTOC records contain prod endpoints (as they should), the resolution pulls the prod provider even in dev runs.
Proposal (backward-compatible)
Add optional overrides to registryForScheme so apps can keep dev fully on dev without forking or monkey-patching.
API
registryForScheme(scheme, dataType: "concepts" | "mappings" | ... = "concepts",
opts?: {
/** If provided, return this registry immediately. */
preferRegistry?
}
): Object
Semantics
- If
preferRegistry is set, return it directly (highest priority).
Example usage
Prefer the app’s dev registry
const dev = cdk.initializeRegistry({ provider: "ConceptApi", api: "https://dev.bartoc.org/api/" })
const resolved = cdk.registryForScheme(scheme, "concepts", { preferRegistry: dev })
// resolved === dev
Backward compatibility
- No behavior changes unless
opts are passed.
- Existing code continues to prefer
scheme.API exactly as today.
Docs
A short note in the README (or JSDoc) explaining:
- Why
registryForScheme prefers scheme.API.
- How to keep a dev run on dev (show
preferRegistry and “call your registry” pattern).
Summary
When an app initializes a
ConceptApiregistry pointing to a dev API (e.g.,https://dev.bartoc.org/api/) and then loads schemes from BARTOC, subsequent operations on those schemes may silently use production instead. This happens becausecdk.registryForScheme(scheme)(and helpers that call it, likescheme._getTop()) resolve a registry fromscheme.API, which in BARTOC entries typically points at production (https://bartoc.org/api/).This makes concept browsing/search inconsistent in dev bartoc.org: parts of the UI and scripts hit prod even though the global configuration says dev.
Expected behavior
If the application is configured to use
ConceptApiagainsthttps://dev.bartoc.org/api/, all vocabulary operations during a dev run should hit dev unless explicitly overridden by the app.Minimal reproduction
Root cause
registryForScheme(scheme, dataType="concepts"):scheme._registryif set;scheme.APIand instantiates a provider for the first matching endpoint; result is cached bytype+url.In environments where BARTOC records contain prod endpoints (as they should), the resolution pulls the prod provider even in dev runs.
Proposal (backward-compatible)
Add optional overrides to
registryForSchemeso apps can keep dev fully on dev without forking or monkey-patching.API
Semantics
preferRegistryis set, return it directly (highest priority).Example usage
Prefer the app’s dev registry
Backward compatibility
optsare passed.scheme.APIexactly as today.Docs
A short note in the README (or JSDoc) explaining:
registryForSchemeprefersscheme.API.preferRegistryand “call your registry” pattern).