Skip to content

refactor(domain)!: dissolve the domain bucket and put a measured tier ladder behind it - #188

Merged
LKSNDRTMLKV merged 27 commits into
mainfrom
refactor/dpp-domain-layout
Aug 26, 2026
Merged

refactor(domain)!: dissolve the domain bucket and put a measured tier ladder behind it#188
LKSNDRTMLKV merged 27 commits into
mainfrom
refactor/dpp-domain-layout

Conversation

@LKSNDRTMLKV

Copy link
Copy Markdown
Member

Dissolves the domain module, gives every top-level module a measured tier, and puts tripwires behind the rules that keep it that way.

domain/ held 52% of the crate — 138 of 222 files — behind a name that says nothing, so nothing in it had been chosen to be there. It is gone. src/ now reads as the domain's own vocabulary, the way tokio/src is fs io net sync task time.

The scope law

docs/architecture/CODE-LAYOUT.md §1 gains an eight-tier ladder: imports may only point up it, and two tripwires hold the code to that — one for direction, one for cycles.

Eight, not four, because eight is what the graph has. Four put sixteen of twenty-three modules in a single tier, which is a tier doing no work. Levelling the import graph by longest path yields seven strata; the eight tiers verify against all 40 production edges with zero upward imports and an empty baseline.

The ladder is a dependency ordering, not a taxonomy of behaviour. That distinction was earned: schemas had been filed under "policy" because it decides whether data conforms, when it imports exactly one module and sits second from the bottom.

What moved

domain/ dissolved — 13 root files and 12 directories rehoused
enums/ dissolved — it documented itself as cross-product-group and one of its nine types was. Four went to battery/, two to electronics/, one to common/, two to carbon_footprint/
instrument/ lifted out of catalog/, which is now nine files and genuinely carries no law
identifier/ the GS1 and CN vocabulary gathered into one leaf whose only dependencies are serde and thiserror — see #187
field_error/ split from error/, which resolved a real import cycle
facility/ manufacturer/ material/ out of passport/, which never contained them in any real sense
every port now a directory matching archive/, and ports/mod.rs is a pure inventory

Behaviour changes

Passport::validate() is wasm-clean. The schema pass needed the versioned registry — jsonschema, and through it a blocking HTTP client — so an aggregate could not state its own invariants without a network stack in its dependency tree. That block moved to validation::validate_passport, which runs both halves. The #[cfg(not(target_arch = "wasm32"))] inside validate is gone; the method now means one thing on every target. A companion test fails if the dependency creeps back.

validation::rules is available on wasm32 for the first time. The module carried a blanket gate because one submodule needs jsonschema; the dpp-rules adapters are pure and were being withheld for no reason of their own.

ports/ no longer re-exports model types. ports::seal and ports::compliance carried shims whose own doc said "re-exported here so existing paths keep resolving" — a second path to the same type, which is what let a composition tier import the boundary tier in the first place.

Conservation

Verified against main before publishing, per the pre-publish audit:

  • Public items 727 → 729, nothing lost. Both additions deliberate (validate_passport, ProductGroupPayload).
  • Wire surface byte-identical — 30 schemas, 12 instrument manifests, 12 product-group manifests, zero diff.
  • Tests conserved, and the audit earned its keep: it found ten tests that had silently stopped running because two moved files were never declared with mod …;. An undeclared .rs is not compiled, so it does not fail — it vanishes, and the suite still reports green. The count would have missed it (1149 on both refs, because six new tripwires replaced them one-for-one); only the sorted leaf-name diff exposed it.
  • Three doc blocks had been truncated mid-sentence by range-based extraction, including the Art. 7(2) reasoning for why CarbonFootprintClass is deliberately not an enumeration. Restored.

Gates added

Rules 0 and 11–15, each proven red before being allowed green, plus rule 7 widened to catch test modules named for their subject rather than tests — it was missing five.

Two of the new gates were wrong on first run and the red output is what showed it: rule 11 flagged every foo_tests.rs sibling, punishing compliance with rules 4 and 7; rule 15 counted textual mentions rather than distinct siblings, so one importer looked like two.

Breaking

Module paths move, so the platform repository's imports break. That is accepted rather than hidden: compatibility re-exports would leave two ways to reach every type, which is the condition this change exists to end. Zero external users, so the break is paid once. The consumer update is a separate, coordinated change and is not in this PR.

just check green — 1171 tests.

@codacy-production

Copy link
Copy Markdown

Up to standards ✅

🟢 Issues 0 issues

Results:
0 new issues

View in Codacy

NEW Get contextual insights on your PRs based on Codacy's metrics, along with PR and Jira context, without leaving GitHub. Enable AI reviewer
TIP This summary will be updated as you push new changes.

@LKSNDRTMLKV
LKSNDRTMLKV merged commit e5de9e0 into main Aug 26, 2026
18 checks passed
@LKSNDRTMLKV
LKSNDRTMLKV deleted the refactor/dpp-domain-layout branch August 26, 2026 03:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant