Development stories

Did the model survive the export?

KratosForge Editorial · 2026-11-19

Kratos points to a missing notch in a cast bronze key while his wolf inspects the mold and original.
Custom illustration · A copy can look convincing while losing a detail that matters.

An export can finish successfully and still change the model it carries. An empty description can disappear, whitespace can become part of a value, and a second save can reorder files. Those are difficult changes to spot in a large semantic-model diff. KratosForge’s latest TMDL work found concrete examples by testing what happened after the exported files were read back.

Merged PR #3064 added seeded, generated models to the local TMDL writer and reader tests. Its inputs include quotes, unusual line separators, Windows-reserved names, Unicode spaces and malformed types. Fixed seeds make a failing case reproducible. The tests ask whether a conversion preserves the supported model, refuses an input with a clear reason, or names the information it cannot carry. They also check that writing the restored model produces the same files.

That extra pass found bugs that ordinary sample models had missed. The reader ignored the table order recorded in model.tmdl. Empty descriptions were omitted. A filename already at its length limit grew beyond that limit when a collision suffix was added. The merged fixes preserve table order and empty descriptions, and shorten the filename before appending its suffix. A separate converter fix quotes strings containing the U+0085 next-line character so YAML does not reinterpret it.

The small check below uses the internal Python module from app commit a45b1a3. Run it in a development checkout with the sidecar dependencies installed and sidecar on PYTHONPATH; it is a source-level example, not a Stable automation API. It checks a deliberately awkward table order, case-colliding names and an empty description. The example passed locally, as did 37 tests across the pinned generated-case and TMDL-reader test files. No live Fabric service was exercised.

PYTHON · Source-level round-trip and repeat-save checks at the pinned app commit
from fabric_desktop import tmdl

original = {
    "name": "Check", "compatibilityLevel": 1604,
    "model": {"description": "", "tables": [
        {"name": "b"}, {"name": "a"}, {"name": "A"}
    ]},
}
files, report = tmdl.from_bim(original)
restored, read_report = tmdl.to_bim(files, "Check")
assert report == read_report == []
assert tmdl.differences(original, restored) == []
assert tmdl.differences(restored, original) == []
assert [t["name"] for t in restored["model"]["tables"]] == ["b", "a", "A"]
assert tmdl.from_bim(restored)[0] == files

The contract still has boundaries. A fenced value with blank lines at its edges, or an indent shared by every line, can be interpreted differently when read. The implementation reports affected objects rather than claiming an exact conversion. The semantic-model conversion workflow remains Preview, and this article describes a main-branch merge; the Stable release checked on November 19 was last updated November 2. Read the conversion report before accepting an export.

A reader and writer can also agree on the same mistake. Local round-trip tests establish a useful internal invariant; they leave compatibility with another implementation to separate tests. For your own exporter, keep one awkward fixture, assert the values and ordering that matter, and export the restored object again. When a generated case fails, retain its seed and turn the smallest example into a regression test.

← All publications

Search documentation

Start typing to search all 115 guides.

Search runs in your browser esc to close