Skip to content

test(mcp): every tool answer the end-to-end test is given validates against its tool's output schema (#1415) - #1416

Merged
DrunkOnJava merged 7 commits into
mainfrom
test/mcp-answers-validate-schema
Nov 5, 2026
Merged

DrunkOnJava merged 7 commits into
mainfrom
test/mcp-answers-validate-schema

Conversation

@DrunkOnJava

@DrunkOnJava DrunkOnJava commented Nov 5, 2026 •

Copy link
Copy Markdown
Owner

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 fix(mcp): fields the server leaves out when empty are optional in the output schema #1414 (job 127024735756, "MCP server on Einhoven"). The stdio tests passed (15 of 15), and the check failed on exactly the four fields fix(mcp): fields the server leaves out when empty are optional in the output schema #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 fix(mcp): fields the server leaves out when empty are optional in the output schema #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

Legal and contribution hygiene

  • 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.

@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 03:57
@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 05:18
@DrunkOnJava
DrunkOnJava merged commit f55a95a into main Nov 5, 2026
35 checks passed
@DrunkOnJava
DrunkOnJava deleted the test/mcp-answers-validate-schema branch November 5, 2026 05:37
DrunkOnJava added a commit that referenced this pull request Nov 5, 2026
… beneath it is drawn to that wall's face (#1396) (RE-337) (#1398)

## Summary

**This ships as a labelled approximation (Griffin, 2026-11-05 at about
12:30 AM EST, answering a question asked with the question tool: ship
it, labelled).** Revit steps the end up past the wall beneath, by a join
order that is not read, and the steps above the block are not drawn. A
wall whose block stops below its top carries `BodyEndSource`
`wall_end_to_base_wall_upper_step_omitted` (2 walls on each office file,
2057668 and 2057670, run 41980282001); `wall_end_extended_to_base_wall`
is kept for a block that reaches the wall's full height, which no
measured wall does.

A wall with an edited elevation profile that is a plain rectangle along
a model axis and is drawn from its record box now has an end drawn to
the face of the perpendicular wall beneath it that holds its base, where
the record box's end (before the join trim) lies inside that wall and
the cut of the wall's base still resolves over the longer plan. The
added end is a block drawn up to the lowest of the top of the wall it
reaches, the base of any other wall the pass reads that it would lie
inside, and the wall's own top; the wall's profile openings stay where
they were. Walls 2057668 and 2057670 of the BIM4LCA office have Revit's
lowest point as built and at building permit, and no wall has more
points above Revit's top in the plan rows than on `main`. No other wall
of either office file, Core Interior, RE1 Architecture, the 24 R2025
models, the 58 Autodesk sample projects or the 25 held-out models
changes. A wall that keeps an end the rule would have drawn carries
`BodyEndRefusal`, counted in `exported.wall_end_refusals`. Report:
RE-337.

## Motivation

#1396: after RE-336 the Basement walls 2057668 and 2057670 (and 2058499
and 2058501 at permit) were 0.123 ft (0.044 ft) off Revit's lowest point
because their plans end short of Revit's at the low end of the footing.
The record's join trims the end to the face of a Level_01 wall that
overlaps the wall by 0.66 ft of 9.5, while Revit's body at the base runs
on to the face of the Basement wall beneath
(`JoinEndGStep.m_geomJoined`), which the record box's end lies inside,
and steps up the height to the faces of the walls above. Each of these
walls has an edited elevation profile, which separates them from the
other ends a join trim moves: a rule on the join alone moved 25 Autodesk
sample projects, a held-out model and one more office wall.

## Changes

