FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

ifcdiff: six silent under-reporting defects by BIMvoice · Pull Request #9296 · IfcOpenShell/IfcOpenShell · GitHub

ifcdiff: six silent under-reporting defects - #9296

Open
BIMvoice wants to merge 3 commits into
IfcOpenShell:v0.8.0from
BIMvoice:fix-ifcdiff-correctness-bugs
Open

ifcdiff: six silent under-reporting defects#9296
BIMvoice wants to merge 3 commits into
IfcOpenShell:v0.8.0from
BIMvoice:fix-ifcdiff-correctness-bugs

Conversation

BIMvoice commented Aug 13, 2026
edited
Loading

Copy link
Copy Markdown
Contributor

Six defects in src/ifcdiff/ifcdiff.py, each causing a revision comparison to silently under-report. Found by comparing two real IFC revisions against three independent implementations and chasing every disagreement.

Scope note. This originally carried a seventh fix, for get_container() and get_aggregate() being compared as entity instances across two different ifcopenshell.file objects, which are never equal, so every contained element was falsely reported as changed. @ProductOfAmerica has since fixed that independently and more narrowly in #9312. I have dropped it from here so the two do not conflict, and confirmed with git merge-tree that this branch and #9312 now merge cleanly. That defect is fixed by #9312, not by this PR, and the container and aggregate code paths here are byte identical to v0.8.0.

The defects

1. Class changes are never detected. Same GlobalId, IfcWall becomes IfcSlab, and with every relationship enabled the result is changed=0. diff_element compares attribute values and never compares is_a(). Now reported as class_changed with old and new class names.

2. Placement is never compared. A moved or rotated object whose attributes, mesh and properties are unchanged reads as unchanged. On the test pair this hid a re-georeferencing: an IfcSite moved from (0, 40000, 0) at 60 degrees to the origin at 0 degrees, entirely unreported. Added as its own placement relationship rather than folded into geometry, because IfcSite has no Representation at all and is structurally invisible to the mesh pipeline. Compares the composed world transform, tolerance gated by self.precision.

3. Material changes are never detected. No material branch existed and it was absent from RELATIONSHIP_TYPE. Added, resolving through layer sets, profile sets, constituent sets, usages and material lists, and comparing resolved names rather than entity references, since references renumber on every save.

4. The id exclusion regex never matches. The property branch already tried to exclude the bookkeeping key with exclude_regex_paths=[r".*id$"], but the real DeepDiff path is root['Pset_Foo']['id'], which ends in ']. So the intended filter silently did nothing and every re-saved file reported false property changes whose only difference was a STEP entity number. Fixed to r"\['id'\]$".

5. Attribute detail was computed then discarded. diff_element built a full DeepDiff and stored {"attributes_changed": True}, throwing the detail away, and compared positional lists so names were lost anyway. Now compares name keyed dicts and keeps the diff, so the output says which attribute changed:

"attributes_changed": {"type_changes": {"root['PredefinedType']":
  {"old_value": "USERDEFINED", "new_value": null}}}

6. is_shallow=False never worked. Each relationship branch returned unconditionally, so even asking for full accumulation only ever reported the first change type found. The default stays True, deliberately: it is a documented speed tradeoff and consumers may rely on the output shape.

7. Geometry was never queued on some files. The check required a MODEL_VIEW subcontext; models placing Body items directly under the base IfcGeometricRepresentationContext never reached geometry diffing at all, regardless of settings.

(Numbered one to seven for readability; six are fixed here, since the container and aggregate defect moved to #9312.)

Tests

17 tests in src/ifcdiff/test.py, all built programmatically with ifcopenshell.api so they run anywhere with no sample files. Each defect above has a test that fails without its fix.

Worth flagging one thing found while making the suite portable: defect 7 previously had no portable coverage at all. Every other test uses a helper that creates a proper MODEL_VIEW subcontext, so none of them ever reached the fallback branch the fix adds; it was only exercised by a local sample file. test_geometry_change_detected_without_model_view_subcontext now covers it, verified red against pre-fix ifcdiff.py with a KeyError and green after.

An earlier revision of this branch included a test reading two 900KB IFC files from a hardcoded local path, skipped when absent. That has been removed rather than committed, on size and redistribution grounds. The consequence is that coverage is now unit level rather than integration level against real project data, which is the right trade for reviewability but is a real reduction and worth stating.

black and ruff clean.

Conflicts

Checked with git merge-tree --write-tree against #9312 and against our other open branches, with a control pair confirming the check detects real conflicts rather than passing everything. Clean.

Produced with AI assistance.

class change (same GlobalId, different is_a()) was never detected.
The property id-exclude regex never matched, causing false positives.
attributes_changed discarded its DeepDiff detail and compared
positional lists. container/aggregate compared cross-file entities by
identity, always true. Added material and placement relationships.
BIMvoice changed the title ifcdiff: seven silent under-reporting defects ifcdiff: six silent under-reporting defects Aug 16, 2026
BIMvoice marked this pull request as ready for review August 16, 2026 04:40
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL