A zero-dependency, framework-free TypeScript spatial anatomy, legal-cavity routing, and declarative code constraint kernel shared across my Pascal Editor Structural, MEP, and Architectural Surfaces plugins.
I built @kruschdev/pascal-mep-kernel so Structural (IRC), Plumbing (IPC), HVAC (IMC), Electrical (NEC), and Architectural Surfaces (IRC/GA-214/IECC/TCNA) all observe the exact same building geometry, route strictly inside legal building cavities, and enforce identical placement and audit thresholds from one single source of truth.
Watch 4-Trade Deep-Dive Walkthrough w/ Breaker Box & BOMs (assets/aymeric-house-4trade-deepdive-x.mp4) · Cutaway Showcase (assets/aymeric-house-4trade-cutaway.mp4) · Media Kit · Deep-Dive Script
On Aymeric House (two stories, 21 zones, U-shaped open Lanai courtyard with pool, pitched wing roofs, and central flat roof), one coordinated pass produces 1,412 nodes with 0 / 0 / 0 / 0 errors, zero ducts or electrical cables crossing the courtyard, and zero wires cutting any of the 30 door and window openings.
All six MIT-licensed external plugins coordinate in real-world jobsite priority order (1 -> 2 -> 3 -> 4 -> 5) alongside the SolidCraft B-rep Manufacturer SKU Catalog on top of @kruschdev/pascal-mep-kernel:
| Priority | Plugin | Standards | Unit Tests | Role in Ecosystem |
|---|---|---|---|---|
| Core | @kruschdev/pascal-mep-kernel |
3-Layer Engine | 169 / 169 |
Spatial anatomy, legal-cavity router, declarative rule evaluator |
| #1 | @kruschdev/pascal-plugin-structural |
IRC / AWC NDS / AISC | 104 / 104 |
Framing skeleton, engineered beams/columns, connectors, fire blocking |
| #2 | @kruschdev/pascal-plugin-plumbing |
IPC / UPC / IFGC | 79 / 79 |
Gravity-sloped DWV, dry vents, PEX manifolds, fuel gas, dryer vents |
| #3 | @kruschdev/pascal-plugin-hvac |
IMC / Manual J-D-S / IECC | 95 / 95 |
Dual-wing split/mini-split HVAC, trunks, ERV, exhausts, condensate |
| #4 | @kruschdev/pascal-plugin-electrical |
NEC / NFPA 72 | 135 / 135 |
Panels, 3D cover-off interior, circuits, opening-safe & courtyard-safe routing |
| #5 | @kruschdev/pascal-plugin-surfaces |
IRC / GA-214 / IECC / TCNA / NWFA / NSI | 57 / 57 |
All 15 surface & envelope domains, Pool Surfaces, 44 recipes, 236 SKUs, 60 procedural GLBs + 28 B-rep swatches, 7 3D cutaways |
| Catalog | @kruschdev/pascal-plugin-catalog |
CSI MasterFormat / SolidCraft B-Rep | 19 / 19 |
606+ real-world manufacturer B-rep SKUs across 9 trades & 108 brands, + Real SKU registration, 16 Site-Built raw material takeoffs |
-
Layer 1: Shared Cross-Trade Spatial Anatomy (
@kruschdev/pascal-mep-kernel/anatomy)WeakMap-memoizedcompileBuildingAnatomy(nodes)so all four trades observe identical building geometry in O(1) amortized lookups.- Story and level hierarchy (
resolveNodeLevelId,belongsToLevel,compareLevelsVertically,resolveLevelHeightM,isGroundOrLowestWalledLevel,isHighestWalledLevelInBuilding,findImmediateLowerWalledLevel) ranking explicitlevelordinal beforebaseElevation. - 7-type canonical roof shell (
flat,shed,gable,hip,dutch,mansard,conical) with multi-hop parentrooftransform accumulation, per-segment spatial adoption, and upper-wing seating. - Unified wall and opening extraction (native
door/windownodes plus wall-attacheditemopenings) with unclampedrawSillYMfor floor-to-ceiling storefront glass, framedframedSillYM, and exact 3DOrientedPrismYkeepout prisms. - Concave building footprint enclosure (
pointInPolygon2D, planar half-edge bounded faces, 16-ray fallback, NFD-normalized multilingual room polygons, outdoor courtyard exclusion, and footprint clustering). - Cross-trade spatial occupancy grid (
TradeOccupancyGrid, exact rotated OBB beam/column clash detection,resolveMepRunExtents, and strict trade-priority orderingstructural < plumbing < hvac < electrical).
-
Layer 2: Legal-Space-First Routing Graph (
@kruschdev/pascal-mep-kernel/router)compileLegalCavityGraphbuilds navigable cavities by construction: solid wall stud bays minus 3D door/window/header keepout prisms, enclosed overhead plenums and attics clamped beneath roof surfaces, and under-slab/crawlspace trenches.routeInLegalCavitiessolves constrained shortest paths acrossorthogonal,euclidean-cavity,gravity-slope, andnon-descending-ventmodes withTradeOccupancyGridreservation and cumulative bend budgets.
-
Layer 3: Single-Source Declarative Code Rule Engine (
@kruschdev/pascal-mep-kernel/rules)- Typed
DeclarativeRuleschema and dual-projection evaluator (filterLegalCandidatesfor placement/routing generators andevaluateDeclarativeRulesfor live compliance auditors). - Enforces placement-vs-audit soundness (
effectivePlacementThreshold+validateRuleTable) so placement rules are never looser than audit rules.
- Typed
npm install @kruschdev/pascal-mep-kernel
# or
bun add @kruschdev/pascal-mep-kernelThe published npm tarball (77 KB) ships precompiled pure ESM + .d.ts with zero runtime dependencies and zero React/JSX, so Next.js, Turbopack, Vite, Bun, and Node hosts can consume it directly without extra transpilePackages configuration.
| Subpath | Purpose | Runtime Constraints |
|---|---|---|
@kruschdev/pascal-mep-kernel |
Unified barrel re-exporting types, anatomy, router, and rules | Zero deps, zero React/Three/@pascal-app/*/node:* |
@kruschdev/pascal-mep-kernel/types |
Canonical Vec2, Vec3, OrientedPrismY, SceneNodeLike, and trade priority types |
Pure TypeScript |
@kruschdev/pascal-mep-kernel/anatomy |
compileBuildingAnatomy, roof shell, openings, concave footprints, TradeOccupancyGrid |
Pure TypeScript |
@kruschdev/pascal-mep-kernel/router |
compileLegalCavityGraph, routeInLegalCavities, gravity/vent/orthogonal/cavity modes |
Pure TypeScript |
@kruschdev/pascal-mep-kernel/rules |
DeclarativeRule schema, validateRuleTable, filterLegalCandidates, evaluateDeclarativeRules |
Pure TypeScript |
- Unit Tests:
169 / 169kernel tests (135,888assertions) and658 / 658tests across the full 7-repo stack (158,984assertions,0failures). - Boundary Purity:
5 / 5kernel subpaths verified 100% framework-free and zero-dependency (34 / 34entry boundary gates across the full stack). - Real-World Corpus: Audited across
246real public Pascal buildings (145 / 246completely0/0/0/0clean across all four trades,PLB 245/246,HVC 222/246,ELC 198/246,STR 167/246,0crashes,0NaN geometry outputs).
bun install
bun run check # tsc --noEmit && bun test src && bun run check:purity && bun run buildMIT. Created by Kevin Ruschman (@kruschdev).

