Facility Packages#

The facility code leaves the framework as two distributions. osprey-facility holds the description and its build: it reads the sources under data/facility/ and writes facility.json. osprey-panels is the panel engine: it reads facility.json and writes Canopy screens. The framework keeps the views, the settings and the command line, and reaches the description through its public modules only.

Today the description is the osprey-facility package under packages/osprey-facility, and the panel engine is the osprey-panels package under packages/osprey-panels. This page states the end state, why each part of it is the way it is, which phase of the split realises it, and how a check holds the code to it while the split is under way. What the build writes is in Facility File and Its Views; the version rules of the document are in The facility.json Contract.

The facility packages: the framework, osprey-facility, osprey-panels and osprey-connectors, the directions each may import, and facility.json as the one seam between the facility and the panels Read left to right along the data flow, with the import directions drawn in accent. Column 1, the source: the facility tree, its records, documents, layers and scenarios, and the panels data beside them. Column 2, the description. osprey-facility, imported as osprey_facility, holds the description and the build, imports nothing of osprey, and depends on pydantic, PyYAML, packaging and numpy; it is released under its own tags, osprey-facility-v*. The build reads the facility tree. Above it sits the framework, osprey: views, settings, the CLI and the engine implementations such as pyat. The framework imports osprey-facility through its public API only. Below it sits osprey-connectors, which holds the engine contract at osprey_connectors.simulation.engines; osprey-facility depends on it, and the framework's engines implement that contract. Column 3, the seam. The build is the sole producer of facility.json, written under the render root. Its header is osprey.facility.facility/N, it has a published JSON Schema, and every reader checks N before it reads; the framework reads it too. A box of edges that do not exist: osprey-facility never imports osprey; osprey-panels never imports osprey or osprey_facility; the framework never imports osprey_panels. Column 4, the panels. osprey-panels, imported as osprey_panels, reads facility.json, the panels data and a theme file passed in, depends on the standard library and jsonschema only, has its own command, osprey-panels write, check and classes, and is released under its own tags, osprey-panels-v*. A fork is a separate distribution that replaces it. It emits Screen-IR, validated at run time against the schema it vendors; a sync test holds the vendored schema to Canopy at the pinned commit. Footer: panels and facility meet only in facility.json; an import outside the accent arrows fails the boundary check. 1 · SOURCE 2 · DESCRIPTION 3 · SEAM 4 · PANELS OSPREY · FRAMEWORK views · settings · CLI engine implementations (pyat …) imports osprey_facility's public API, nothing else of it reads facility.json, checks /N FACILITY TREE records/ · documents.yaml layers · scenarios panels/ data, read by osprey-panels at write time OSPREY-FACILITY import osprey_facility description + build imports nothing of osprey pydantic · PyYAML packaging · numpy tags osprey-facility-v* OSPREY-CONNECTORS the engine contract osprey_connectors .simulation.engines its own repository FACILITY.JSON osprey.facility.facility/N published JSON Schema sole producer: the build <render root>/facility.json every reader checks /N NO IMPORT osprey-facility → osprey osprey-panels → osprey osprey-panels → osprey_facility framework → osprey_panels OSPREY-PANELS import osprey_panels reads facility.json, checks /N + panels/ data + theme file stdlib · jsonschema osprey-panels write | check | classes tags osprey-panels-v* SCREEN-IR validated at run time against the vendored schema CANOPY · PINNED COMMIT a sync test holds the vendored schema to the pinned schema read writes reads emits pinned to imports public API depends on framework engines implement the contract reads, checks /N osprey-facility and osprey-panels meet only in facility.json; an import outside the accent arrows fails the boundary check.

The decisions#

Each decision states the end state, the reason, the phase that realises it and what holds today.

1. The panel engine reads the document only#

The engine reads facility.json at a declared, checked version and imports no facility code. The build also writes into the document the two things the engine derives from the vocabulary today: the effective signal-role table (nameplate and title) and the relation types.

Why: a fork of the engine tracks one versioned document, not the description’s Python API, and importing the engine no longer loads click, the build stack and osprey.simulation.

Phase: 2, done. Today: the engine reads facility.json at /4 and imports no description module; the build writes the signals and relation_types tables.

2. facility.json is a versioned document with a published schema#

