You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(mcp): address review correctness gaps + tighten test isolation
Five real issues from review against the WML schema graph; one cheap
DX win folded in.
Issue 1 - lookupSymbol returned local-only symbols by qname.
After per-owner scoping landed, lookupElement("w:tblGrid") could
return either CT_TblGridBase or CT_TblGrid depending on which row
postgres picked first. Fixed: lookupSymbol now filters
parent_symbol_id IS NULL, so it only returns top-level symbols
addressable by qname. Local elements are reachable through
getChildren on their owning type.
Issues 3 + 4 - getAttributes mishandled inheritance.
complexContent/restriction inherits attribute uses per XSD
§3.4.2.2; only `use="prohibited"` drops them. The previous code
walked the base only for `extension`, so every WML *Change type
built on a restriction reported zero base attrs (id, author, date
silently missing). The walk order also had base attrs emitted
first, making the older docstring claim about "derived wins" wrong
in practice. Fixed: derived attrs (and their attributeGroup refs)
emit first, then the base is walked for both extension AND
restriction; seenAttrs dedup makes derived redeclarations win.
Two new tests pin both behaviors with a CT_TrackedBase /
CT_TrackedRestricted / CT_OverrideDerived fixture.
Issue 5 - stale unscoped local symbols on dev DBs.
The migration that introduced parent_symbol_id never purged the
pre-migration parent-NULL collapsed rows, so re-ingest left them
alongside the new per-owner symbols. Fixed: ingest now purges
everything this source previously wrote at the start of the
transaction, then rewrites. Non-cascading FKs
(xsd_inheritance_edges.base_symbol_id and friends) are cleaned
explicitly first. Idempotency test updated to reflect the new
semantics: every stat equals first.X across re-runs and DB row
counts stay stable.
Issue 2 - tests TRUNCATE through DATABASE_URL.
A developer with DATABASE_URL pointed at Neon could wipe their
schema graph by running `bun test`. Fixed: tests now require
TEST_DATABASE_URL (no fallback) and refuse to run unless the
hostname is local. Shared guard at tests/test-db.ts; package.json
test script defaults TEST_DATABASE_URL to local Postgres.
DX - ooxml_children's group fallback inlined a 28-line copy of
lookupSymbol. Replaced with a 4-line lookupSymbol("group", ...)
call, and dropped a dead-code branch in getChildrenRecursive that
re-set source="inherited" on entries the recursive call had
already labeled.
44/0 across db / ingest / mcp-server.
Copy file name to clipboardExpand all lines: package.json
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -29,7 +29,7 @@
29
29
"xsd:fetch": "bun scripts/ingest-xsd/fetch.ts",
30
30
"xsd:ingest": "bun scripts/ingest-xsd/ingest.ts",
31
31
"ooxml:call": "bun scripts/ooxml-call.ts",
32
-
"test": "bun test tests/db/ && bun test tests/ingest-xsd/ && bun test tests/mcp-server/"
32
+
"test": "export TEST_DATABASE_URL=${TEST_DATABASE_URL:-postgresql://postgres:postgres@localhost:5432/ecma_spec} && bun test tests/db/ && bun test tests/ingest-xsd/ && bun test tests/mcp-server/"
0 commit comments