|
1 | 1 | # Source Tree |
2 | 2 |
|
3 | | -- `src/input/` owns typed atmosphere, geometry, surface, spectroscopy, instrument, and reference-data input structures. |
4 | | -- `src/forward_model/` owns optical-property preparation, radiative transfer, instrument-grid calculation, and implementation bindings. |
| 3 | +- `src/input/` owns typed atmosphere, geometry, surface, spectroscopy, instrument, and reference-data input structures, plus JSON, defaults, and validation. |
| 4 | +- `src/setup/` builds the named physics tables consumed by the hot path: atmosphere layers, line, CIA, aerosol, instrument, solar, phase, and O2 run tables. |
| 5 | +- `src/optics/` owns per-sample optical properties: layer depths, Rayleigh, CIA absorption, curved sun path, and source levels. |
| 6 | +- `src/rtm/` owns radiative transfer: controls, gauss angles, attenuation, phase basis, scattering orders, layer reflect/transmit, reflectance, and the `solve` entry point. |
| 7 | +- `src/spectrum/` owns spectral assembly: sampling table, line physics, solar lookup, radiance wavelengths/results, instrument averaging, and the `spectrum_run` driver. |
| 8 | +- `src/retrieval/` owns optimal-estimation algebra and its root entry point. |
5 | 9 | - `src/output/` owns diagnostic reports and spectrum serialization. |
6 | | -- `src/common/` is shared support code only. |
7 | | -- `src/validation/` owns validation-only CLIs that consume the typed O2 A baseline. |
8 | | -- `src/forward_model/instrumentation/` owns narrow no-op-by-default facades for trace, telemetry, and sensitivity hooks. Retained sinks, capture scripts, and reports live under `scaffolding/`. |
| 10 | +- `src/cache/` owns retained, named memory owners (session, profile-line, radiance, solar-irradiance, spectrum, transport-worker, worker-pool). These are the borrowed write targets the hot path threads through. |
| 11 | +- `src/common/` is shared support code only: errors, hashing, math, units, memory, worker partition. |
| 12 | +- `src/assets/` owns embedded asset readers. |
| 13 | +- `src/validation/` owns validation-only code that consumes the typed O2 A baseline. |
| 14 | +- `src/instrumentation/` owns narrow no-op-by-default facades for trace, telemetry, and sensitivity hooks. Retained sinks, capture scripts, and reports live under `scaffolding/`. |
9 | 15 |
|
10 | 16 | ## Rules |
11 | 17 |
|
12 | 18 | - Inline `test` blocks under `src/` are not allowed. Add tests under `tests/unit/`, mirroring the source path. |
13 | 19 | - Tests that need non-public symbols should use `src/internal.zig`; keep that access surface named after the current tree. |
14 | | -- Prefer the public flow input -> RTM -> output. Do not move product wiring into `src/common/`. |
| 20 | +- Prefer the public flow input -> setup -> optics -> rtm -> spectrum -> output. Do not move product wiring into `src/common/`. |
15 | 21 | - Comments explain why, not what. Keep comments near non-obvious DISAMAR semantics, unit conversions, sign conventions, ordering, and intentional divergences. |
16 | | -- File I/O and text parsing belong in input, output, validation, scaffolding, CLI, or scripts, not in RTM routines. |
| 22 | +- File I/O and text parsing belong in input, output, validation, scaffolding, CLI, or scripts, not in optics, rtm, spectrum, or retrieval routines. |
17 | 23 | - Every new input/config field must be consumed, rejected with a typed error, or explicitly documented as inert with focused test coverage. |
| 24 | + |
| 25 | +## Explicit dataflow (hot folders) |
| 26 | + |
| 27 | +Functions in the hot folders `src/optics`, `src/rtm`, `src/spectrum`, and |
| 28 | +`src/retrieval` must name what they read and write. Pass explicit scalars, |
| 29 | +slices, and named physics tables; borrow read-only data as `*const`; confine |
| 30 | +writes to a single named data owner. This keeps each function's dependencies |
| 31 | +visible in its signature instead of hidden inside a broad mutable object, which |
| 32 | +is what makes the hot path readable and property-testable. |
| 33 | + |
| 34 | +This is enforced by `scripts/linting/check-explicit-dataflow-signatures.py`, |
| 35 | +which scans signatures and type declarations in those folders. |
| 36 | + |
| 37 | +- Banned in signatures and as type names: `Scene`, `PreparedOpticalState`, |
| 38 | + `ProductStorage`, `Context`, `Workspace`, `Request`, `Cache`, `ComputeCache`, |
| 39 | + `Storage`, and any identifier ending in `Request` or `Workspace`. A |
| 40 | + god-object parameter hides what the function actually touches. |
| 41 | +- Allowed named data owners (the only broad-ish types permitted in hot-folder |
| 42 | + signatures): `SolarIrradianceMemory`, `ProfileLineValues`, |
| 43 | + `TransportWorkArrays`, `SpectrumSamplingTable`, `RadianceWavelengthList`. |
| 44 | +- The allowed list is the real governance lever. Keep these owners narrow; do |
| 45 | + not let one grow into a catch-all. Adding a name to the list (in the linter) |
| 46 | + is a deliberate decision, not a convenience. |
| 47 | +- Document each hot-path function's reads and writes in a `dataflow` section of |
| 48 | + its function map (see `STYLEGUIDE.md`). |
0 commit comments