Architecture gates#

Built from the module docstrings of tests/unit/architecture/test_*.py and the YAML contracts beside them each time the site is built. Fix a wrong row there.

10 gate modules and 7 YAML contracts. Run them all with pytest tests/unit/architecture -q. The rule is the first paragraph of the module docstring; the checks are its test functions.

Gates#

Module

Rule

Contract

Checks

test_code_rules.py

The code rules of the repository that a reader can check on the syntax alone.

-

  • Rule 8 no init hands over a name it imports

  • Rule 9 every contract is a port or has two implementations

  • Rule 9 the tables list only contracts that exist

  • Rule 10 type checking blocks stay under the ceiling

  • Rule 12 no module but the root defines getattr

  • Rule 13 no module is named with a word of the rule

  • Rule 16 no package reads a private name of another

  • Rule 8 check sees each kind of import

  • Rule 9 check sees each kind of contract

  • Rule 10 check counts the blocks

  • Rule 12 check reads only the module level

  • Rule 13 check reads the whole path

  • Rule 16 check sees each kind of private read

test_layers.py

Who reads whom: the layer matrix, the ports that stand alone, the string paths.

dotted_paths.yaml, layer_matrix.yaml

  • Layer matrix

  • A transitional entry is still needed

  • The matrix judges a bad edge

  • Layer matrix declares every top level package

  • Layer tolerances are declared and needed

  • A row cites only rows above it

  • Architecture package pages match the rows

  • The layer contract is sound

  • Committed layer matrix page matches the contract

  • Siblings one way

  • Every sibling has a row

  • A sibling reads only its row

  • Entry points only target annex

  • A geographic name imports without a cycle

  • A port imports only what it promises

  • A port flags a bad import

  • A terrain exception is still taken and deferred

  • The builtin sources are all in the registry

  • A source lookup and the port load no provider library

  • The tree obeys

  • A rule flags its bad example

  • The registry engine still scans and the tables exist

  • The index is opened through the retry helper

  • Every duckdb write owner still writes

  • The catalog family names none of the retired tables

  • A solver package reads only the private names it declares

  • The private name rule sees a dotted read and a getattr

  • Watch reads the outcomes and never the index

  • The doctor counts read the sessions and never the index

  • Every dotted path resolves

  • The dotted path scan reads every location

  • A known stale entry is still stale

  • An allowed name is still used

  • Entry points use declared groups

  • The resolver tells a real path from a dead one

test_package_layouts.py

Enforce the import rules inside the packages that carry a <package>_layout.yaml.

calibration_layout.yaml, layer_matrix.yaml

  • Every package with a layout is seen

  • The scanner sees the package

  • Every part has a row

  • A row names only rows above it

  • A part imports only what its row allows

  • Another layer imports only the public modules

  • The public patterns name existing modules

  • The text path files exist

  • No module sits at the root of data

  • A variable never imports another variable

  • A family module is one the registry names

  • The data source registry names only its builtin sources

  • The calibration evaluator registry names only its builtin evaluators

  • Config reads the upper parts only inside its validators

  • Evaluation reads optim only for types

  • Preflight reads the other parts only inside its checks

  • Calibration reaches solver only through generic ports

  • The display text paths are the frames and the specials

  • A backend never imports another backend

  • The solver registry names only its builtin backends

  • The mesh registry names only its builtin engines

test_public_import_paths.py

Which import paths are public, and which port is stable.

-

  • The list is read

  • A listed module exists and is not private

  • The pages teach an import

  • A page imports only what the list or the facade answers for

  • A name imported from the package is in the facade

  • The page states the stability of every port

  • A port named on the page lives in a listed module

test_run_path.py

What the path of a run reads and writes.

environment_reads.yaml, process_state.yaml, solver_layout.yaml

  • No file outside the home imports or names the backend

  • The global backend is declared by its two registry lines alone

  • A fallback inside a function of a declaration file is flagged

  • The four reading zones name no backend

  • The model gate sees every spelling of a read

  • The model gate sees every import of the flow

  • The model gate sees every write on the model

  • Every allowed registry reader still reads a registry

  • A run context carries what its run produced

  • A run context refuses anything but the view

  • The view carries no catalog handle

  • The gate sees every spelling of a registry read

  • The gate sees every spelling of a hand built context

  • The gate sees every spelling of a state read

  • The gate sees an aliased import of the view

  • The workflow scan reads the package that declares the context

  • No module reads a workflow context reflexively

  • Every workflow context member has a reader

  • The steps package holds the thirteen known steps

  • A step declares the payload keys it touches

  • Every step but the first reads the one key that remains

  • The payload gate sees every spelling of a read

  • The payload gate sees every spelling of a write

  • The payload gate counts no read that is not a payload read

  • The payload gate follows a helper and a helper of a helper

  • The payload gate finds a step that declares nothing

  • The basin is computed and called from one place each

  • The basin gate skips the soil budget basin

  • Enough builder call sites are scanned

  • The journal detector reads every form of import

  • The journal scan reads the modules it bans and the session still imports it

  • The one injection site and its caller exist

  • Retired provider files do not exist

  • The say rule reads enough modules and sees a validator

  • Each windows detector flags what it must

  • The windows scan reads the package and each allowed file exists

  • The run path does not load the slurm launcher

  • A project root past the windows budget is refused

  • The tree obeys

  • A rule flags its bad example

  • The gate sees every spelling of a trial key

  • The gate sees every spelling of the gone dictionary

  • The model exemption table is empty

  • Every process state site has its row and every row its site

  • The process state rows are classed and never switch a render

  • The warning filters and handlers are set in their one place

  • The process state scan flags a planted site

  • Every environment site has its row and every row its site

  • The environment rows are classed and name no secret

  • The files that carry the bounds read no environment

  • The environment scan reads a planted site

  • The verbs and the project receive the environment by keyword

  • The network clients are the ones declared

