Repository Public
1<!--2ORIX Cosmos3File: ARCHITECTURE.md4Description: Module layout, layering rules, shared conventions and engineering rules every contributor (human or agent) follows.5Author: Simon-Pierre Boucher6Contact: contact@spboucher.ai7-->8# ORIX Cosmos — Architecture910ORIX Cosmos is a native macOS (Apple Silicon) astronomical atlas, digital observatory and11astrophysics laboratory. Swift 6, SwiftUI + AppKit + MetalKit, own Metal renderer, SQLite for12metadata, indexed binary files for large catalogues. No game engine, no web view, no mandatory server.1314## 1. Environment the project was built on1516| Item | Value (audited 2026-11-24) |17|---|---|18| Machine | MacBook Pro, Apple M5 Max, 18 CPU cores, 40 GPU cores, 48 GB |19| OS / Xcode / Swift | macOS 27.0 · Xcode 27.2 · Swift 6.4.2 |20| Metal | Metal 4 reported by the system; capabilities are detected at runtime |21| Deployment target | **macOS 15.0** — same floor as the other ORIX macOS apps; gives Metal 3, MetalFX, Swift Testing, modern SwiftUI. Newer features are runtime-gated |22| Project generation | XcodeGen (`project.yml`) for the app; one SwiftPM manifest (`Package.swift`) for all modules |2324## 2. Modules2526One SwiftPM target per directory `Packages/<Module>/Sources`, tests in `Packages/<Module>/Tests`27(fixtures in `Tests/Fixtures`, never used as production data). The allowed dependency edges are28declared in `Package.swift`; the compiler enforces them.2930| Module | Responsibility |31|---|---|32| CosmosCore | Scientific status, provenance, `Measured<T>`, typed units, constants, `ObjectID`, `Instant`, `StateVector`, provider protocols |33| CosmosMath | Vectors/matrices/quaternions in Double, Chebyshev, interpolation, root finding, ODE helpers, statistics |34| CosmosTime | UTC/TAI/TT/TDB/UT1, leap seconds, Julian dates, calendar, simulation clock |35| CosmosCoordinates | Frame rotations (ICRF, ecliptic, galactic, body-fixed), precession/nutation, sidereal time, spherical/topocentric conversions |36| CosmosEphemeris | DAF/SPK kernel reader, text-kernel (LSK/PCK) parser, body orientation, light-time/aberration, sampled trajectories |37| CosmosCatalog | Object model, SQLite metadata store, binary star/galaxy catalogues, search |38| CosmosSpatial | Scale hierarchy, floating origin, octree / HEALPix indices, LOD selection |39| CosmosRender | Metal engine: frame graph, pipelines, planets, atmospheres, rings, stars, galaxies, trajectories, labels |40| CosmosPlanetary | Physical and visual descriptions of bodies (radii, rotation, textures, atmosphere parameters, rings) |41| CosmosAstrodynamics | Kepler elements, SGP4, Lambert, Hohmann, delta-v, event finding (eclipses, transits, conjunctions, phases) |42| CosmosCosmology | FLRW distances, lookback time, horizons |43| CosmosObservation | Topocentric sky, rise/set, refraction, telescope field of view, HR diagram data, FITS/WCS |44| CosmosLaboratory | N-body solvers, integrators, experiments, diagnostics, reproducibility records |45| CosmosDataPacks | Pack manifests, SHA-256, resumable download, atomic install, archive validation, quotas |46| CosmosExport | PNG, CSV, JSON, PDF, video, reproducibility bundle |47| CosmosScripting | Restricted, sandboxed scripting language and API |48| CosmosAI | Optional assistant with typed tools; never a source of scientific values |49| CosmosUI | SwiftUI/AppKit interface; the only module that sees everything |5051`App/` holds the thin application target, `Shaders/` the Metal Shading Language sources,52`DataPipeline/` the scripts that turn public source data into packs, `Benchmarks/` the headless53benchmark runner, `Scripts/` build/test/release tooling, `Documentation/` user documentation.5455## 3. Conventions (binding)56571. **Units.** SI internally: metres, seconds, kilograms, radians, m/s. Kernels in km are converted at58 the reader. Public APIs use the typed quantities of `CosmosCore` or name the unit in the parameter.592. **Time.** The time argument of every dynamical computation is `Instant` (TDB seconds past J2000.0).60 UTC appears only at input/output boundaries.613. **Frames.** Default axes are ICRF (treated as J2000 equatorial, as JPL kernels do). A `StateVector`62 always names its frame and its centre.634. **Precision.** Absolute positions are `SIMD3<Double>` on the CPU. The renderer receives positions64 relative to the camera (floating origin) and only then narrows to float32.655. **Unknown is nil.** A missing value is `nil`, never `0`, never a guessed default.666. **Status and provenance.** Anything shown to the user carries a `ScientificStatus` and, when it comes67 from data, a `Provenance.ID`. Approximate modes (Kepler, pedagogical scale) are labelled as such.687. **No silent extrapolation.** Outside coverage, providers throw `CosmosError.outOfCoverage`.698. **Identifiers.** `ObjectID` values are stable and namespaced; they are never renumbered.709. **Concurrency.** Swift 6 language mode, strict concurrency. Long work is cancellable (`Task.checkCancellation`),71 streams apply backpressure, UI state is `@MainActor`.7210. **Data honesty.** Production data comes from the pipeline with recorded provenance and licence.73 Test fixtures live under `Tests/Fixtures` only. No invented numbers, no fabricated test or benchmark results.7411. **Headers.** Every first-party source file starts with the ORIX Cosmos header (File, Description, Author, Contact).7512. **No private keys, tokens or personal data** in the repository, logs or artefacts.7677## 4. Rendering and data flow7879```80 packs (SQLite + binary) -> Catalog / Ephemeris providers -> scene assembly (CosmosUI, Double, ICRF)81 | camera-relative, float3282 time (CosmosTime clock) -> Instant -----------------------------+-> CosmosRender (Metal) -> MTKView83```8485The renderer never imports catalogue or simulation modules: it draws a value-type scene description.86The laboratory never mutates the reference universe: experiments are separate documents.8788## 5. Decision log8990See `Documentation/DECISIONS.md`.91