Skip to content

ci(measure): score the MCP server's answers against the same run's export and Revit's (#1327) - #1404

Merged
DrunkOnJava merged 10 commits into
mainfrom
ci/measure-mcp-answers-1327
Nov 5, 2026
Merged

DrunkOnJava merged 10 commits into
mainfrom
ci/measure-mcp-answers-1327

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

Summary

Measure now scores what the MCP server tells an agent about each model it exports. A scripted client with no language model starts the built rvt-rs-mcp, asks a fixed query set, and tools/re/mcp_answers_vs_ifc.py checks the answers against the same run's IFC export (any difference is a failure, exit 1) and against Revit's export.

Motivation

#1327. The server answers from the model the IFC exporter builds, so its answers must equal the export; only the protocol was checked, on corpus/tier1 and Einhoven (corpus-mcp). This also builds the extractor that #1334's semantic merge check reads.

Changes

  • tools/re/mcp_client.py: JSON-RPC over the server's stdio (stateless 2026-07-28 lifecycle, standard library only), the fixed query set, and the deterministic semantic dump (sorted keys, floats at six decimals, no handle, time or path). The sample is the five lowest ElementIds of each IFC entity.
  • tools/re/mcp_answers_vs_ifc.py: the consistency checks and the oracle. Report.line takes words written with W() and, as values, only integers and IFC entity names, and raises on anything else; a check that was not measured is named in the verdict.
  • tools/ci/measure-reference-models.sh: an mcp task per model (also a model with no Revit export), never from the score cache; mcp-dump.json only for Core Interior, Einhoven, RE1, the BIM4LCA office and the Revit 2025 models.
  • .github/workflows/measure.yml: builds rvt-rs-mcp only in a run that names no scorers or names this one (binary cache key v2, -mcp when built); a server that does not build leaves the step NOT MEASURED with a warning and fails no other scorer, and its key is not saved without the binary. The run summary lists each model's verdict, no verdict, exit N for a crash, and fails no job; mcp-dump.json is out of the diff.
  • tools/ci/scrub-holdout-results.sh: a held-out, BIMcollab or rac_advanced model keeps only the lines starting mcp answers: and its exit status.
  • docs/maintaining.md, changelog.d/added/1327-measure-mcp-answers.md.

What is checked, and what is not

Consistency, against the model's own export (the server's own when ifc_flags is set): the protocol; the summary's counts against the rows, the filtered totals, the IFC and the diagnostics; every element and space by GlobalId in both directions with entity, Name, LongName, Tag, PredefinedType and storey; the levels and the elements each holds; the rooms' Name (the number), LongName, storey, outline source and plan area; for the sampled elements the property and quantity sets, trust markers, type object, translation (not rotation), host, and whether the body is none or mapped; get_diagnostics against diagnostics.json; the server's export against ifc.sha256.

It cannot catch a decode error. The server and the writer share one IfcModel, so the check finds what either does to it on the way out (a wrong projection, an element or set the writer drops or makes, a run that does not repeat), and a value read wrongly from the file is the same on both sides. The oracle (class sets, storeys, room areas, property and quantity values against Revit's export, with the existing scorers' pairing and tolerances) is what measures decode; its lines are measurements, not failures.

Testing

Unit tests are banned: none added. Measure, on main's server (this pull request does not change the server):

