Skip to content

Commit 99d149f

Browse files
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/mcp.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,7 @@
77
import { createDb } from "./db";
88
import { embedQuery } from "./embeddings";
99
import type { Env } from "./index";
10-
import {
11-
OOXML_TOOL_DEFS,
12-
callOoxmlTool,
13-
isOoxmlTool,
14-
ooxmlToolsEnabled,
15-
} from "./ooxml-tools";
10+
import { callOoxmlTool, isOoxmlTool, OOXML_TOOL_DEFS, ooxmlToolsEnabled } from "./ooxml-tools";
1611

1712
// JSON-RPC types
1813
interface JsonRpcRequest {

0 commit comments

Comments
 (0)