The build is the only producer. The header is osprey.facility.facility/N; N goes up when a key is removed, renamed, retyped or changes meaning, and stays when a key is added. Readers ignore keys they do not know, check N against the versions they declare, and refuse any other with “rebuild with osprey build”. A test pins the document’s generated JSON Schema, so a shape change fails until its author bumps N or marks the change additive.

Why: the document is the description’s product. A fork or a non-Python reader needs a contract it can check by machine, and one number is the only thing a reader has to compare.

Phase: the panel engine checks the version in phase 2, the framework readers in phase 3 with the write guard first, and the schema ships in the package in phase 4. Today: the build writes /4, a test pins the schema against the floor of each N, the schema ships in the osprey-facility wheel, and every reader refuses any other version. The exact rules and the reader table are in The facility.json Contract.

3. The description and the framework split as the code reads#

osprey-facility gets the records, relations, combine, sources, compute, build, wiring and validate (without its command-line reporting), the serialisation half of the renderer, the scenario rosters and checks, the scenario session model (osprey_facility.sessions), the layers, the schema and vocabulary, the kinds with the five built-in kinds, the pure helpers from the simulator and pyAML views, and its errors as plain exceptions without click.

The framework keeps the views, the settings, the bundled facility, the step that renders the facility outputs, the check of scenario sessions against MCP server names, the click adapter for the errors and the command line. osprey-panels gets the panel engine.

osprey-facility depends on osprey-connectors, pydantic, PyYAML, packaging and numpy, with scipy and accelerator-toolbox in an mml extra. It does not depend on pyaml-cs-osprey: the one kind name it borrows from there becomes its own. osprey-panels needs the standard library and jsonschema; it writes its files atomically itself.

Why: this is where the imports already fall once the cycle is cut. pyaml-cs-osprey imports the framework’s runtime, so a dependency on it would bring the framework back into the description.

Phase: 3 untangles the description from the framework, 4 makes it a package, 5 makes the panel engine a package. Today: the description is osprey-facility and imports neither the framework nor click; the panel engine is osprey-panels and imports neither the framework nor osprey_connectors.

4. The simulation-engine contract lives in osprey-connectors#

The engine Protocol, its optional names, the entry-point group name and the calibration math move to osprey_connectors.simulation.engines.

Why: the description calls the engines, the framework implements them and the virtual accelerator loads them. osprey-connectors is the one layer all three depend on, so the contract is spelled once. The cost is a larger public API in osprey-connectors and its compatibility table.

Phase: 3. Today: the contract lives there, and the group has one spelling, osprey_connectors.simulation.engines, held by that module’s ENGINE_GROUP. The engine implementations, such as osprey.simulation.engines.pyat, stay framework code.

5. Names, public modules and the command line#

The distributions are osprey-facility (import osprey_facility) and osprey-panels (import osprey_panels). Each declares its public modules; the rest is private, and a contract enforces it the way the connectors’ public API is enforced. osprey-panels ships its own command, osprey-panels write|check|classes, and the framework’s command line has no panels command. Entry-point groups take the new roots, such as osprey_facility.kinds.

Why: top-level names keep the import contract enforceable. Namespace packages under osprey would share the root, import-linter skips modules that overlap, and which distribution owns a module would blur. A framework command over the engine would mean the framework imports it, and a fork would have to be wired into the framework’s command line too.

Phase: 4 for osprey-facility, 5 for osprey-panels. Today: osprey-facility declares its public modules, the framework and apps reach no description module outside them, and the kinds group is osprey_facility.kinds. osprey-panels declares its public modules, ships the osprey-panels command (osprey-panels), and the framework imports none of it.

6. Both packages have their own tag streams#

Releases are tagged osprey-facility-v* and osprey-panels-v*, built by one release workflow that takes the package as a parameter. The framework depends on osprey-facility with a floor. osprey-panels declares the facility.json versions and the Screen-IR version it supports, not an osprey-facility floor.

Why: each package gets its own version and cadence. One parameterised workflow generalises the connectors’ release stream instead of copying it twice.

Phase: 6. Today: an osprey-facility-v* or osprey-panels-v* tag runs release-package.yml, which publishes that package to PyPI and nothing else. The framework’s v* release builds neither.

7. A fork is a separate distribution that replaces osprey-panels#

A fork reads facility.json at a declared version, the facility’s panels/ data and a theme file the caller passes in, and emits Screen-IR and index.json at declared versions. Layout, symbols and the describe step are the fork’s own code. The engine carries fallback state colours and has no path into the framework. There are no plug-in points inside the engine.