Run Head Models Consistent
41950741547 (the pull request's) 9fbb594 Core Interior, Einhoven, RE1 (6) 0 of 6
41949014871 1895e77 the same 6 0 of 6
41949018446 1895e77 BIM4LCA office as built, at permit 0 of 2
41949021964 1895e77 24 Revit 2025 models 1 of 24 (blank project)
41949025326 1895e77 18 held-out, 1 spent, BIMcollab, 6 rac_advanced (counts only) 0 of 26

Equal to the export on every model: the protocol, the rooms' areas, the sampled property and quantity sets and trust markers, the diagnostics and the export hash. The faults found:

  1. A space's Name was the model's Room-<ElementId> where the IFC has the room number, and its LongName was not served (Core Interior 116 of 116 rooms, RE1 Architecture 11 of 11).
  2. element_type lacked the Other and Identity Data sets and the type objects made for rooms, and named a type where the writer makes none (Einhoven's four ArcWalls).
  3. Parts of a stair or railing have no level where the IFC puts them on their whole's storey: 5 Revit 2025 models, 4 held-out, and the office, as built 599 of 12,974 rows and 8 of 10 levels' counts, at permit 599 of 13,020 rows and 7 of 10.
  4. The office lists IfcCovering rows the export does not write: 158 against 111 as built (47 rows), 122 against 75 at permit.

(1) and (2) are fixed in #1406: its runs 41951524664 and 41951554180 (code head 6c994f3, this branch's scorer at 9fbb594) pass 6 of 6 reference models and 19 of 24 Revit 2025 models. (3) and (4) are not fixed. The scorer took 44 s on the office as built (13,021 rows) and 42 s at permit (13,067).

The scorer has changed twice since the runs above, on the findings of #1406 and #1412: 3048014 reads the pieces a server folds into other bodies (elements.folded_into_bodies) when it compares the summary with the diagnostics, and 9b51c1a expects, for a space with neither a number nor a name, the name its row gives (a family instance written as a space keeps its Family:Type:ElementId) and the <class>-<ElementId> placeholder only where the row has none: with the earlier rule the office failed rooms on 44 of 308 spaces in each file, a scorer fault. The pull request's own Measure run on the head 9b51c1a (merged with main 07caf05, main's server), 41957544702, scored the 6 reference models (it has no office or Revit 2025 models): all 6 fail, for the faults #1406 fixes (element names and long names on Core Interior and RE1 Architecture, type objects and their sets on all 6), with a verdict line on every model and no crash. The fixed servers' runs with this scorer: #1406's tip 3c9a263, run 41957587403, passes 25 of 32 models (the 5 stair models and the office fail what #1412 fixes), and the merge of #1406 and #1412 (537d88ba), run 41957685928, passes 32 of 32. The IFC identity runs belong to those pull requests: 41954681945 (#1406, 34 of 34 identical) and 41957584014 (#1412 against its fork point, 34 of 34 identical). Not measured: Autodesk's sample projects are not asked; the oracle's figures are in the runs' artifacts and are not summarised here.

Related issues

Refs #1327

…port and Revit's (#1327)

A scripted client with no language model (tools/re/mcp_client.py) starts the built rvt-rs-mcp, opens each model Measure exports and asks a fixed query set. tools/re/mcp_answers_vs_ifc.py checks the answers against the model's own IFC export (a difference ends its output with exit 1) and against Revit's export with the pairing and tolerances of the existing class sets, storeys, space profiles, property sets and quantities scorers. Measure builds the server only when it scores it, keeps the count lines of the held-out models, and uploads each model's answers as a deterministic dump for the semantic merge check (#1334).
…t attribute and the type objects as checks of their own (#1327)

The diagnostics do not count an IFCOPENINGELEMENT as a building element (RE-84) while the summary lists it as a row, so the comparison with building_elements leaves the openings out and counts them on a line. A single disagreeing attribute (a room's name in list_elements) no longer hides the elements, ids, predefined types and storeys that agree, and the type objects' presence and their sets are separate checks.
…d the type object's entity and name (#1327)

The writer gives an IfcSpace the room number as Name and the room name as LongName, and a type object an entity and a Name of its own. The scorer compares each with the answers' fields, and accepts an absent name only where the IFC Name is the exporter's own <Revit class>-<ElementId> placeholder.
@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava marked this pull request as ready for review November 5, 2026 01:54
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
…and entity names, a crash shows in the summary, and the dump is for open models (#1327)

Review of the scorer: Report.line raises on anything but words written with W() and integers or IFC entity names as values, so a name or an id cannot reach the lines kept for restricted models; the dump is written for the openly licensed models only; the scrub keeps the exit line and the run summary reports a model with no verdict as such; a PASS names the checks that were not measured; a server that does not build leaves the step NOT MEASURED without failing the Build step or poisoning the binary cache; the client times discovery out on its own, turns a broken pipe into NOT MEASURED and samples the five lowest ElementIds of each entity; a room's number must be the IFC Name, a repeated IFC GlobalId is a failure, and the placeholder is matched as <class>-<ElementId>. Docs and the changelog fragment say what consistency can and cannot catch and restate the measured claims by run and head.
@DrunkOnJava DrunkOnJava added the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
…ements' bodies from its summary (#1327)

The diagnostics count the further pieces of an element of separate loops as exported, the IFC does not write them as elements. When the summary lists them apart (elements.folded_into_bodies), the comparison of its counts with the diagnostics adds them back; without the field nothing is added.
…eck (#1327)

A family instance written as a space has neither a room number nor a room name and keeps its Family:Type:ElementId model name, which the IFC Name is and the row gives. The room check expected the <class>-<ElementId> placeholder of it, a false failure on 44 spaces of each BIM4LCA office file; it now expects the row's name, and the placeholder only where the row has none.
@DrunkOnJava DrunkOnJava removed the ready-when-green Draft whose code is complete: marked ready for review once its fast CI passes label Nov 5, 2026
@DrunkOnJava
DrunkOnJava enabled auto-merge (squash) November 5, 2026 03:21
@DrunkOnJava
DrunkOnJava merged commit c9297d8 into main Nov 5, 2026
42 checks passed
@DrunkOnJava
DrunkOnJava deleted the ci/measure-mcp-answers-1327 branch November 5, 2026 03:50
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
@DrunkOnJava DrunkOnJava mentioned this pull request Nov 5, 2026
3 tasks done
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
…rt writes (#1327) (#1406)

## Summary

An `IfcSpace`'s `name` in the MCP server's `list_elements` and
`get_element` is the room number the IFC writes as `Name` (its room name
is `long_name`, the `LongName`), and `element_type` is the type object
the IFC writer makes, with its sets. Both now come from the writer's own
functions.

## Motivation

The Measure scorer of #1327 (#1404) found both disagreements between the
server and the IFC export on every model it ran on: the server served
the model's `Room-<ElementId>` placeholder as a room's name, and
`element_type` was a parallel grouping in `rvt-mcp/src/views.rs` without
the `Other` and `Identity Data` sets, without the `IfcSpaceType` made
for each room, and with a type where the writer makes none (Einhoven's
four ArcWalls, type 8570).

## Changes

- `src/ifc/step_writer.rs`: `written_names` (the `Name` and `LongName`
of an element, and whether the name is the exporter's placeholder) and
`type_objects` (the type objects the writer makes: which elements each
types and the sets it holds) are public, and the writer writes with
them. The diagnostics' count of the type objects' parameter values
(`type_object_pset_values`) reads `type_objects` too, so it now skips
the pieces folded into another element's body. The move is meant to
leave the IFC text byte for byte as it was.
- `rvt-mcp`: rows and `get_element` gain `long_name`; `name` is absent
only for a room with neither a number nor a name whose name is exactly
the exporter's `<Revit class>-<ElementId>`; `element_type` gains
`ifc_type` and `name`, and is absent where the writer makes no type
object; `explain_element`'s `name` and `other_entities[].name` follow
the same rule.
- `docs/mcp.md`,
`changelog.d/fixed/1327-mcp-written-names-and-types.md`,
`changelog.d/added/1327-written-names-and-type-objects.md`.

## MCP contract

The tool output schemas change (`name` optional, `long_name`,
`element_type.ifc_type`, `element_type.name`) and the `list_elements`
and `get_element` descriptions. The contract in `docs/mcp-tools.json`
and `docs/mcp-tools.md` is committed by the contract sync from CI, not
edited here.

## Known gap

The placeholder names of elements other than rooms are still served as
`name`: a wall nothing named is `Wall-<ElementId>`. Einhoven 23 of 37
rows, RE1 Electrical 3 of 49, the BIM4LCA office as built 52 of 13,021.
Said in `docs/mcp.md` and the fragment. The path where a row has no
`name` is not measured: no row of the 32 models' dumps lacks one.

## Testing

Unit tests are banned: none added. Proof is the scorer of #1404
(`tools/re/mcp_answers_vs_ifc.py`), run by Measure with `base=none`, `-f
scorers=mcp_answers_vs_ifc`.

**Lands first**, then #1412 (which edits the same functions of
`rvt-mcp/src/views.rs` and `store.rs`) merges main.

Before: main's server with the 1895e77 scorer. After: this branch, code
head 34ace10 (merged with main 07caf05, and 3c9a263 adds the
contract) with the 3048014 scorer, run 41954686452:

| Models | Consistent before | Consistent after |
| --- | --- | --- |
| Einhoven, Core Interior, RE1 Architecture, Electrical, Mechanical,
Plumbing | 0 of 6 (run 41949014871) | 6 of 6 |
| 24 Revit 2025 models | 1 of 24 (run 41949021964) | 19 of 24 |
| BIM4LCA office as built, at permit | 0 of 2 (run 41949018446) | 0 of 2
|

Still failing, and why:

- The 5 Revit 2025 stair models (13 to 17): `element storeys` and
`levels`. The parts of a stair have a level of their own, or none, where
the IFC puts them on their whole's storey. Fixed in #1412.
- The office, as built and at permit: counts, element membership,
element storeys and levels. As built: 158 against 111 `IfcCovering`
rows, 599 of 12,974 rows, 8 of 10 levels' counts. At permit: 122 against
75, 599 of 13,020 rows, 7 of 10 levels. #1412 takes these (the 599 are
542 curtain-wall members and the rest stair parts; the coverings are the
pieces the export folds into another body).
- The office's `rooms` check also failed in run 41954686452, 44 of 308
spaces each: a scorer fault, not the server's. A family instance written
as a space has neither a room number nor a room name and keeps its
`Family:Type:ElementId` model name, which is its IFC `Name`; the scorer
expected the `<class>-<ElementId>` placeholder. Corrected in the scorer
as 9b51c1a; run 41957587403 (this branch's tip 3c9a263, that scorer)
has the same 25 of 32 models passing and no `rooms` failure.

**With #1412 merged** (throwaway merge `537d88ba` of the two heads, the
scorer at 9b51c1a), run 41957685928: **32 of 32 models pass every
check**: the 6 reference models, the 24 Revit 2025 models and the office
as built and at permit.

The office's names, long names, type objects and their sets, diagnostics
and export hash are equal.

IFC identity: run 41954681945 (`base=main` at 07caf05, head 34ace10,
`scorers=none`, nordic and r2025 on) has the same `ifc.sha256` on 34 of
34 models: the reference models, the four office files and the 24 Revit
2025 models. The held-out models and Autodesk's samples were not run.

The `parameter_value_count` that `type_object_pset_values` feeds now
skips folded pieces; no model's diagnostics were compared for it.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR:
`docs/mcp.md` (names, `element_type`, the known gap); no claim of a
feature this PR does not ship.
- [x] The user-visible change has fragments under `changelog.d/`
(`fixed` and `added`), not in `CHANGELOG.md`.
- [x] A limitation resolved: the type objects and room names disagreed
with the export; the "Known gap" above is the one introduced or left,
and it is documented in the PR body, `docs/mcp.md` and the fragment.
- [x] Commit messages describe what changed and why.
- [x] No emojis in code, docs or commit messages.
- [x] No private paths, personal email addresses or internal jargon in
committed files.
- [ ] N/A: not a reverse-engineering finding.

## Legal and contribution hygiene

- [x] Licensable under Apache-2.0.
- [x] No Autodesk proprietary source, decompiled internals or NDA
content; the change reorganises the library's own writer.
- [x] No new fixtures.

## Breaking changes

For clients of the MCP server (the tool contract changes):

- `name` of a row, of `get_element` and of `explain_element` is now
optional: absent for a room whose name is exactly the exporter's `<Revit
class>-<ElementId>` placeholder. A client that required it must handle
the absence.
- `element_type` is absent where it used to be served: for an element
the writer makes no type object for (Einhoven's four ArcWalls), and its
`property_sets` now hold the `Other` and `Identity Data` sets.
- `element_type.element_id` is the type object's `Tag`, which for an
`IfcSpaceType` is the room's ElementId, not a type's.
- New fields: `long_name`, `element_type.ifc_type`, `element_type.name`.

The `rvt` crate gains public items only (`written_names`,
`WrittenNames`, `type_objects`, `TypeObject`, `TypeObjects`).

## Related issues

Refs #1327
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
## Summary

Release 0.15.0:
- Where each decoded element was read from, down to the byte, on
request: `rvt-ifc --element-provenance` (#1325), with the copy each
body, profile and outline reader took its value from (#1360, #1368).
- Why an element, body, opening or outline was left out, one entry per
element, on request: `rvt-ifc --export-decisions` (#1326), and the MCP
server's `explain_element`.
- Where a Revit 2008 to 2023 project's element records stop, in every
export's diagnostics (#1389, for #421).
- Rooms take off the round columns their stored solid holds (#1354,
RE-334).
- Areas whose boundary lines name each other are drawn to their joins
(#1261, RE-330).
- Shape-edited floors drawn along their sloped top, and the walls on
them cut at it (#1384, RE-336).
- `rvt-ifc --family-extrusions`, opt-in, draws a family instance from
its family's own extrusions, arcs as true arcs (#156, RE-327, #1366).
- Partition streams in number order (#1356); the viewer's browser tests
in `CI passed` (#1394).
- Value sources for Areas and shaped floors (#1403), the shaped floors'
slab quantities and the GLB layer colour kept (#1405), floor voids
tagged as Revit tags them (#1402), Measure's scorer for the MCP server's
answers (#1404), and the MCP server's element names and type objects
taken from the IFC writer (#1406).

## Changes

- Version 0.14.0 -> 0.15.0 in:
  - Cargo.toml;
  - rvt-py/Cargo.toml and its `=` pin;
  - rvt-mcp/Cargo.toml and its `=` pin;
  - rvt-wasm/Cargo.toml;
  - tools/stream_evidence/Cargo.toml;
  - viewer/package.json;
  - CITATION.cff (version and date);
  - Cargo.lock and fuzz/Cargo.lock.
- `python3 tools/release/changelog.py assemble`: 23 fragments go into
`[0.15.0]`, with an introduction, a "Not measured" list, credits and
"Upgrading from 0.14". The 21 from the first assembly come in first,
then #1403's and #1405's after `main` was merged. #1405's fix is folded
into #1384's entry, since the slab quantities it restores never left a
release.
- README: the latest release and the "Upgrading from" pointer.

## Testing

- **Measure 41944962415.** It ran `main` at 77d71cb against v0.14.0
with timing, on the reference models, the samples, the held-out models
and Revit 2025, with no families.
- It found two losses from #1388 on the offices: 16 slab quantities went
from equal to missing on each file, and 14 (16) walls lost their GLB
layers.
- #1405 restores both. Measure 41949652150 shows them back to v0.14.0's
values, with 32 other models byte-identical.
  - The intro's timing figures come from this run.
- **Final Measure 41965523134.** It ran this branch at 1e56972 (with
#1402 to #1406, #1413 and #1414) against v0.14.0, with the reference
models, Revit 2025, the samples, the held-out models and the families.
  - Every figure in the introduction comes from it.
- Apart from the MCP scorer #1404 adds, every scorer output on every
model is identical to run 41963115180 (5b1a371): the held-out counts
only gain `mcp answers:` lines. #1406's writer refactor therefore moves
no export, on the samples and held-out models too.
  - Since 1e56972 the branch adds only changelog text.
- **Witness and fixtures.** The Core Interior witness observations and
verdicts (both artifacts) and the two synthetic fixtures are taken from
this PR's CI run 41954452074 on ce0b2d8. Only `witness_version`, the
verdict hashes and the version strings changed.
- **Release review.** A second read found these, all fixed on the
branch:
  - a false "and the families" for the first run;
  - #1405's missing entry;
  - an offsets claim that overreached for the decisions log;
  - stale sentences in three entries;
  - missing caveats, credits and upgrade notes;
- an MCP output schema that listed four optional fields as required.
#1414 fixes that and lands first.

## Audit-honesty checklist

- [x] The introduction keeps each entry's caveats, and adds a "Not
measured" list:
- the offsets unmeasured on Revit 2008 to 2022, and the decisions log's
before 2024;
  - the values with no recorded source;
  - the in-sample Area join rule (#1261);
- the refusal markers on Snowdon and `rac_advanced` with no IFC4 export
to score them;
  - the family-extrusions release range.
- [x] No emojis, private paths or internal jargon.

## Legal and contribution hygiene

- [x] Apache-2.0; no Autodesk proprietary source, decompiled internals
or NDA'd SDK content.

## Breaking changes

None in the stable API: `ExportOptions`, `ExportNote`,
`ExportDiagnostics`, `DecodedExportDiagnostics` and
`ExportedModelDiagnostics` gain fields and variants, and all are
`#[non_exhaustive]`; the provenance, decisions and stage types are new.
`--family-extrusions` is new in this release (the `arcs` field #1366
removed never shipped). Behaviour changes are listed under "Upgrading
from 0.14".

The `rvt-rs-mcp` tool output changes, as #1406 states and "Upgrading
from 0.14" lists:
- an element's `name` can be absent, where it would be a room's
`<class>-<ElementId>` placeholder;
- `element_type` is absent where the IFC export writes no type object;
- `element_type`'s `element_id` is the type object's `Tag`.

The output schemas in `docs/mcp-tools.json` say so.

## Related issues

Refs #1325, #1326, #1360, #1368, #1389, #421, #1354, #1261, #1384, #156,
#1366, #1356, #1394, #1374, #1402, #1403, #1404, #1405, #1406, #1413,
#1414.
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
…FC export writes (#1327) (#1412)

**Lands after the v0.15.0 release merges (the main session holds every
pull request until then).** #1406 and #1404 are in main; this branch has
main merged in (`d0836833`), and its tool contract is synced from CI
(`d3fe753b`).

## Summary

The MCP server's element lists, counts and levels are the elements the
IFC export writes, in the storey it puts them in. A part of a stair, a
railing or a curtain wall has the level of its whole, an element in a
room the level of the room, an opening the level of its host, and a
further piece of an element of separate loops that the export folds into
the owner's body is not a row.

## Motivation

The Measure scorer of #1327 (#1404) found two disagreements that #1406
does not fix: the parts of a stair, a railing or a curtain wall have no
level, or one of their own, in the answers where the IFC puts them on
their whole's storey (5 Revit 2025 models, 4 held-out, and the BIM4LCA
office: 599 rows of each of its files, 542 of them curtain-wall members
at "Roof" where the IFC says Level_05, and 7 or 8 of 10 levels' counts),
and the office lists `IfcCovering` rows the export does not write (158
against 111 as built, 122 against 75 at permit).

## Changes

- `src/ifc/step_writer.rs`: `placements` (the writer's decision where
each building element goes: folded, a door's or window's opening, in a
space, part of an aggregate, on a storey, in the building) and
`storey_of` are public, and the writer places every element with
`placements`. `Placement::Opening` is `non_exhaustive`.
- The diagnostics' `storey_bound_elements` (`src/ifc/mod.rs`), the rooms
schedule (`room_rows` in `schedule_csv.rs`) and
`every_storey_holds_an_element` read `placements` and `storey_of`
instead of each holding a copy of the containment rule over the
element's own `storey_index`. Not changed: `elements_csv`, whose level
column and rows still follow the element's own `storey_index` and list
the folded pieces.
- `rvt-mcp`: an element's `level`, the levels' `element_count` and the
`level` filter read `placements`; a folded piece is neither a row nor in
`total` or `by_ifc_type`, and the summary counts it by IFC entity in
`elements.folded_into_bodies`, always present, since the diagnostics'
`exported` counts include it. The `open_model`, `get_summary` and
`list_elements` descriptions and the `other_entities` doc say the lists
leave out folded pieces.
- `docs/mcp.md`, `changelog.d/fixed/1327-mcp-written-placement.md`.

## MCP contract

The summary's output schema changes (`elements.folded_into_bodies`,
always present) and so do the descriptions of `open_model`,
`get_summary` and `list_elements`. `docs/mcp-tools.json` and
`docs/mcp-tools.md` are the contract as the server writes it, synced
from CI run 41965770978. Clients: a row can be absent that was listed
before (the folded pieces), and an element's `level` can be present
where it was absent.

## Testing

Unit tests are banned: none added. Proof is the scorer of #1404, run by
Measure with `base=none`, `-f scorers=mcp_answers_vs_ifc`, over the
office as built and at permit, the 24 Revit 2025 models and the
reference models.

On the merged head `d0836833` (this change merged with main `6f4bc534`,
which has #1406 and #1404):

- **Consistency.** Run 41965720746 (`base=none`, `-f
scorers=mcp_answers_vs_ifc`): **32 of 32 models pass every check**: the
6 reference models, the 24 Revit 2025 models and the office as built and
at permit. Before, on main's server, the office as built and at permit
failed `counts`, `element membership`, `element storeys` and `levels`
(47 coverings; 599 of 12,974 and of 13,020 rows, of which 542
curtain-wall members and the rest stair flights and landings; 8 and 7 of
10 levels) and so did the 5 Revit 2025 stair models (runs 41949018446
and 41949021964).
- **IFC identity.** Run 41965717668 (head d083683 against main
6f4bc53, `scorers=none`, nordic and r2025 on): the same `ifc.sha256` on
**34 of 34 models**: the 6 reference models, the four office files and
the 24 Revit 2025 models.
- **Diagnostics.** Across the 34 models of that run, one key of
`diagnostics.json` moves: `exported.storey_bound_elements`, on 7 models:
the office as built 12,961 to 12,971, at permit 13,008 to 13,018, the
Revit 2025 stair models 13 to 15 from 24 to 27 and 16 and 17 from 24 to
25. These are the elements bound to a storey through their whole. The
only use of the count besides the field is a warning that fires when it
is above zero and the elevation fallback applies; no warning text moved.

The runs on the earlier review head (code `3f49fe67`, merged with main
`da4c9141`, before #1406 landed) are superseded and agree: IFC identity
41960289212 (34 of 34), scorer 41960292399 and, with #1406 merged in on
a throwaway branch, 41960400798 (32 of 32). Runs against the wrong bases
(41954408419, 41957584014) are superseded too.

The held-out models and Autodesk's samples were not run.

## Audit-honesty checklist

- [x] README / docs reflect the current state after this PR:
`docs/mcp.md` (elements and levels as the export writes them); no claim
of a feature this PR does not ship.
- [x] The user-visible change has a fragment under `changelog.d/fixed/`,
not in `CHANGELOG.md`.
- [x] A limitation resolved: the levels and lists disagreed with the
export. Left: `elements_csv`'s level column and folded rows; the
placeholder names of non-room elements (#1406); a part of several wholes
takes the first whole's storey, which is not measured; the held-out
models and Autodesk's samples are not measured.
- [x] Commit messages describe what changed and why.
- [x] No emojis in code, docs or commit messages.
- [x] No private paths, personal email addresses or internal jargon in
committed files.
- [ ] N/A: not a reverse-engineering finding.

## Legal and contribution hygiene

- [x] Licensable under Apache-2.0.
- [x] No Autodesk proprietary source, decompiled internals or NDA
content; the change reorganises the library's own writer.
- [x] No new fixtures.

## Breaking changes

For clients of the MCP server: `elements.total`, `by_ifc_type` and the
lists leave out the folded pieces (47 rows on each office file, nowhere
else measured); an element's `level` and the levels' `element_count`
follow the export's containment, so a part, an element in a room and an
opening have the level of its whole, room and host;
`elements.folded_into_bodies` is new. For users of the diagnostics:
`exported.storey_bound_elements` counts an element bound to a storey
through its whole, space or host (the figures above). The `rvt` crate
gains public items only (`placements`, `Placement`, `storey_of`).

## Related issues

Refs #1327
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
…gainst its tool's output schema (#1415) (#1416)

## Summary

Closes #1415. The release review of 0.15.0 found MCP output fields that
the server leaves out when empty but its output schema listed as
required (#1414). Nothing caught it: `rvt-mcp/tests/mcp_stdio.rs`
checked only that each tool has an `outputSchema` and that the contract
is committed.

Now, when `RVT_MCP_ANSWERS_DIR` is set, the end-to-end test keeps:
- each tool's `outputSchema`, from every session's `tools/list`;
- every successful structured answer it is given, written as
`<dir>/{schemas,answers}/<tool>/<pid>-<n>.json`.

Every call the rmcp client makes goes through the test's `call()`
helper, and every raw JSON-RPC request goes through the `Raw` helper,
which records each `tools/call` request's tool by id and keeps its
successful structured answer in `recv`. So every tool answer the test is
given is kept: `open_model`, `get_summary` and `export_ifc` in the raw
tests (`wire_discipline_on_raw_stdio`,
`a_path_outside_output_dir_is_refused`, `cancel_an_export`), and every
tool through the client. Schemas are kept from each session `drive`
runs.

`tools/ci/validate-mcp-answers.py` then checks four things, and fails CI
if any of them fails:
- each tool's schema is the same in every session;
- every tool that answered declared a schema;
- the schema is valid JSON Schema;
- every answer validates against it.

It prints a per-tool count, and up to 5 errors per invalid answer,
naming the deepest reason inside an `anyOf` (an optional object), with a
count of the rest. With `--require-all`, as CI runs it, a tool that
declared a schema and gave no answer fails too. A model the test skipped
therefore cannot leave tools unchecked: `get_element` and
`explain_element` answer only on Einhoven. An empty answer folder also
fails. The test clears the directory once a run before writing, so a
local rerun never mixes runs. CI's "MCP server on Einhoven" job sets the
variable, runs the check after the test (fixture and Einhoven, both
lifecycles), and uploads the directory as `mcp-answers`. It uses
`jsonschema`, already pinned by hash in
`tools/ci/requirements-test.txt`. No Rust dependency is added.

## Testing

- **Locally, without a build.** I ran the validator on main's
`get_element` schema (from `docs/mcp-tools.json`) with an empty answer.
It reports each missing required property and exits 1. I also gave it an
empty schema folder; it now reports that instead of crashing.
- **First CI run, at 6a2aadb on main without #1414** (job 127024735756,
"MCP server on Einhoven"). The stdio tests passed (15 of 15), and the
check failed on exactly the four fields #1414 fixes. Every tool
answered: 59 answers in all, across the synthetic fixture and Einhoven
in both lifecycles.
- `list_elements` (2 of 6 valid): each row's `provenance` lacks
`value_sources`.
- `get_element` (0 of 6) and `explain_element` (0 of 6): each
`value_sources` entry lacks `partitions`, `parts` and `parts_left_out`.
  - The other 7 tools' 47 answers are valid.
- **After #1414 landed**, at 1c32d1b (main merged in, job
127034039581), all 59 answers of all 10 tools validate against their
tools' schemas.
- **Final head 509a968** (job 127062380667), with the raw JSON-RPC
tests' answers kept as well: all 65 answers of all 10 tools validate in
`--require-all` mode. The 6 raw answers add 3 `export_ifc`, 2
`get_summary` and 1 `open_model`.
- `cargo fmt --check`, `actionlint` (no finding beyond the known `$/`
syntax) and `py_compile` pass.

## Audit-honesty checklist

- [x] The check validates what the server actually sends, against what
it declares. It does not judge whether the values are right; Measure's
`mcp_answers_vs_ifc` (#1404) does that.

## Legal and contribution hygiene

- [x] Apache-2.0; no Autodesk proprietary source, decompiled internals
or NDA'd SDK content.

## Breaking changes

None. Test and CI only.

## Related issues

Closes #1415. Refs #1414, #1327.
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