JSON Schema
The portable artifact — composed, versioned, and usable from any language
Everything in DisclosureOS is expressible as JSON Schema (draft 2020-12). This is what makes it a standard rather than a TypeScript library: a Python ingest pipeline, a Rust validator, and a TS app can all enforce the identical contract.
The artifacts
Every package commits a versioned schema artifact and exposes it as a subpath:
| Artifact | Import |
|---|---|
| Records core | @disclosureos/records/schema |
| Observables slot | @disclosureos/observables/schema |
| Origins slot | @disclosureos/origins/schema |
| Scoring result shapes | @disclosureos/scoring/schema |
| Enriched observation (composed) | @disclosureos/schema/schema |
Each is wrapped in the same envelope:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://os.disclosure.org/schema/schema/1.0.0/enriched-observation.json",
"x-schema-version": "1.0.0",
"$ref": "#/$defs/Observation",
"$defs": { "Observation": { /* ... */ } }
}The $id URLs are canonical and versioned — non-JavaScript consumers can pin an exact contract version.
The composed schema
composeObservationSchema() folds the records core and every registered slot into one enriched Observation schema:
import { composeObservationSchema } from '@disclosureos/schema';
const schema = composeObservationSchema();The composition is a plain-data merge with three properties worth knowing:
- Slots become real properties.
observableAssessmentsandoriginappear inproperties,$ref-ing the$defstheir owner packages emitted. - The root closes. The records core schema is open (
additionalProperties: true) because slots attach by augmentation; the composed schema tightens toadditionalProperties: false— the JSON Schema equivalent of the unknown-key rejection inparseEnrichedObservation. $defsstay disjoint. Each layer owns its definition names; a collision throws instead of silently winning.
Using it outside TypeScript
import json
import jsonschema
with open('node_modules/@disclosureos/schema/schema/enriched-observation.schema.json') as f:
schema = json.load(f)
jsonschema.validate(instance=observation, schema=schema)Anything with a draft 2020-12 validator works the same way: Rust (jsonschema), Go (santhosh-tekuri/jsonschema), Java (networknt), or a $ref-aware code generator for typed models in your language.
Drift protection
The committed artifacts are guarded by drift tests: regenerating the schema in CI and diffing against the committed file. A layer schema change that alters the composed artifact fails the build until the artifact and its version are updated deliberately. When you see x-schema-version change, the contract changed — never silently.
Custom contracts
Compose with a custom registry to emit a narrower or extended artifact for your own ecosystem:
import { ExtensionRegistry, composeObservationSchema } from '@disclosureos/schema';
const registry = new ExtensionRegistry();
// register only the slots your consortium uses...
const contract = composeObservationSchema(registry);