Skip to content

dr_check: the rules as data, one rule set for each standard - #359

Merged
IPedrax merged 2 commits into
IPedrax:mainfrom
ffishman:dr-check-data
Nov 11, 2026
Merged

IPedrax merged 2 commits into
IPedrax:mainfrom
ffishman:dr-check-data

Conversation

@ffishman

@ffishman ffishman commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

The same move #290 made for load_points, now for dr_check, following the shape decided in #260: the cases live in a data file, every rule names its source, and a test fails on one that doesn't.

What changes

  • crates/core/data/dr-check.json: one rule set per standard. NBR 5410:2004 item 5.1.3.2.2 is the only set for now, with the same behaviour dr_check had in code. Each case is one rule: the places it reaches (empty = any), the kinds of point (empty = any), the building (residential, other or any), whether it needs the "may feed equipment outdoors" flag, and the height from which a light is left out. The set also holds the 30 mA limit, the 32 A ceiling for outlets (note 1), the IT continuity exemption (note 2) and what the check does not cover. Every rule gives the item it comes from; the file holds numbers and item references only, no text of the standard.
  • dr.rs: the check is now RuleSet::check, which only reads those rules; the first rule a point meets gives its reason, as before. dr::check stays and uses the default set, so the existing tests pass unchanged. MAX_RESIDUAL, MAX_OUTLET and LIGHT_HEIGHT go, since the numbers are in the data now.
  • dr_check takes standard (default NBR 5410:2004, an unknown one is an error) and the answer adds standard, standard_source, max_outlet_a and, for each circuit, the sources of its reasons.
  • Docs: the command's params doc and docs/areas/structure-and-mep.md.

Why per country

The rule shape is generic on purpose. IEC 60364-4-41 and BS 7671 (411.3.3) ask the device for outlets up to 32 A whatever the room, and IEC 60364-7-701 / BS 7671 section 701 for every circuit of a room with a bath or shower; that is one rule with kinds: ["outlet"] and no places, plus one for bath. The US NEC (210.8) asks a GFCI, a device of its own, by a list of places close to the Brazilian one. I didn't add those sets: I'd rather not load numbers I haven't checked against the documents. A made-up set in the tests shows the check takes them as rows.

Tests

  • Every set and every rule names its source, places and kinds are ones the command knows, the numbers are finite, and the default set is there.
  • Each reason comes back with its item (5.1.3.2.2 b), d) …).
  • A made-up set (any outlet up to 20 A, 10 mA, no exemption) goes through the same check.
  • The command answers with the standard and the sources and refuses an unknown standard; the existing unit and command tests are untouched.

Not in this PR: the bathroom volumes of item 9.1, which dr_check lists as not covered; they come in a separate PR (bath_volumes).

cc @renanem, since dr_check is yours (#245): same behaviour, only where the rules live has changed.

The cases NBR 5410:2004 item 5.1.3.2.2 asks a 30 mA residual-current
device for move to data/dr-check.json, as load_points' rules did: each
rule a place, a kind of point, a building and its exceptions, naming
the standard's item, and the 32 A of note 1, the IT circuits of note 2
and the high lights of note 3 with their sources. dr.rs only reads them
(RuleSet), so another country's rules come in as rows. The command
takes standard (NBR 5410:2004 the default and only set) and answers
with the standard, its source and the source of each reason; a test
fails on a rule that names no source or a place or kind it does not
know, and a made-up set shows the check takes other numbers.
@IPedrax
IPedrax merged commit e1d90b6 into IPedrax:main Nov 11, 2026
5 checks passed
@dronov-dmitry dronov-dmitry moved this to Done in BIMCraft Nov 14, 2026
ffishman added a commit to ffishman/BIMCraft that referenced this pull request Nov 20, 2026
Each fails under a deliberate break that the tests let through before: a range from 0 holds 0, and each row answers at its
own upper end (and its demand's), in every utility's table and by every method (IPedrax#484, IPedrax#474); each building method at its
least number of dwellings and not one fewer (IPedrax#483); an outdoor rule asks it of outlets only, whatever kinds a code lists
(IPedrax#359); a room with its outlets and no light point is short, and enough once its light is drawn (IPedrax#280); a 3D file over the
limit refused by its size, before it is read (IPedrax#393); only a common property set has the status the export writes (IPedrax#291); a
beam at the view range's top is seen, and hidden by a ceiling there (IPedrax#153); Run Script says a single warning (IPedrax#391).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

2 participants