Why: the inputs and outputs are files at declared versions, which is all a replacement needs. Plug-in points would be an abstraction with no second user.

Phase: 5, done. Today: the engine reads the theme file --theme names, else only its fallback state colours, and has no path into the framework.

8. osprey-panels owns its Screen-IR pin#

The engine vendors the Screen-IR schema of the version it emits, and a sync test compares that file with the pinned Canopy commit. write and check validate every screen against it at run time. The version is one named constant. The framework’s Canopy pin keeps pinning the runtime stack and names the engine’s Screen-IR version.

Why: an engine release, a fork or a facility edit cannot emit a screen that fails only once it reaches Canopy.

Phase: 5, done. Today: the engine vendors screen-ir.schema.json and names its version in osprey_panels.screen_ir.SCREEN_IR_VERSION; write refuses and check reports a screen the schema refuses. tests/integrations/canopy/test_screen_ir_pin.py holds the vendored schema and the version to the pinned Canopy commit.

9. Tests live inside each package#

Each package keeps its tests in packages/<package>/tests/<package>_tests/ with its own pytest configuration, and a standalone CI job installs it without the framework and refuses the framework if it appears. The panel tests read a checked-in built facility.json, which an osprey-facility test rebuilds from the fixture tree and compares byte for byte. The description helpers the framework tests use move into osprey_facility_tests; the framework’s build and preset fixtures stay in the framework.

Why: only a test run without the framework proves a package works without it. Test helpers in the wheel would become public API.

Phase: 4 for osprey-facility, 5 for osprey-panels. Today: osprey-facility tests itself in packages/osprey-facility/tests/osprey_facility_tests/, which the osprey-facility-standalone job runs without the framework, and osprey-panels in packages/osprey-panels/tests/osprey_panels_tests/, which the osprey-panels-standalone job runs. The panel tests read packages/osprey-panels/tests/osprey_panels_tests/fixture/facility.json, and packages/osprey-facility/tests/osprey_facility_tests/test_panel_fixture_rebuild.py rebuilds it.

The boundary check#

Two tools hold the code to the end state, and both read one classification.

The classification is the module lists of six import-linter contracts in pyproject.toml. Every module under src/osprey, osprey_facility and osprey_panels sits on one side: description, panel engine, engine contract or framework. osprey_panels is the panel engine, and the whole of osprey is framework, the views, settings, bundled facility, osprey.utils.facility and the engine implementations among them.

lint-imports, run by the import-contracts check, follows every static import between osprey, osprey_connectors, osprey_facility and osprey_panels. Its contracts forbid:

Contract

Forbids

facility-description-standalone

the description importing the framework

facility-description-without-panels

the description importing the panel engine

panels-document-only

the panel engine importing the description or the engine contract

panels-standalone

the panel engine importing the framework or osprey_connectors

framework-without-panels

the framework importing the panel engine

facility-public-api

the framework importing a description module outside the public set

The boundary test, tests/facility/test_package_boundary.py, reads the sides from those lists and checks what import-linter cannot see: imports of third-party distributions outside each package’s dependency set, and dynamic reaches (importlib.import_module strings, importlib.resources.files and paths climbed from __file__). It also keeps the classification whole: a module on no side, or on two, fails, so a new module fails until a list names it. It runs with the invariant tests on every check; negative tests prove that each edge class it guards fails when introduced.

The ratchet#

The edges that existed when the check landed are its baseline. Each is one importer -> imported entry, in the contract’s ignore_imports for a static import or in the boundary test’s third-party and dynamic ratchets, under a # phase N header naming the phase that removes it. Entries are only removed. A new crossing edge fails, and so does an entry whose edge is gone.

Today versus target: the description and the panels each their own package, and the edges the boundary ratchet listed, grouped by the phase that removed them Two halves. The left half is today. The description is its own package, packages/osprey-facility, import root osprey_facility: some 25 modules such as records, combine, build, validate, render, scenarios, compute, layers, kinds, sessions and the schema. It imports no framework code, no click and no pyaml_cs_osprey, and the framework imports it through its public modules only. The panel engine is its own package too, packages/osprey-panels, import root osprey_panels: it reads facility.json, the panel rule tables and a theme file passed in, and imports no framework, no description module and no osprey_connectors. The framework imports no osprey_panels module and has no panels command. No third-party reach is listed. The right half is the ratchet, drawn by edge class and the phase that removed it, not entry by entry. Phase 2, the panels seam, is done and lists no edge: the panels read facility.json only. Phase 3, the facility untangle, is done and lists no edge: it removed every description edge into the framework, the edges to click and to pyaml_cs_osprey, and the engine contract's osprey.simulation.engines spelling, and broke the import cycle. Phase 4, the facility package, is done and lists no edge: it removed the framework's reaches into description modules outside the public API, such as the CLI's read of the MML layer data. Phase 5, the panels package, is done and lists no edge: it removed the framework CLI's import of the panels, the panels' climb to the framework theme, replaced by a theme file passed in, and the panels' import of osprey_connectors.safety_file. Phase 6, release wiring, removes no edge: both packages tag and publish. Footer: the ratchet is empty; an edge of any of these classes fails the boundary check today. TODAY · DESCRIPTION AND PANELS EACH A PACKAGE TARGET · THE RATCHET BY EDGE CLASS AND REMOVING PHASE PACKAGES/OSPREY-FACILITY/ DESCRIPTION · OSPREY_FACILITY ~25 modules: records combine build validate render scenarios compute layers kinds sessions schema … imports no framework, no click, no pyaml_cs_osprey; no cycle PACKAGES/OSPREY-PANELS/ PANEL ENGINE · OSPREY_PANELS reads facility.json, the rule tables and a theme file passed in imports no framework, no description, no osprey_connectors OSPREY FRAMEWORK views settings bundled utils.facility cli · deployment simulation engines (pyat …) imports no osprey_panels imports THIRD-PARTY REACHES none listed: each side imports only its declared dependencies an edge the end state keeps, through the public API PHASE 2 · PANELS SEAM · DONE lists no edge the panels read facility.json only PHASE 3 · FACILITY UNTANGLE · DONE removed description → framework: views helpers, utils.facility, registry.mcp, CLI, deployment, config paths, the osprey.simulation root, engine implementations (pyat …) removed description → click, → pyaml_cs_osprey the engine contract's osprey. spelling → osprey_connectors lists no edge the import cycle is gone PHASE 4 · FACILITY PACKAGE · DONE removed framework → description modules outside the public API, such as the CLI's read of the MML layer data lists no edge; the public API is protected PHASE 5 · PANELS PACKAGE · DONE removed framework CLI → panels removed panels → theme by path climb; a theme file is passed in removed panels → osprey_connectors.safety_file lists no edge; the ratchet is empty PHASE 6 · RELEASE WIRING removes no edge: osprey-facility and osprey-panels tag and publish on their own streams The ratchet is empty: each phase deleted its classes, and an edge of any of these classes fails the boundary check today.

The headers name these phases:

  • Phase 2 removed the panel engine’s imports of facility code and its read of the vocabulary files; its header is empty.

  • Phase 3 removed the description’s imports of the framework (views helpers, osprey.utils.facility, the MCP registry, the bundled kinds, the engine implementations), its click imports in nine modules, its import of pyaml-cs-osprey and the osprey. spelling of the engine contract; its header is empty.

  • Phase 4 removed the framework’s reaches into private description modules, one resource read of the MML layer by the command line among them; its header is empty.

  • Phase 5 removed the framework command line’s imports of the panel engine, the engine’s climb to the framework theme and its atomic writes through osprey_connectors.safety_file; its header is empty.

  • Phase 6 is the release wiring and removes no edge.

Refreshing the baseline#

Main keeps moving while the split is under way, and nothing outside the split knows the check. The baseline is therefore refreshed at one point only: when main is merged into the split’s branch, at each merge back to main. After that merge:

  1. Run lint-imports and the boundary test.

  2. Classify every module main added into a side’s module list.

  3. Enter every new crossing edge main brought under the header of the phase that removes it, in the matching contract’s ignore_imports for a static import and in the boundary test’s third-party or dynamic ratchet otherwise, with the reason and phase.

  4. Delete every entry whose edge main removed.

  5. Run both tools again; they pass with no other change.

At any other time the baseline is never extended: a new edge is fixed, not entered.

See also

The facility.json Contract

The document’s header, bump rule, reader rule and published schema.

Facility File and Its Views

What the build writes into facility.json and the views read from it.