Commit 99d149f
committed
fix(mcp): correct inheritance order, compositor flattening, and nested attributeGroup walk
Three Phase 4 query bugs surfaced by review against real WML schemas.
Each one would have produced wrong structural answers from the new tools
before the dogfood window even opened.
P2 - Inheritance ordering for complexContent/extension.
XSD says base content comes before the extension's own content
(e.g. CT_PPr extends CT_PPrBase: pStyle and friends from base, then
rPr/sectPr from the extension). The old code walked the chain self-
first, so ooxml_children("w:pPr") would have surfaced the extension's
rPr/sectPr ahead of inherited pStyle. complexContent/restriction is
now also handled correctly: derived REPLACES base content, so the
base is no longer included for restriction relations.
P2 - Compositor flattening across nested particles.
order_index is local to each compositor. The old query joined
child_edges + group_edges across ALL compositors of a type and sorted
by order_index alone, so a nested choice's children (which restart at
order 0) sorted before later siblings of the outer sequence. WML's
CT_Object would have reported the inner choice's first child before
drawing. Fixed with a recursive walkCompositor that does DFS through
parent_compositor_id, emitting children in true document order. Each
ChildEdge now carries a compositorPath like
["sequence(1..1)", "choice(0..unbounded)"] for downstream rendering.
P2 - Recursive attributeGroup refs.
The previous code only fetched direct xsd_attr_edges from a referenced
group, not the group's own xsd_group_edges with ref_kind='attributeGroup'.
VML's AG_AllCoreAttributes -> AG_CoreAttributes -> AG_Id/AG_Style chain
would have lost most attributes. Now collectAttrsFromAttributeGroup
recurses with a visited-set guard against cycles, so nested
attributeGroup chains unfold completely.
Tests:
- 3 new query-layer tests cover each fix path against fixtures:
CT_DerivedExtended verifies extension order, CT_NestedOrder verifies
nested compositor flatten, CT_NestedAttrUser verifies nested
attributeGroup chain.
- Fixture main.xsd grows: CT_BaseWithChildren / CT_DerivedExtended /
CT_NestedOrder / AG_Inner / AG_Outer / CT_NestedAttrUser. Existing
ingest counts updated to match.
Test infra: bun's default 5s timeout was tight for the WML smoke ingest
on a busy DB; bumped that test to 30s. test runner now sequences the
three test directories so the WML smoke and the fixture-ingest tests do
not race for the same connection pool.
39 / 0 across db / ingest / mcp-server.1 parent 7b0898c commit 99d149f
8 files changed
Lines changed: 441 additions & 189 deletions
File tree
- apps/mcp-server/src
- scripts
- tests
- ingest-xsd
- fixtures
- mcp-server
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
7 | 7 | | |
8 | 8 | | |
9 | 9 | | |
10 | | - | |
11 | | - | |
12 | | - | |
13 | | - | |
14 | | - | |
15 | | - | |
| 10 | + | |
16 | 11 | | |
17 | 12 | | |
18 | 13 | | |
| |||
0 commit comments