- `src/ifc/export_content/wall_tops.rs`: `extend_wall_ends`,
`decide_ends`, `axis_wall`, `stepped_top_wall`, `profiled_wall`,
`join_trims`, `SteppedPlan`, `finish_wall_ends` and helpers. The pass
runs after the tops are cut and before the bases are, returns early when
no wall has a profile opening, and reads the model once. It tries the
ends of each candidate on a copy, asks RE-336's `decide_base` again for
a wall whose base join names elements (and makes the solid with the
blocks, refusing if any piece is dropped or any piece has no height
above the base), and moves nothing if the base is no longer cut. It
moves the ends, moves the wall's profile openings back by the shift of
the origin, writes `BodyEndSource`
(`wall_end_to_base_wall_upper_step_omitted` where a block stops below
the wall's top, `wall_end_extended_to_base_wall` where every block
reaches it) and `EndCoverElementId`, or one `BodyEndRefusal`
(`walls_beneath_reach_the_end_at_different_faces`,
`base_cut_lost_on_extended_plan`, `base_not_cut_over_the_extended_plan`,
`wall_beneath_not_one_rectangle`, `wall_stands_in_the_added_end`). The
base pass takes the pieces (the wall's plan and a block for each end,
each to its own top); a wall with no base cut is made by
`finish_wall_ends`, whose first item is the whole plan so the glTF keeps
its layers.
- `src/ifc/export_content.rs`: the property names and values, the order
of the passes and `finish_wall_ends`. `src/ifc/wall_cut_openings.rs`:
`BodyEndSource` counts as a stepped body, so RE-321 openings still
attach (it applies alongside #1400's rewritten `host_of`).
- `src/ifc/mod.rs`, `src/ifc/export_decisions.rs`:
`exported.wall_end_refusals` and the decision
`wall_end_extension_refused` (stage `body_left_as_box`), as for
`wall_base_refusals`; `tests/export_decisions_counts.rs` counts them
against each other and names the reason for the as-built office.
- `docs/export-diagnostics.md`,
`docs/schemas/export-diagnostics.schema.json`, `docs/mcp.md`, and the
reason lists in the descriptions of `rvt-mcp/src/schema.rs` and
`rvt-mcp/src/server.rs` (the contract is synced on the branch).
- RE-337 report, `docs/support-matrix.json`, `docs/contribution-map.md`,
`docs/format-reconnaissance.md`, the RE-336 report, and a changelog
fragment for #1396 that also corrects 0.15.0's #1384 entry (its "other 2
(4) are off" sentence); the release deleted the #1384 fragment, so this
branch deletes it too.

## Testing

No unit tests (banned). Measure at head `1b3a6bd7` against `main` at
`b36477f1` (which includes #1401, RE-340), commands in RE-337 section 4:

-
[41980282001](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41980282001):
both offices, Core Interior, RE1 Architecture, `wall_heights_vs_ifc`,
`wall_top_cover_vs_ifc`, `wall_quantities_vs_ifc`, `wall_layers_vs_ifc`,
`qtos_vs_ifc`, `unfilled_openings_vs_ifc`, `keep_ifc`.
- The rule drew the ends of 2 walls as built (2057668, 2057670) and 2 at
permit (the same two). **Both office files carry the new label on 2
walls: `wall_end_to_base_wall_upper_step_omitted` on 2057668 and
2057670, as built and at permit; `wall_end_extended_to_base_wall` on
none.** It kept the ends of 2 as built (2058499, 2058501:
`base_not_cut_over_the_extended_plan`) and 2 at permit (the same:
`wall_beneath_not_one_rectangle`). `exported.wall_end_refusals` is
`{"base_not_cut_over_the_extended_plan": 2}` as built,
`{"wall_beneath_not_one_rectangle": 2}` at permit, empty on Core
Interior and RE1 Architecture, which are byte-identical (sha256).
- The scorer's own summary against `main` with #1401: walls with base
and top Revit's 604 to 606 of 607 as built and 585 to 587 of 589 at
permit; walls with the top Revit's and the base not 2 to 0 as built and
4 to 2 at permit; misses in the same storey 3 to 1 as built and 4 to 2
at permit. 2057668 and 2057670 go from 0.1230 ft (0.0439 ft at permit)
off Revit's lowest point to Revit's; no other wall's lowest or highest
point changes. Of the scorers run, only `wall_heights_vs_ifc`,
`wall_quantities_vs_ifc` and `wall_top_cover_vs_ifc` change.
- No wall has more `taller` points than on `main` in the plan rows of
`wall_top_cover_vs_ifc`, on either file. 2057668 as built: `equal 85
taller 10 lower 0` of 95 to `equal 85 taller 10 lower 5` of 100 (the
five are where Revit goes on to 182.087 ft and the block stops at
179.2979 ft); 2057670: to `equal 90 taller 10 lower 0` of 100 (Revit's
179.2979 ft); at permit both are `equal 80 taller 10 lower 0` of 90, as
on `main`. (The block to the top of the wall beneath, `1b417c45`, made
2057670 `taller 15`: Revit's end there follows the wall in front of it
from 179.2979 ft, which is the stop now.)
- Volume: 2057668 from 1.704 ft3 under Revit's to 0.593 under, 2057670
from 1.258 under to 0.147 under; at permit both from 0.374 under to
0.088 over, where the block itself is about 0.12 ft3 under Revit's end
(it stops at 180.610 ft, the wall beneath's lowest underside, where
Revit's step is at 182.087 ft) and the rest is about 0.21 ft3 of excess
in the body elsewhere that the short end of `main` masked.
- The area where a full-height top is higher than Revit's stays at
`main`'s 0.3363 ft2 on both walls and files; that metric counts only the
faces at the wall's full height, so it says nothing of the added end,
which is below it. The far-end tab is 0.4101 ft wide, as on `main`.
- `wall_layers_vs_ifc`, `qtos_vs_ifc` and `unfilled_openings_vs_ifc`
output is identical to `main`'s on all four models. 2058499 and 2058501
as built are what `main` writes (volume, height, plan, lowest point,
base). The IFC of each office differs from `main`'s (entity numbers and
timestamp taken out) in the bodies of the two walls that take the end,
the outlines of their profile openings and the property sets of the four
walls above, and nothing else. `decoded.parameter_value_count` equals
`main`'s (54,952 as built, 55,145 at permit): the markers are in
`RvtElementRecordGeometry`, not a `Pset_` set. The scorer's fit moves
the "taller" and "lower" areas of other walls by at most 0.0578 ft2 (54
walls as built) and 0.0188 ft2 (50 at permit), with the walls themselves
unchanged.
-
[41980285452](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41980285452)
(`-f r2025=true -f samples=true -f scorers=wall_heights_vs_ifc`, my own
run at `1b3a6bd7` against `main` at `b36477f1`): it exported and hashed
88 models (the 24 R2025 models, 58 Autodesk sample projects, Einhoven,
Core Interior and the four RE1 models), and the IFC sha256 is identical
to `main` on all 88. `wall_heights_vs_ifc` was scored on the 29 that
have a Revit IFC4 export (the 24 R2025 models, Core Interior and the
four RE1 models) and its output is identical to `main`'s on all 29; the
58 sample projects and Einhoven have no export to score against, so
their hash is the whole measurement.
-
[41980288900](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41980288900):
held-out, counts only, at `1b3a6bd7`: 25 models, identical to `main` on
all.
- The same two comparisons at `b47a9a00` before #1401 was merged,
[41978482673](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41978482673)
(88 models) and
[41978485557](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41978485557)
(25 held-out), are identical too.

-
[41982867204](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41982867204):
the final, unfiltered run, on this pull request's head `96baaafe`
against `main` at `40b86b80` (`-f base=main -f nordic=true -f r2025=true
-f holdout=true`, every default scorer): 53 models, 51 byte-identical,
all 18 held-out models among them; only the two office files differ.
`wall_heights_vs_ifc` reads as above (base and top Revit's 604 to 606 of
607 as built, 585 to 587 of 589 at permit). This run also scores the
wall ends, which the runs above did not: both ends within 0.001 ft go
from 512 to 514 of 607 as built and from 435 to 437 of 589 at permit, in
`wall_bodies_vs_ifc`, `wall_ends_cv_vs_ifc` and `wall_ends_list`, each
file one `start short` and one `end short` wall to `ok` and no wall
worse. No other scorer output moves. The MCP server's answers equal the
export: 900 consistency lines, 0 differ.

Head and merges: the measured head is `1b3a6bd7`, which merges `main`
(v0.15.0, #1400, #1412, #1416, #1401). The merge of `main` after it
(#1420, the 0.15.0 post-release docs) changes documents only: it
conflicted with this branch in `docs/contribution-map.md` alone,
resolved by keeping this branch's #1384 row and main's #1335 row (which
replaces the #1237 row), and changes no figure here. An earlier merge,
`8e0aa535`, touched three workflow files and no Rust. A final unfiltered
Measure of the pushed head `96baaafe` (`-f base=main -f nordic=true -f
r2025=true -f holdout=true`) is
[41982867204](https://github.com/DrunkOnJava/rvt-rs/actions/runs/41982867204),
registered with the watcher and not read when this was written.

Measured limits, all in RE-337 section 5:

- Revit's end steps up and follows a wall at each height by a join order
that is not read, so the added end is a bound by the geometry the pass
reads, and "no wall is drawn above Revit's at an added end" is a
measured result on the four walls, not a derived one. The steps above
the block are not drawn; 2057668 as built goes five points under
Revit's.
- Walls 2058499 and 2058501 as built keep their ends 0.31 ft short of
Revit's: no footing covers the longer plan and their base is not cut
(before and after). A footing that covers a wall's plan in part is the
follow-up.
- Walls 2058499 and 2058501 at permit are not reached: the wall beneath
them is drawn with a stepped profile, so they stay 0.0439 ft off; the
skip is counted.
- No measured wall exercises: a stepped-top wall beneath whose lowest
underside is at or below the candidate's base (its higher pieces are not
checked against the block); two candidates at one corner; a candidate
with no base join; the `BodyEndSource` arm of `is_stepped` in
`wall_cut_openings.rs`, which only `finish_wall_ends` reaches; the
refusal reasons `base_cut_lost_on_extended_plan`,
`walls_beneath_reach_the_end_at_different_faces` and
`wall_stands_in_the_added_end`; `finish_wall_ends` (a wall with no base
cut); the Level branch of the blocks; the high end of a wall; walls
along x; an end reaching the wall's full height (and so the value
`wall_end_extended_to_base_wall`); the plane-offset term of the opening
shift. Nor does a beneath wall whose top a floor cut in steps over only
part of its plan (the block stops at the lowest underside, 180.6102 ft
for 1493966, where Revit's step at permit is 182.087 ft), a beneath wall
drawn as another kind of solid is neither reached nor refused (an
uncounted skip), and a wall standing in the added end that the pass does
not read (turned off a quarter turn, or a solid of another kind) does
not stop the block.
- A wall with one end drawn and the other kept carries `BodyEndSource`
and `BodyEndRefusal` both; `JoinTrimStart` and `JoinTrimEnd` stay the
record's once `BodyEndSource` is set (documented in
`docs/export-diagnostics.md`).
- Earlier heads are not evidence for the rule: the full prism with the
slid openings (`33529d0b`), the block to the wall beneath's top
(`1b417c45`, 2057670 over-drawn), the block stopped below walls in its
way with the pass moved after the tops (`74f5ee37`, Measure 41964576550,
which lost the permit refusals of 2058499 and 2058501 because a wall
beneath with a stepped top and a profile of its own was not read; fixed
in `0f80699b`), the rule without the join-trim condition (Measure
41944433297, which moved a Snowdon Towers soffit wall to 0.1016 m longer
than Revit's export, local only) and the rule that also drew 2058499 and
2058501 as built (Measure 41947542271, their volume 4.5 to 6.9 ft3 over
Revit's).

- [ ] `tools/check-local.sh` passes: not run locally (no local builds);
CI is the gate
- [x] Verified end to end on real Revit files: the BIM4LCA office as
built and at permit (Revit 24.0.5 IFC4 exports, CC BY-SA 4.0), against
Revit's own export, with the commands and the scorers in RE-337
- [x] IFC exporter touched: Core Interior's IFC is byte-identical to
`main`, so the witness observations do not move
- [ ] Performance change: N/A

## Audit-honesty checklist

- [x] Docs reflect the current state after this PR (support matrix,
contribution map, reconnaissance addendum, diagnostics reference and
schema, RE-336 pointer)
- [x] A changelog fragment under `changelog.d/fixed/`
- [x] A new limitation is documented here, in RE-337 section 5 and in
the `extend_wall_ends` doc comment
- [x] No emojis, private paths or personal addresses in committed files
- [x] Reverse-engineering finding: report RE-337 with the bytes, what
was tried and dropped, and reproduce commands; the probe is
`probe_1067_native_dump` (its `JoinEndGStep` and `GLine` lines)

## Legal and contribution hygiene

- [x] Apache-2.0
- [x] No Autodesk proprietary source, decompiled internals or NDA
content: public byte observations and Revit's own IFC4 exports only
- [x] No new fixtures

## Breaking changes

None. Two new element-record properties on the two office walls above,
`BodyEndSource` with the new labelled value
`wall_end_to_base_wall_upper_step_omitted` (and
`wall_end_extended_to_base_wall`, which no measured wall carries) and
`EndCoverElementId`, and `BodyEndRefusal` on two more at each office
file; a new field `exported.wall_end_refusals` (default empty) and a new
decision reason `wall_end_extension_refused`; two MCP tool descriptions
list it (contract synced).

## Screenshots or output samples

RE-337 section 5.

## Related issues

Refs #1396. The done-when is met for 2057668 and 2057670 on both files
and for no other wall's length or base moving; it is not met for 2058499
and 2058501 at permit.
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.

MCP E2E: validate every tool answer against its own output schema

1 participant