test_science_module_imports.py

Rule 6: a science module imports numpy, the standard library and one neighbour of its folder.

-

  • Every module of a science folder keeps rule 6

  • The table of exceptions only shrinks

  • The gate sees each kind of import

  • The table lets through only what it lists

test_surfaces.py

What is public and held: surfaces, registers, tolerances, variables, exceptions.

dotted_paths.yaml

  • The frozen step names are the steps of the pipeline

  • A surface equals its snapshot

  • A removed toml key keeps its migration until its delay ends

  • A removed name keeps its entry until its delay ends

  • An entry that outlives its delay is named

  • The delay of the interface tables is the one of the register

  • An old form of hmp is not surface

  • A change is named by kind

  • An experimental key can leave and a stable one is counted

  • Regenerating refuses a stable key without a migration

  • Regenerating records a key that has its migration

  • Before the tag a name leaves with no entry

  • From the tag a name needs its entry to leave

  • A positional may leave with no entry

  • A stable key marked experimental still needs its migration to leave

  • From the tag a stable key cannot be marked experimental

  • A form the loader only refuses is no migration

  • Only a row that rewrites counts as a migration

  • A path finds the row or the line that covers it

  • The top level is the verbs the objects the categories and the version

  • The api holds the fifteen verbs and defines each

  • The kept readers are the ones the frozen runs call

  • Each object is the class of its home

  • Every parameter of a verb is serializable

  • Every verb returns what a server can send

  • Each type a verb returns writes json

  • A plan draft writes json

  • Each command imports the api and calls its verb

  • The api module reads in one place

  • The register reads and counts its rows

  • Each document has a reader

  • Each rule is a function of the reader of its document

  • Each function of a reader is named by a row

  • The sidecar reader reads its rows

  • No row is dated past the next minor version

  • Each default that moved since 2 0 0 has its row

  • Each field new since 2 0 0 keeps the numbers of 2 0 at its default

  • No bug touches the version of this tree

  • The numbers block of the changelog is the one the register writes

  • Classification partitions all loadable rows

  • Every tol call resolves to one real row

  • Referenced rows are subset of loadable keys

  • Every inline row is referenced by a tol call

  • Dupuit fixed head doc agrees with case toml

  • Documented tolerance count matches the table

  • Every variable the code names has a row

  • Every row names a variable the code reads

  • Every exclusion is still written somewhere

  • A row is complete and unique

  • A public exception derives from the root

  • Every whitebox group file still exists

  • No parallel step collects a whitebox test

  • What a parallel step ignores is run somewhere serially

  • Legacy regression vocabulary stays out of active surface

  • A scoped layer raises typed exceptions only

  • The typed rule flags its bad example

  • Every exemption is dated and still needed

  • Every scoped entry exists

test_the_run_path_is_short.py

A flow run plays fewer than forty files of hydromodpy/, listed one by one in run_path.toml.

-

  • The run path of the tree breaks no rule

  • Every file of a variant exists

  • A flow run plays fewer than forty files

  • The chained transport run is the mf6 run plus its transport group

  • A table that breaks a rule is refused with the file and the rule

test_the_stream_criterion_reads_once.py

The stream criterion reads each of its inputs once, for the trial and the figure alike.

-

  • An old copy is gone

  • An operation has one definition

  • A mesh kernel is called only by the criterion inputs

  • Priority flood is the one flood

  • The tables name modules that exist

test_two_runs_in_two_threads.py

Two runs in two threads of one process change nothing the other run reads (rule 15).

process_state.yaml

  • Two runs in two threads keep the process as it was

Import rules inside a package#

layer_matrix.yaml treats each package as one block. A package whose parts are ordered carries a <package>_layout.yaml, checked by test_package_layouts.py. Parts are listed lowest first: a part may import only parts listed above it.

Contract

Package

Parts

Other keys

calibration_layout.yaml hydromodpy/calibration

targets, criteria, parameter_resolution, optim, persistence, report, evaluation, config_terms, config_network, config_outputs, config_objective, config_phases, config, protocols, observations, metrics, runners, preflight_report, preflight_searches, preflight_network, preflight, <init>

public, solver_access, text_paths

catchment_layout.yaml hydromodpy/catchment

raster_support, surface, surface_sampling, administrative, delineation, terrain, algorithms, synthetic, preprocess, drainage, stream_network, <init>

public, text_paths

data_layout.yaml hydromodpy/data

contracts, schemas, provenance, source, common, ingest, families, variables, sites, loading, workspace, request, <init>

public, text_paths

display_layout.yaml hydromodpy/display

<init>, request, theme, static, quicklook, subject, interactive, variables, overlays, output, frames, special, presets, render, config, cohort, run_comparison, runs, catalog_figures, overview, report

public, text_paths

mesh_layout.yaml hydromodpy/mesh

<init>, planar, request, refinement_config, mesh_config, resample, cells, io, stored, port, registry, engines, planning

public, text_paths

solver_layout.yaml hydromodpy/solver

base, modflow_grid, modflow_common, boussinesq, linear_reservoir, modflow6, modflow_nwt, <init>

backends, families, public, text_paths