Import rules#

Keep the dependency direction between the Toolkit, the packs and the reference parts. ci/import_rules.py checks it and fails the root migration_contract job when it breaks.

python3 ci/import_rules.py

The rules#

Tier

May import

contracts

Nothing else in the Toolkit

core

contracts

knowledge, tools

core, contracts; never each other

skills

contracts

pack:<name>

Any Toolkit folder and the packs it requires

Reference parts (refapp, reforch)

contracts and core’s router extension; never each other

  • The Toolkit has no import statement for a pack or a reference part. Core loads parts by module name from the parts list, and MCP tool families from the MCP server’s family list; parts reach core through the part registry (Write a pack) and the contracts.

  • A pack’s required packs are its geonemo-pack-* dependencies in packs/<name>/pyproject.toml.

  • Core’s router extension is the short list of core modules a reference part may import, under [router_extension] in ci/boundaries/tiers.toml.

  • A folder’s scripts/ and tests/ follow the folder’s rules for packs/ and reference/ imports, including modules imported by name and paths in strings. They may import any required Toolkit folder.

  • A missing optional part is skipped, so deleting packs/ and reference/ leaves a Toolkit that checks, builds and passes its own tests.

Where the rules are#

File

Holds

ci/boundaries/tiers.toml

A tier for every module, by longest matching path, and the [[scan]] list of packages

ci/boundaries/allowlist.txt

Imports that break the rules today. It may only shrink

ci/import_rules.py

The check

When the check fails#

Failure

Fix

A module matches no rule

Add a [[rule]] for its path to tiers.toml. A new module in an existing subpackage inherits the subpackage’s tier

A new import breaks a rule

Change the import: go through contracts/ or the part registry. A test that needs an optional part belongs in that part’s folder. Do not add to the allowlist

An allowlist entry no longer occurs

Run python3 ci/import_rules.py --write-allowlist

The check reads only Python imports. It is standard-library only, so it runs before the environments are installed.