# 002 - Cosmos ## User Story As the operator and the designer, I want the orchestrator's sky, music and orbit scene as one reusable component behind a small live globe, so that the orchestrator and every Infinito.Nexus web app can show the same calm background without carrying its code twice. ## Decisions (operator-confirmed 2026-11-06; do not re-litigate) 1. **Scope**: everything of the orchestrator's background moves: the sky (sun, moon, stars, twilight stages, day and night palettes with contrast check), the generated meditative music and the orbit and 3D scene. The radio streams with their schedule stay in the orchestrator. Rejected: the sky only. 2. **Repository**: `github.com/kevinveenbirkenbach/cosmos`, not managed by pkgmgr, laid out as an Infinito.Nexus custom role `web-app-cst-cosmos` that core pulls from its inventory-declared source. Rejected: the infinito-nexus organisation, a pkgmgr-managed release. 3. **Form**: Web Components (`` for sky and music, `` for the 3D scene) that also set `--cosmos-*` CSS custom properties every design can follow; a "colors only" mode draws nothing. Rejected: a plain ES module. 4. **Globe menu**: a small globe logo turns with the Earth's real rotation and shows the current Earth with its live day and night line; a click on it reveals every control, nothing else is visible while it is closed. Rejected: a visibly spinning globe (not the real orientation). 5. **Licence**: MIT, like the skills repository it comes from. Rejected: the Infinito.Nexus Community License (non-commercial, limits reuse). 6. **Work split**: Skills extracts the code into cosmos and switches the orchestrator to a pinned cosmos version; the IAM agent builds the core integration: a role that the design service `web-svc-design` activates. Rejected: IAM doing everything. 7. **Timing**: implemented after requirement 001; the core part also needs core's custom roles (requirement 046) on core main. Rejected: starting now. 8. **Icons**: the controls use Bootstrap Icons per decision 19 of requirement 001. ## Approach ```mermaid flowchart TD subgraph P["๐Ÿงญ 0 ยท Preparation"] P1["๐Ÿ“‹ Write requirement"] --> P2{"โœ… Operator approves?"} P2 -- "โœ๏ธ corrections" --> P1 P2 -- "๐Ÿค– yes" --> P3{"๐Ÿ 001 done and 046 on core main?"} P3 -- "โณ not yet" --> P3 end P3 -- "๐ŸŸข yes" --> C1 subgraph C["๐ŸŒŒ 1 ยท Extract into cosmos (Skills)"] C1["๐Ÿ”ด Red tests: astronomy, palette contrast, globe, attributes"] --> C2["๐Ÿ› ๏ธ cosmos repo as custom role, Web Components, globe menu, demo page"] C2 --> C3{"๐Ÿงช Tests and core role lints green?"} C3 -- "๐Ÿ”ด no: fix" --> C2 C3 -- "๐ŸŸข yes" --> C4["๐Ÿ“ธ Screenshots: noon, dusk, night, menu open"] C4 --> CF{"๐Ÿ’ฌ Operator feedback?"} CF -- "โœ๏ธ changes" --> C2 end CF -- "๐Ÿ‘ commit word" --> O1 subgraph O["๐Ÿงญ 2 ยท Orchestrator on cosmos (Skills)"] O1["๐Ÿ” Pin cosmos, drop ambience.js, sky and generated music"] --> O2{"๐Ÿงช Orchestrator tests green?"} O2 -- "๐Ÿ”ด no: fix" --> O1 O2 -- "๐ŸŸข yes" --> OF{"๐Ÿ’ฌ Operator feedback?"} OF -- "โœ๏ธ changes" --> O1 end OF -- "๐Ÿ‘ commit word" --> I1 subgraph I["๐Ÿ›๏ธ 3 ยท Core integration (IAM)"] I1["๐Ÿ“‹ IAM writes the core requirement"] --> I2["๐Ÿ› ๏ธ Role activated by web-svc-design"] I2 --> I3{"๐Ÿงช Deploy and Playwright green?"} I3 -- "๐Ÿ”ด no: fix" --> I2 I3 -- "๐ŸŸข yes" --> IF{"๐Ÿ’ฌ Operator feedback?"} IF -- "โœ๏ธ changes" --> I2 end IF -- "๐Ÿ‘ fits" --> D1["๐Ÿ Commit with operator OK, push hand-over"] ``` ## Acceptance Criteria ### Repository - [ ] `github.com/kevinveenbirkenbach/cosmos` holds an MIT `LICENSE`. - [ ] `pkgmgr list` does not list cosmos. - [ ] The repository is a role named `web-app-cst-cosmos`: `README.md`, `meta/` (main, info, services, license), `tasks/main.yml`, and the components under `files/`. - [ ] An inventory group `web-app-cst-cosmos` with `custom: true` and a pinned source makes core's `make roles-pull` place it. - [ ] Every core role lint passes on the placed role. ### Components - [ ] `` takes `latitude`, `longitude`, `mode` (`full` or `colors`) and `music` with a volume, and follows `prefers-reduced-motion`. - [ ] It sets `--cosmos-sky-top`, `--cosmos-sky-bottom`, `--cosmos-stage` and `--cosmos-text` and updates them at least once a minute. - [ ] Text against sky keeps a contrast of at least 4.5:1 at every minute of a day at 0ยฐ N 0ยฐ W and at 52.5ยฐ N 13.4ยฐ E (unit test). - [ ] Sun and moon positions match published reference values within 1ยฐ for at least six fixed dates (unit test). - [ ] `` renders the 3D scene on vendored `3d-force-graph` 1.80.1 and `three` 0.186.1 and takes nodes and links as data. - [ ] The generated meditative music plays with a volume; no radio stream code is in the repository. ### Globe menu - [ ] A globe of at most 48 px shows a public-domain Earth texture with the live day and night line, turned to the Earth's current rotation. - [ ] A click, Enter or Space opens the control panel and Esc closes it. - [ ] While the panel is closed only the globe is visible. - [ ] Every control is a Bootstrap Icon with `title` and `aria-label`. ### Orchestrator - [ ] The orchestrator vendors a pinned cosmos tag and loads it under its nonce CSP. - [ ] `ambience.js`, the sky code and the generated music are gone from the orchestrator; its radio-stream schedule stays. - [ ] The orchestrator's 3D views render through ``. ### Core (IAM) - [ ] IAM writes the core requirement for the integration. - [ ] With `web-svc-design` activating cosmos, a designed web app shows the cosmos background behind its content with the globe. - [ ] With it off, the app loads no cosmos file. ### Tests - **Unit** - [ ] Astronomy against reference values. - [ ] Palette contrast over a day. - [ ] Attribute parsing. - [ ] Globe orientation at fixed times. - **Integration** - [ ] Core's `make roles-pull` places cosmos and its role lints pass. - [ ] The orchestrator serves the pinned cosmos under its CSP. - **E2E** - [ ] Headless Chromium and Firefox open the cosmos demo page and the orchestrator at noon, dusk and night with the menu closed and open, and save the screenshots. - [ ] One designed core app is opened with cosmos on and off.