Skip to main content

OSCO — OptimNet Supply Chain Objects

A typed supply-chain ontology and an ontology-driven data-preparation engine in one distribution, with a clean layer boundary. Notes and packages stay separate: a note is an engine that accepts a ProblemSpec; packages provide the blocks a spec names. OptimNet is the foundation both stand on.

Install

pip install osco            # ontology, catalog, notes, spec (no dependencies)
pip install "osco[engine]"  # plus the polars data-preparation engine

Layers

Layer Import What it is Deps
Ontology osco.ontology typed entities, fields, relationships, invariants, profiles none
Names osco.ontology.names validated name constants T / F / L none
Catalog osco.catalog agent-facing describe / search / graph / context none
Notes osco.notes note contracts: input field subsets, output entities, note JSON none
Spec osco.spec the AI-facing ProblemSpec and its fingerprint none
Lint osco.lint cross-entity consistency checks of the whole ontology none
Export osco.scripts.export_json_schema JSON Schema files per profile, plus the catalog document none
Engine osco.prepare ontology-driven validation and preparation of input tables polars (osco[engine])

Design

  1. One source of truth per table. An Entity holds schema, semantics, relationships, invariants and profile overlays in one typed object; JSON Schema and name constants are derived, never stored.
  2. Profiles are overlays. One entity plus thin ProfileOverrides (requiredness flips, exclusions) serves every profile, so profiles cannot drift apart.
  3. Semantics are first-class. Every field carries a mandatory meaning (written for LLM grounding), optional synonyms, and a physical unit. catalog.search("minimum order quantity") resolves to vendor_contract.moq. This is what makes the ontology usable as an agent's vocabulary, not just a validator's checklist.
  4. Relationships are declared, not discovered. FK edges are data on the entity; the engine derives its integrity checks from them and the catalog can render the whole join graph.
  5. Invariants are declared. Row-level business rules (open_date <= close_date, min_stock <= max_stock) live on the entity as SQL expressions; the engine enforces them generically.
  6. No codegen. T / F / L name constants are derived at import time and validate on access with did-you-mean suggestions. There is no file to regenerate and forget.
  7. The engine is table-agnostic. Every preparation step reads only the EntityView; there is zero table-specific code. Adding a table = adding one entity file.
  8. The engine's own reports are ontology entities (validation_detail, validation_summary).
  9. Determinism is enforced in code, not by prompt discipline: PK dedupe sorts first, report frames have fixed schemas, specs fingerprint canonically (spec.fingerprint() + data hash = run identity).

Quickstart

import polars as pl
from osco.ontology.names import T, F, L
from osco.prepare import Preparer
from osco import catalog

# names, validated at access time
T.vendor_contract                  # "vendor_contract"
F.vendor_contract.moq              # "moq"
L.location.location_type.WAREHOUSE # "warehouse"

# agent-facing catalog
catalog.search("minimum order quantity")[0]   # -> vendor_contract.moq
catalog.describe("lane", profile="transportation")
print(catalog.to_context(names=["demand_forecast"]))  # prompt grounding block

# the preparation engine
prepared = Preparer(profile="planning", strict=False).prepare({
    "location": pl.read_csv("location.csv"),
    "product": pl.read_csv("product.csv"),
    "calendar_period": pl.read_csv("calendar.csv"),
    "demand_forecast": pl.read_csv("demand.csv"),
})
clean = prepared.tables["demand_forecast"]
prepared.report.summary_frame()    # validation_summary as a DataFrame

The AI-emitted spec:

from osco.spec import ProblemSpec, BlockRef

spec = ProblemSpec(
    problem="supply_plan", profile="planning",
    objective=("maximize_service", "minimize_cost"),
    blocks=(BlockRef("demand_fulfilment", {"backlog": True}),
            BlockRef("vendor_capacity", {"vendor": "V1"})),
    inputs=("demand_forecast", "vendor_contract", "location",
            "product", "calendar_period"),
    outputs=("validation_summary",),
    horizon={"buckets": 13, "granularity": "week"},
    solver={"engine": "gurobi", "mip_gap": 0.005},
)
spec.fingerprint()   # stable content hash — half of a run's identity

Tests

pip install -e '.[dev]'
pytest tests/    # 34 tests: ontology, names, catalog, notes, spec, engine

Metadata

Release files for osco 0.1.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for osco 0.1.1
File Size Uploaded Provenance
osco-0.1.1.tar.gz 36.1 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for osco 0.1.1
File Interpreter ABI Platform
osco-0.1.1-py3-none-any.whl Python 3 none any Details

Total release size: 77.6 kB

Release files / osco-0.1.1.tar.gz

Download URL osco-0.1.1.tar.gz
Size 36.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fc8dd7cade0a17a956ca8529f5a074181934c4a0b05d144ed44b37d721b68d83
BLAKE2b-256 checksum
How to use checksums
9b19a30486163c176b6c3e4b09bef22160dccccff66c16d663eee3cb63cb32b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Release files / osco-0.1.1-py3-none-any.whl

Download URL osco-0.1.1-py3-none-any.whl
Size 41.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d9494eb059370db4df8c1a246aef5276dab506f4294956a99dfe34048bd032bf
BLAKE2b-256 checksum
How to use checksums
7b242339e9d1996711e12f87e28aa58825b45fcfaafde37fb32f231a9a5e4f3c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

Security for osco 0.1.1

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for osco-0.1.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Oct 24, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.1 This release

2 release files Full provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page