diff --git a/Fensalir.sln b/Fensalir.sln index 1327133..1c196ee 100644 --- a/Fensalir.sln +++ b/Fensalir.sln @@ -29,6 +29,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aquarium.Fractal.Receipt", EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Aquarium.Fensalir", "src\Aquarium.Fensalir\Aquarium.Fensalir.csproj", "{F9274D99-3CC6-42B6-9817-EC7F19663B1D}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Saga", "src\Saga\Saga.csproj", "{30324495-56BE-4D45-80E8-CE03C24726C8}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -159,6 +161,18 @@ Global {F9274D99-3CC6-42B6-9817-EC7F19663B1D}.Release|x64.Build.0 = Release|Any CPU {F9274D99-3CC6-42B6-9817-EC7F19663B1D}.Release|x86.ActiveCfg = Release|Any CPU {F9274D99-3CC6-42B6-9817-EC7F19663B1D}.Release|x86.Build.0 = Release|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Debug|Any CPU.Build.0 = Debug|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Debug|x64.ActiveCfg = Debug|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Debug|x64.Build.0 = Debug|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Debug|x86.ActiveCfg = Debug|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Debug|x86.Build.0 = Debug|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Release|Any CPU.ActiveCfg = Release|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Release|Any CPU.Build.0 = Release|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Release|x64.ActiveCfg = Release|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Release|x64.Build.0 = Release|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Release|x86.ActiveCfg = Release|Any CPU + {30324495-56BE-4D45-80E8-CE03C24726C8}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -173,5 +187,6 @@ Global {A9D41C48-7E78-4D75-A814-0C1500245EFC} = {0AB3BF05-4346-4AA6-1389-037BE0695223} {C0D1BFAC-B1B4-4350-92A7-D537AE382909} = {07C2787E-EAC7-C090-1BA3-A61EC2A24D84} {F9274D99-3CC6-42B6-9817-EC7F19663B1D} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B} + {30324495-56BE-4D45-80E8-CE03C24726C8} = {827E0CD3-B72D-47B6-A68D-7590B98EB39B} EndGlobalSection EndGlobal diff --git a/README.md b/README.md index 1104021..15eaf15 100644 --- a/README.md +++ b/README.md @@ -136,6 +136,9 @@ how WASAPI or Faust got invited to the party. audio/synth host, bundled assets, and renderer-owned shaders. - `src/Aquarium.Engine.Fractal`: `.aquageo`, IFS/fractal fields, temporal reservoirs, evidence tracks, contribution cache, and lowering machinery. +- `src/Saga`: stochastic planetary flow middleware for cube-sphere Transport + fields, arbitrary forcing, Coriolis-aware advection, and learned atmosphere / + ocean / debris flow packets. - `src/Aquarium.Fensalir`: Fensalir splash/art reconstruction demo. - `src/Aquarium.Sample.Minimal`: tiny client proving the runtime boundary. - `src/Aquarium.Zyphos`: planetary/fractal terrain demo. diff --git a/docs/README.md b/docs/README.md index 0434328..8c6243d 100644 --- a/docs/README.md +++ b/docs/README.md @@ -13,6 +13,8 @@ historical branch scar. ## Fields, Reservoirs, And Fractals +- `../src/Saga/README.md`: studio-facing Saga middleware pitch and subproject + overview for stochastic planetary flow. - `papers/fensalir-pipeline.tex`: living MiKTeX paper for the Fensalir pipeline, research spine, domain reservoir model, and evaluation plan. - `papers/fensalir-native-domain-reservoirs.tex`: focused SIGGRAPH-shaped diff --git a/src/Saga/README.md b/src/Saga/README.md new file mode 100644 index 0000000..c10367e --- /dev/null +++ b/src/Saga/README.md @@ -0,0 +1,165 @@ +# Saga + +**Planetary flow middleware for worlds that refuse to sit still.** + +Saga is Fensalir's stochastic planetary flow organ: a cube-sphere native system +for streaming atmosphere, ocean, gas, debris, heat, and other transport fields +across whole planets at arbitrary level of detail. + +It is built for studios that want living planets without hand-authoring a fake +weather loop, baking one heroic texture atlas, or stapling a particle system to +a skybox and calling it climate. Saga turns terrain, bathymetry, atmospheric +state, ocean reanalysis, arbitrary forcing sources, and learned stochastic +transport into compact flow packets the engine can stream, inspect, simulate, +and render. + +No poles. No flat-Earth texture tricks. No private renderer arrows pretending +to be physics. Just a planet-scale flow field with provenance, uncertainty, and +enough teeth to survive a camera dive from orbit to coastline. + +## The Pitch + +Modern games and simulation tools can render planets. They rarely make them +move like planets. + +Saga is the missing middleware layer between static world geometry and dynamic +planetary behavior: + +```text +planet domain + relief + state + forcing + learned transport +-> stochastic advection packets +-> streaming flow pages, particles, weather, debris, clouds, currents, debug +``` + +Use it for: + +- ocean surface currents and debris drift; +- atmospheric wind fields and gas-giant bands; +- volcanic, nuclear, magical, artificial, or stellar energy injection; +- multi-sun lighting and thermal forcing; +- tides, rotation, Coriolis-dominated flow, and exotic planetary regimes; +- gameplay-visible particles, clouds, smoke, spores, ash, foam, or pollutants; +- offline worldbuilding, cinematic previs, and realtime renderer guidance. + +Saga is not a weather forecast API wearing a costume. It is a reusable engine +organ for representing and streaming stochastic flow over Fensalir's planetary +domains. + +## What Makes It Different + +### Cube-Sphere Native + +Saga speaks Fensalir's optimized cube-sphere address space directly. Lat/lon +grids are source formats, not runtime truth. Every packet belongs to a tile, +LOD, projection, local tangent frame, and provenance chain. + +### Stochastic By Design + +Real flow is not one obedient arrow. Saga packets carry mean transport, +diffusivity/covariance, confidence, and optional transition kernels. Renderers +can draw clean vectors; simulations can keep the uncertainty instead of +throwing it into the sea and acting surprised later. + +### Arbitrary Forcing + +The evaluator is not Earth-locked. Saga conditions on explicit rotation and +Coriolis features plus variable-cardinality energy, mass, and momentum forcing +sources: + +- one sun, binary suns, or no sun worth trusting; +- moons and tidal drivers; +- eruptions, impacts, reactors, orbital mirrors, industrial heat, spellstorms; +- gas-giant internal heat and extreme atmosphere bands; +- transient shock events and persistent planetary gradients. + +Source count is data, not architecture. + +### Built For Streaming + +Saga is designed for camera-relative planet rendering: + +- coarse flow far from the camera; +- refined flow where the player, shot, simulation, or uncertainty demands it; +- parent/child LOD consistency; +- cross-face seam continuity; +- explicit stale-page and model-version checks. + +The renderer samples packets. It does not invent climate in a pixel shader +because the schedule got nervous. + +## Architecture + +Saga lives inside Fensalir because Fensalir already owns the machinery it needs: + +- `CubeTileKey` and cube-sphere projection math; +- field evidence layers, especially `Transport`; +- selected cuts and residency planning; +- GPU resource pages and debug telemetry; +- renderer/simulation lowering boundaries. + +Saga's live shape: + +```text +source manifests + -> cube-sphere dataset bakes + -> training shards + -> FlowNet-S / FlowNet-M / optional FlowNet-T + -> Saga stochastic advection packets + -> Fensalir Transport field claims + -> GPU pages, particle advection, weather visuals, debug probes +``` + +## Model Line + +Saga uses a staged neural architecture plan: + +- `FlowNet-S`: 8-15M parameters, local baseline for ingestion, calibration, and + export. +- `FlowNet-M`: 40-60M parameters, first serious runtime/distillation model with + local tile encoders, a cube-sphere graph processor, and stochastic heads. +- `FlowNet-T`: 150-300M parameters, optional global teacher for offline + distillation and ensemble behavior. + +The model emits stochastic advection parameters, not just velocity: + +- tangent mean velocity; +- positive-semidefinite 2x2 covariance/diffusivity; +- calibrated confidence; +- optional neighbor transition logits; +- provenance and model identity. + +## Data Spine + +Saga's first research targets: + +- ETOPO / GEBCO for relief and bathymetry; +- ERA5 for atmosphere; +- GLORYS / OSCAR / HYCOM candidates for ocean currents; +- PlasticAdrift and drifter transition matrices for stochastic debris + transport validation; +- synthetic analytic worlds for contract and seam tests before the ocean gets + expensive. + +Every source needs a manifest. No manifest, no training shard. The altar wants +receipts. + +## First Vertical Slice + +1. Define the Saga packet contracts. +2. Bake a synthetic cube-sphere flow world. +3. Export Transport field pages. +4. Render/debug vectors, covariance ellipses, confidence, and selected LOD. +5. Train FlowNet-S on synthetic + tiny ERA5 wind. +6. Add ocean surface current targets. +7. Add PlasticAdrift transition validation. +8. Promote FlowNet-M when the baseline has failed in useful, measured ways. + +## Boundary + +Saga owns reusable planetary flow mechanics. Clients own meaning. + +Fensalir clients may ask for currents, winds, debris drift, cloud motion, ash +transport, or gas-giant bands. They may not create a private flow authority that +bypasses Saga packets and Fensalir Transport claims. + +That is the deal: the planet can be wild, but the authority has to be clean. diff --git a/src/Saga/Saga.csproj b/src/Saga/Saga.csproj new file mode 100644 index 0000000..26dee97 --- /dev/null +++ b/src/Saga/Saga.csproj @@ -0,0 +1,14 @@ + + + + + + + + + net10.0 + enable + enable + + + diff --git a/src/Saga/SagaOrgan.cs b/src/Saga/SagaOrgan.cs new file mode 100644 index 0000000..89de3ea --- /dev/null +++ b/src/Saga/SagaOrgan.cs @@ -0,0 +1,65 @@ +using Aquarium.Engine.Fractal; +using System.Numerics; + +namespace Saga; + +public static class SagaOrgan +{ + public const string Name = "Saga"; + + public const string Description = + "Cube-sphere stochastic planetary flow for Fensalir Transport fields."; +} + +public readonly record struct SagaFlowDomain( + string DomainId, + double PlanetRadiusMeters, + string ProjectionId, + string GridVersion); + +public readonly record struct SagaFlowRequest( + SagaFlowDomain Domain, + CubeTileKey Tile, + int SampleResolution, + double TimeSeconds, + SagaCoriolisFrame Coriolis, + IReadOnlyList ForcingSources); + +public readonly record struct SagaCoriolisFrame( + Vector3 RotationAxis, + double AngularVelocityRadiansPerSecond, + double LocalF, + Vector2 LocalBeta); + +public readonly record struct SagaForcingSource( + string SourceId, + SagaForcingKind Kind, + SagaForcingGeometry Geometry, + Vector3 PlanetDirection, + Vector3 LocalTangentDirection, + double Intensity, + double RadiusMeters, + double Attenuation, + double TimePhase); + +public readonly record struct SagaAdvectionSample( + Vector2 MeanVelocity, + SagaCovariance2D Diffusivity, + double Confidence); + +public readonly record struct SagaCovariance2D(double C00, double C01, double C11); + +public enum SagaForcingKind +{ + Energy, + Mass, + Momentum, +} + +public enum SagaForcingGeometry +{ + Directional, + Point, + Area, + Volume, +} diff --git a/state/map.yaml b/state/map.yaml index 892f471..cd5ace9 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -21,6 +21,12 @@ current_model: implementation: src/Aquarium.Engine.Fractal tests: tests/Aquarium.Engine.Fractal.Tests receipt_tool: tools/Aquarium.Fractal.Receipt + saga: + implementation: src/Saga + purpose: > + Stochastic planetary flow middleware for cube-sphere Transport fields, + arbitrary forcing, explicit Coriolis/rotation conditioning, and learned + atmosphere/ocean/debris advection packets. demos: fensalir_splash: src/Aquarium.Fensalir minimal: src/Aquarium.Sample.Minimal