Repository Public
1<!--2ORIX Cosmos3File: Documentation/modules/CosmosCatalog.md4Description: What CosmosCatalog implements (object model, pack storage, search, federation, derived quantities, Milky Way model), the sources with their licences and what was done to them, the packs built, how to rebuild them, validation, measurements and known limits.5Author: Simon-Pierre Boucher6Contact: contact@spboucher.ai7-->8# CosmosCatalog910Object model, storage and search of the catalogues. Depends on `CosmosCore` only (and the system `SQLite3`11library, which needs no manifest change on macOS). No third-party code.1213## 1. What is implemented1415| File | API | Notes |16|---|---|---|17| `Records.swift` | `StarRecord`, `ExoplanetRecord`, `HostStarRecord`, `ExoplanetCandidateRecord`, `DeepSkyRecord`, `GalaxyRecord`, `GalaxyClusterRecord`, `MinorBodyRecord`, `SatelliteElementSet`, `ConstellationRecord`, `CatalogRecord` (enum, JSON), `StarFlags`, `DistanceMethod` | Every quantity is `Measured<Double>?`: unknown = nil. Catalogue-native units carry the unit in the property name (`parallaxMas`, `orbitalPeriodDays`); sky angles are radians, distances metres. |18| `Designation.swift` | `Designation.normalize`, `tokens`, `starKey(of:)`, `editDistance`, `constellations` (88), `StarKey` | Same rules in `DataPipeline/catalogs/designations.py`; 289 shared cases in `Tests/Fixtures/designation_cases.json`. |19| `SQLite.swift` | `SQLiteDatabase` (`readOnlyImmutable` / `readWriteCreate`), `query` with bound parameters, `checkIntegrity`, `hasFTS5Trigram` | Packs are opened `immutable=1`: no WAL, no journal, no lock file. |20| `StarFile.swift` | `StarFile` (memory-mapped), `RawStar`, `StarTile`, `StarSelection`, `StarPoint`, `stream`, `forEachRecord`, `index(of:)`, `verify`, `StarTileCache`, `StarFileWriter` | Format in §3. |21| `CatalogPack.swift` | `CatalogPack: CatalogProvider`, `CatalogPackManifest`, `CatalogSchema`, `searchRanked`, `object(for:)`, `star(for:)`, `coneSearch`, `forEachObject(kind:)`, `children(of:)` | One installed pack. |22| `FederatedCatalog.swift` | `FederatedCatalog: CatalogProvider`, `searchRanked`, `object(for:)`, `preferredStarRecord`, `coneSearch`, `starStream`, `starSources` | All installed packs as one catalogue. |23| `Derived.swift` | `StellarPhysics.absoluteMagnitude`, `bandLuminositySolar`, `temperature(fromBV:)`, `direction(of:atJulianYear:)`, `position(of:atJulianYear:)`, `distance(fromParallaxMas:error:)`, `HRDiagram.extract` | Each result has a status and, where feasible, a propagated uncertainty. |24| `MilkyWayModel.swift` | `MilkyWayModel.Parameters`, `generate(count:seed:)`, `assumptions`, `armCenterline`, `sunPosition` | Reconstruction, never an observation. |2526### How to use it2728```swift29let catalog = try FederatedCatalog(packsDirectory: packsURL) // opens every installed catalogue pack30let hits = try catalog.searchRanked("alf CMa", limit: 20) // ranked; hits[0].summary.id == "hip:32349"31let object = try catalog.object(for: ObjectID("hip:32349")) // designations + typed records of every pack32let star = try catalog.preferredStarRecord(for: ObjectID("hip:70890")) // Gaia if well behaved, else Hipparcos33let near = try catalog.coneSearch(rightAscension: ra, declination: dec, radius: 1 * .pi / 180)34for try await batch in catalog.starStream(StarSelection(center: axis, radius: 0.5, limitingMagnitude: 9)) { … }35let hr = try HRDiagram.extract(from: catalog.pack("stars-gaia-nearby")!.stars!, system: .gaiaG)36let galaxy = MilkyWayModel().generate(count: 200_000, seed: 1) // .status == .reconstructed, .assumptions37```3839`CatalogProvider` (`summary(for:)`, `search(_:limit:)`) is implemented by `CatalogPack` and `FederatedCatalog`.40The 3D index of a star pack (`octree.bin`) is read with `CosmosSpatial.OctreeFile`; its payload is the record41index in `stars.bin` (CosmosCatalog cannot depend on CosmosSpatial, so the UI layer joins the two).4243## 2. Identity and cross-identification4445One object has one `ObjectID` whatever pack describes it; merging in `FederatedCatalog` is a merge by identifier.4647| Objects | Identifier | How the identification is made | Failure modes |48|---|---|---|---|49| Star with a Hipparcos number | `hip:<n>`; its Gaia DR3 `source_id` is an alias resolving to the same object | Gaia archive table `gaiadr3.hipparcos2_best_neighbour` (the archive's own cross-match), forced one-to-one (closest pair wins) | 99 525 of 117 955 Hipparcos stars matched. Unmatched: stars too bright for Gaia (Sirius, Vega, Canopus…), close binaries. `StarFlags.ambiguousCrossMatch` when the archive saw several neighbours; a wrong match is then possible. A Gaia star whose match is missing appears as a separate `gaia3:` object. |50| Other Gaia star | `gaia3:<source_id>` | — | — |51| Nearby Gaia star without Hipparcos number | same, plus names (GJ, traditional) from HYG | position: Gaia J2016 moved to J2000 with its proper motion, separation < 60″, distances within 25 %, unique both ways (766 stars named) | Unnamed when HYG has no entry or the match is not unique; a wrong name is possible in close pairs. |52| Exoplanet / host | `exo:<pl_name>`; host `hip:<n>`, else `gaia3:<id>` as given by the archive, else `exohost:<name>` | identifiers published by the NASA Exoplanet Archive | A host without HIP whose archive Gaia identifier is wrong or absent is not merged with the Gaia star. |53| NGC / IC / Messier | `ngc:<n>`, `ic:<n>` (Messier and duplicates are aliases); addendum objects by their own prefix (`m:40`, `mel:22`, …) | OpenNGC | — |54| 2MRS galaxy | `ngc:` / `ic:` when the 2MRS catalogue name is an NGC/IC/Messier entry, else `2masx:<designation>` | name | Pairs: only the first 2MRS row takes the NGC identifier. |55| Local Group dwarf | `ngc:`/`ic:` when named so (M 32, M 33 = `ngc:598`, SMC = `ngc:292`), else `lg:<name>` | name | LMC is `lg:LMC` (OpenNGC lists it under an ESO name). |56| Cluster, satellite, minor body, constellation, TOI | `abell:<n>`, `norad:<n>`, `naif:<SPK-ID>`, `con:<Abbr>`, `toi:<n.nn>` | — | TOIs are not cross-identified with confirmed planets. |5758Minor bodies use the JPL SPK-ID, i.e. the Horizons extended numbering of `core-ephemeris/kepler_elements.json`:59`naif:20000001` = (1) Ceres (20 000 000 + number), `naif:1000036` = 1P/Halley.6061Stars present in several star packs carry membership bits (`StarFlags.inStarter`, `inHipparcos`, `inGaiaNearby`,62`inGaiaG10`, `inGaiaG12`) computed by the pipeline; `FederatedCatalog.starStream` streams packs in priority order63and skips a record whose star exists in a higher-priority installed pack. Tested on the installed data: 805 51064distinct stars from 942 058 records, none twice, none lost.6566## 3. Storage6768**SQLite store** (`catalog.sqlite`, schema version 1, `CatalogSchema`): `meta`, `provenance`, `objects` (id, kind,69name, status, provenance, ra/dec in radians, `zone` = floor(dec° + 90), mag, parent, typed record as JSON),70`designations` (normalised key `norm`, primary key `(norm, oid)`), `names_fts` (FTS5, trigram tokenizer: available71in the system SQLite 3.54), `blobs`, `star_text` (spectral types). Opened read-only and immutable; `PRAGMA72integrity_check` on demand (`verify: true`). All queries are prepared statements with bound parameters.7374**Star file** (`stars.bin`, magic `COSMSTR1`, version 1, little-endian, memory-mapped): header 128 bytes; tile75directory × 48 bytes (id, order, level, magnitude range, bounding cone, record range); records × 112 bytes (source76key, cross key, ra/dec f64, epoch, parallax ± error, proper motion ± errors, radial velocity ± error, distance77with low/high bounds, magnitude, two colour fields, secondary magnitude, Teff, RUWE, source, distance method,78flags); HIP index and Gaia index (sorted `u64 key, u32 record`, binary search). Absent float = NaN on disk = nil in79the API. Tiles are HEALPix nested pixels per magnitude band (< 6, 6–8, 8–10, 10–12, 12–14, 14–16, fainter), the80order chosen so that a tile holds ≤ 4 096 stars on average; records are sorted by magnitude inside a tile. A view81reads only the tiles whose cone meets its cone down to its limiting magnitude; nothing loads a whole catalogue.82`StarFile.stream` is pull-based (a tile is decoded when the consumer asks: backpressure), ends early on83cancellation, and `StarTileCache` bounds the decoded tiles (LRU by point count). Opening validates magic, version,84sizes, offsets, exact length and the tile directory; `verify()` reads everything (positions inside the tile cone,85magnitude order, indices). The byte layout is specified in the header comment of `StarFile.swift`. The Swift86writer and the pipeline writer produce identical bytes for identical input (tested).8788## 4. Search8990`normalize`: canonical decomposition, diacritics and apostrophes removed, lowercase; Greek letters → IAU91three-letter abbreviations; split into letter runs and digit runs (leading zeros removed); `+` kept, `-` kept only92inside coordinate-style names (after ≥ 4 digits); `Messier` → `m`, `Gliese`/`Gl` → `gj`; constellation genitives →93abbreviations; Greek letter names abbreviated in front of a constellation. So "HIP 32349" = "hip032349",94"M31" = "Messier 31", "α CMa" = "alf CMa" = "Alpha Canis Majoris", "TRAPPIST-1 e" = "trappist 1e".9596Ranking (`MatchClass`): exact designation or name > proper-name prefix > other-designation prefix > substring of a97name (FTS5 trigram) > fuzzy (trigram candidates, optimal-string-alignment distance ≤ 1 up to 4 characters, ≤ 2 up98to 8, ≤ 3 beyond). Inside a class: smaller distance, shorter matched text, brighter object. "HIP n" and99"Gaia DR3 n" are resolved through the star-file indices (no database row needed). Cone search: 1° declination100zones with a right-ascension window per zone, exact test afterwards; stars through the tile directory.101102Measured on the full installed data (11 packs, 963 730 database-or-file objects; 2026-11-24, MacBook Pro M5 Max,103release build, 1-minute load average 13–15 because other builds were running: pessimistic):104105| Query class (20 queries × 20 runs, 10 × 20 for the last two) | p50 | p95 | max |106|---|---|---|---|107| exact designation ("HIP 32349", "M31", "alf CMa", "Gaia DR3 …") | 2.9 ms | 5.7 ms | 8.9 ms |108| exact name ("Sirius", "Andromeda Galaxy") | 1.8 ms | 5.5 ms | 11.3 ms |109| prefix ("sir", "ngc 22", "a") | 2.5 ms | 20.9 ms | 30.2 ms |110| substring ("nebula") | 1.9 ms | 4.1 ms | 4.7 ms |111| fuzzy ("betelgeuze") | 1.4 ms | 2.5 ms | 3.5 ms |112| all 1 600 searches | 2.0 ms | 8.5 ms | 30.2 ms |113114First search on a freshly opened catalogue: 1.9 ms. Opening the 11 packs: 13.7 ms (median of 10). Full115verification (integrity check + star-file verification): 0.003–0.25 s per pack. Cone search (random directions,116stars to magnitude 12): 0.1° p50 1.6 ms / p95 2.5 ms; 1° 1.9 / 2.7 ms; 5° (limit 500) 5.9 / 7.4 ms.117118Streaming (de-duplicated federation): whole sky 805 510 stars in 0.079 s (10.3 M stars/s); magnitude ≤ 6.5:11911 308 stars in 1.4 ms; ≤ 9: 185 566 stars in 18 ms; 30° cone to magnitude 10: 41 062 stars in 8.9 ms (4.1 ms from120a warm tile cache); 5° cone: 1 927 stars in 2.2 ms. Raw record decoding: 13–15 M records/s.121Reproduce: `swift run -c release cosmos-bench catalog.open catalog.search catalog.stream catalog.cone`.122123## 5. Distances, parallaxes and other honesty rules124125- **No naive 1/parallax.** Gaia records carry the Bailer-Jones et al. (2021) *geometric* distance (posterior126 median, 16th/84th percentiles → asymmetric uncertainty, status `estimated`) or none. GCNS records carry the GCNS127 posterior distance. Hipparcos records use the Bailer-Jones distance of their Gaia counterpart when the match is128 unambiguous, RUWE ≤ 1.4, the Gaia parallax error is smaller and Gaia's S/N ≥ 5 (`distanceFromCounterpart`);129 otherwise 1/ϖ **only when ϖ/σ ≥ 5** (status `computed` at S/N ≥ 10, `estimated` below, uncertainty 1/(ϖ ∓ σ));130 otherwise no distance: the star keeps a direction only and `StellarPhysics.position` returns nil.131- Negative or zero parallaxes are kept as published and flagged (`nonPositiveParallax`); S/N < 5 is flagged132 (`lowParallaxSNR`). A Bailer-Jones distance of such a source is dominated by the prior: it is kept, flagged.133 Installed data: 942 058 records, 920 442 with a distance, 4 277 non-positive parallaxes, 65 959 below S/N 5 of134 which 44 346 keep a flagged model distance; no inverse-parallax distance below S/N 5 (test135 `distancePolicyHoldsForEveryInstalledStar`).136- **Parallax zero point.** Stored Gaia parallaxes are the published values; the Lindegren et al. (2021, A&A 649,137 A4) zero-point correction (tens of µas, depending on magnitude, colour, position) is **not applied**. The138 Bailer-Jones distances include it. Hipparcos parallaxes have no such correction.139- Epochs are kept: J1991.25 (Hipparcos), J2016.0 (Gaia). Proper motions, radial velocities (Gaia DR3; GCNS adopted140 value), G/BP/RP, RUWE, GSP-Phot Teff (status `estimated`; fetched for G ≤ 10 only) are stored when present.141- Absolute magnitudes and band luminosities are not corrected for extinction and say so; luminosity is per band142 (V or G), not bolometric. `temperature(fromBV:)` (Ballesteros 2012) is a display estimate.143- **Galaxies**: redshift (cz and z = cz/c, frame stated) and, when it exists, a redshift-independent distance144 (Local Group: from the published distance modulus, status `computed`). No distance derived from a redshift is145 stored; CosmosCosmology computes it at run time.146- **Exoplanets**: published errors and limit flags are kept (`Uncertainty.upperLimit/.lowerLimit`); masses from a147 mass–radius relation are `estimated`; missing parameters are absent (installed: 0 zero-valued parameters).148 TOIs are a separate pack with status `estimated`.149- **Milky Way model**: status `reconstructed`; display choices that nobody measured are `hypothetical` and listed150 in `assumptions`. No image of the Milky Way from outside exists. Parameters: Reid et al. (2019, ApJ 885, 131)151 Table 2 (seven arm segments with kinks, widths) and R₀ = 8.15 ± 0.15 kpc; Bland-Hawthorn & Gerhard (2016, ARA&A152 54, 529) for z☉ = 25 ± 5 pc, thin disc 2.6 ± 0.5 kpc / 300 ± 50 pc, thick disc 2.0 ± 0.2 kpc / 900 ± 180 pc,153 bulge scale lengths (0.70, 0.44, 0.18) kpc at 27 ± 2°, long bar half-length 5.0 ± 0.2 kpc at 28°–33°, stellar154 masses (values checked against the papers' arXiv sources, 1910.03357 and 1602.07702, on 2026-11-24). Arms are155 drawn only over the azimuths that have parallax data.156157## 6. Sources (all retrieved 2026-11-24)158159| Source (provenance id) | Access, release | Licence / terms as stated | Acknowledgement | Transformation |160|---|---|---|---|---|161| Hipparcos new reduction, van Leeuwen 2007 (`esa-hipparcos-2007`); Hipparcos 1997 for V, spectral type, HD (`esa-hipparcos-1997`) | ESA Gaia Archive TAP `https://gea.esac.esa.int/tap-server/tap`, tables `public.hipparcos_newreduction`, `public.hipparcos` | ESA Space Science Archives: CC BY-NC 3.0 IGO; "open and free to use … subject to proper acknowledgment"; commercial use needs prior authorisation (data.licences@esa.int). https://www.cosmos.esa.int/web/esdc/terms-and-conditions | ESA; van Leeuwen (2007) A&A 474, 653 | degrees → radians; distance rule of §5 |162| Gaia DR3 `gaia_source` (`esa-gaia-dr3`) | column subset `gaia.dr3lite` at GAVO `https://dc.g-vo.org/tap` (synchronous queries per magnitude bin); `teff_gspphot` and `gaiadr3.hipparcos2_best_neighbour` from the ESA archive | CC BY-NC 3.0 IGO (https://www.cosmos.esa.int/web/gaia-users/license) | Gaia DPAC acknowledgement (in each manifest); Gaia Collaboration, Vallenari et al. (2023) A&A 674, A1 | degrees → radians; nothing corrected |163| Gaia Catalogue of Nearby Stars (`gaia-edr3-gcns`) | ESA archive `external.gaiaedr3_gcns_main_1` | CC BY-NC 3.0 IGO | Gaia Collaboration, Smart et al. (2021) A&A 649, A6 | kpc → pc |164| Bailer-Jones distances (`bailer-jones-2021`) | GAVO `gedr3dist.main` (the publisher of the catalogue) | derived from Gaia EDR3 (ESA terms); citation requested | Bailer-Jones et al. (2021) AJ 161, 147 | joined on `source_id`, geometric estimate only |165| IAU Catalog of Star Names (`iau-csn`) | https://www.pas.rochester.edu/~emamajek/WGSN/IAU-CSN.txt, file of 2022-04-04 | Creative Commons Attribution (file header) | IAU WGSN | names attached by HIP number |166| HYG v4.1 (`hyg-v41`) | https://github.com/astronexus/HYG-Database | CC BY-SA 4.0 | D. Nash | cross-identifications only (HR, Bayer, Flamsteed, GJ, traditional names) |167| OpenNGC v20260501 (`openngc`) | https://github.com/mattiaverga/OpenNGC | CC BY-SA 4.0 | M. Verga; NED, HyperLEDA, SIMBAD, HEASARC, H. Corwin | sexagesimal → radians; duplicates folded as aliases |168| Stellarium v26.3 sky culture "modern" (`stellarium-modern`) | GitHub tag v26.3 | "Text and data: CC BY-SA 4.0" | Stellarium contributors | figures resolved to Hipparcos positions; B1875 edges interpolated every 0.25° and precessed to J2000 (IAU 1976), checked against VizieR VI/49 (1 850 points, all within the vertex spacing) |169| NASA Exoplanet Archive `pscomppars`, `toi` (`nasa-exoplanet-archive-*`) | https://exoplanetarchive.ipac.caltech.edu/TAP | no licence statement found; acknowledgement and citation of original references requested | standard NASA Exoplanet Archive acknowledgement; Christiansen et al. (2025) | pc → m; errors and limits kept |170| 2MRS v2.4 (`2mrs`) | http://tdc-www.harvard.edu/2mrs/ | README: cite by bibcode; **"Please do not redistribute any of these files."** | Huchra et al. (2012) ApJS 199, 26 | z = cz/c |171| Nearby dwarf galaxies, Jan 2021 (`mcconnachie-2012`) | CADC, `NearbyGalaxies_Jan2021_PUBLIC.fits` | no licence statement; citation requested | McConnachie (2012) AJ 144, 4 | distance from the distance modulus |172| Abell/ACO (`abell-aco-1989`) | VizieR VII/110A via the CfA mirror FTP | CDS rules-of-usage page unavailable on 2026-11-24 (CDS Strasbourg answered "Page unavailable"): terms not read | Abell, Corwin & Olowin (1989) ApJS 70, 1; VizieR | J2000 → radians |173| JPL SBDB (`jpl-sbdb`) | https://ssd-api.jpl.nasa.gov/sbdb_query.api | no licence statement in the API documentation | NASA/JPL-Caltech SSD | elements copied at full precision |174| CelesTrak GP (`celestrak-gp`) | https://celestrak.org/NORAD/elements/gp.php (groups stations, visual, gnss, geo), one request each | usage policy: one download per data update (2 h), stop on HTTP 301/403/404; no licence statement | CelesTrak (T. S. Kelso); 18 SDS | OMM fields copied |175176Choices worth knowing:177- Hipparcos comes from the primary archive rather than HYG (HYG mixes sources and pre-computes distances by plain178 inversion); HYG is used for cross-identifications only, because the VizieR cross-index IV/27A could not be used179 under readable terms on the build day.180- Archive limits observed on 2026-11-24: ESA anonymous jobs are cut at 60 s and 50 000 rows (a 50 000-row answer is181 a truncated one: the adapter discards it and halves the batch); the ARI mirror left a job queued for 18 minutes;182 GAVO asynchronous jobs stayed queued while its synchronous endpoint answered at once. Hence: small adaptive183 batches at ESA, synchronous magnitude bins at GAVO.184- Redistribution classes in each manifest (`redistributionTerms.class` → schema-v1 `redistribution`):185 `yes` and `non-commercial` → `redistributable`; `unverified` (no licence stated, or terms unreadable) and `no`186 (2MRS) → `localBuildOnly`. **The ESA licence is non-commercial**: selling an application that bundles the star187 packs needs ESA's authorisation.188189## 7. Packs built (in `Resources/Packs`, 2026-11-24)190191| Pack | Size | Content | Redistribution |192|---|---|---|---|193| `starter` | 8.2 MB | 10 685 stars (10 507 Hipparcos: V ≤ 6.5, or ≤ 25 pc, or IAU-named, or in a constellation figure, or exoplanet host; 178 Gaia-only within 10 pc), 88 constellations (boundaries + figures), 637 OpenNGC objects (all Messier, named, or V/B ≤ 10) | non-commercial (ESA) + CC BY-SA parts |194| `stars-hipparcos` | 51.8 MB | 117 955 stars, 101 143 with a distance; names, Bayer, Flamsteed, HR, HD, GJ, spectral types | non-commercial |195| `stars-gaia-nearby` | 55.0 MB | GCNS, 331 312 stars within 100 pc, all with a distance | non-commercial |196| `stars-gaia-g10` | 80.1 MB | all 482 106 Gaia DR3 sources with G ≤ 10; 477 502 with a distance | non-commercial |197| `exoplanets` | 44.7 MB | 6 473 confirmed planets, 4 863 hosts | local build only (unverified) |198| `exoplanet-candidates` | 12.2 MB | 8 175 TOIs with dispositions | local build only (unverified) |199| `deep-sky` | 16.0 MB | 13 371 NGC/IC/addendum objects | yes (CC BY-SA 4.0) |200| `galaxies` | 2.2 MB | 144 Local Group / nearby dwarfs (not the Milky Way nor M 31 themselves), 4 076 Abell/ACO clusters | local build only (unverified) |201| `galaxies-2mrs` | 35.8 MB | 43 533 galaxies with heliocentric cz | local build only (**no**) |202| `satellites` | 0.9 MB | 844 objects, element-set epoch per record | local build only (unverified) |203| `minor-bodies` | 4.2 MB | 1 865 numbered asteroids (H ≤ 10), 610 numbered comets | local build only (unverified) |204205Each pack: `manifest.json` (pack-manifest schema v1, validated with `DataPipeline/packs/packtool.py validate`:206all eleven VALID), `catalog.sqlite`, and for star packs `stars.bin` and `octree.bin`. Not built: `stars-gaia-g12`207(see §10) and an SDSS sample.208209## 8. Rebuilding everything210211```212DataPipeline/catalogs/build_all.sh # fetch (cached, resumable) + build + octrees + manifests213DataPipeline/catalogs/build_all.sh --no-fetch # rebuild from DataPipeline/raw/catalogs only214DataPipeline/catalogs/build_all.sh --g12 # also fetch 10 < G <= 12 and build stars-gaia-g12215```216217Steps it runs: `fetch_sources.py all`; `fetch_gaia.py hipparcos | hipxm | gcns | tier … | teff …`;218`build_stars.py`; `build_objects.py`; `finalize.py`; `swift run -c release cosmos-bench catalog.build-octrees`;219`finalize.py`. Python standard library only. Raw responses are cached under `DataPipeline/raw/catalogs/<source>/`220with a `.meta.json` (URL or query, UTC date, SHA-256); a re-run reuses them, so an interrupted fetch resumes.221Every adapter checks the columns it needs and row counts where they are fixed (117 955, 331 312, 43 533, 4 076,22288) and stops on a difference. Output is deterministic for given raw files. `COSMOS_PACKS_DIR` redirects the223output and the tests. Nothing is deployed and no remote machine is assumed.224225## 9. Validation (tests: `Packages/CosmosCatalog/Tests`, 40 tests)226227- Normalisation: 289 cases shared with the pipeline; equivalence classes; edit distance.228- Records: JSON round trip of all ten record types; pipeline-encoded `Measured` values; missing values stay nil.229- Star file: fixture written by the pipeline writer decoded field by field; Swift writer byte-identical; 16230 corruptions/truncations rejected; selections = brute force (4 000 random stars); streaming, early stop on231 cancellation, bounded cache.232- SQLite: binding, NULL ≠ 0, read-only immutable (no side files), damaged database detected, hostile query text.233- Search ranking, cross-identification (one object, two star records), federation without duplicates, cone234 search = brute force (3 000 objects incl. poles and RA wrap), manifest/size/schema mismatches rejected.235- Derived: distance rule, absolute magnitude and luminosity with uncertainties, position at an epoch, unit236 conversions, HR filters; Milky Way determinism, statistics and geometry.237- Installed packs (fail with an instruction when absent, never skip): integrity and schema of every pack; Sirius,238 Vega, Proxima Centauri, Barnard's Star, 51 Peg b, TRAPPIST-1 e, M 31 compared with rows saved from the archive239 responses (`Tests/Fixtures/archive_reference.json`: query/URL and retrieval date per row); M 33 and LMC distances;240 Abell 1656; ISS; Ceres/Halley identifiers; distance policy over all 942 058 records; HR diagram of the 25 pc241 sample.242243Run: `swift test --scratch-path .build-cat --filter 'CosmosCatalogTests|CosmosSpatialTests'`.244245## 10. Known limits and data caveats246247- **Gaia G ≤ 12 tier not built.** Raw bins were fetched up to G = 11.31 (about 1.4 h would have been needed248 for the rest at the archive's pace) and the download was stopped; the bins are cached, so249 `build_all.sh --g12` resumes at G = 11.31 and then builds `stars-gaia-g12`. Teff was fetched for G ≤ 10 only.250- Gaia is incomplete brighter than G ≈ 3 and unreliable brighter than G ≈ 6: bright stars come from Hipparcos.251 Vega, Sirius and other very bright stars have no Gaia counterpart.252- Hipparcos V magnitudes are missing for a few entries (Hp is then used for ordering).253- Spectral types exist only for Hipparcos stars; no variability, multiplicity or component data.254- Nearby Gaia-only stars are named only when the HYG positional match is unique (766 of them).255- No uncertainties in OpenNGC; mixed magnitude systems there. Abell positions are coarse (1′).256- `pscomppars` rows mix references per parameter. Host parameters are those of the archive, not of Gaia.257- Satellites: a dated snapshot (2026-11-24); SGP4 is not in this module. Minor bodies: osculating elements only.258- Constellation membership of a position (Roman 1987) is not implemented; boundaries are polylines per shared259 edge, not closed polygons.260- Search: the FTS index covers names (role 1), not numeric designations; fuzzy matching needs ≥ 4 characters and261 can return distant look-alikes after the exact hits ("Sirius" → also "332 Siri"). One SQLite connection per262 pack, serialised by a lock: concurrent searches queue.263- `ObjectID` is encoded by its synthesised `Codable` as `{"raw": "…"}`; records store it that way.264- Records are JSON text in SQLite (exoplanets pack: 44.7 MB): simple and inspectable, not compact.265