@kruschdev/pascal-mep-kernel 0.1.0 → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,30 +1,87 @@
1
1
  # `@kruschdev/pascal-mep-kernel`
2
2
 
3
- Shared zero-dependency, framework-free TypeScript kernel for Pascal Editor MEP and Structural plugins (`@kruschdev/pascal-plugin-structural`, `@kruschdev/pascal-plugin-plumbing`, `@kruschdev/pascal-plugin-hvac`, and `@kruschdev/pascal-plugin-electrical`).
3
+ [![License: MIT](https://img.shields.io/badge/License-MIT-amber.svg)](./LICENSE)
4
+ [![npm version](https://img.shields.io/npm/v/@kruschdev/pascal-mep-kernel?color=cb3837)](https://www.npmjs.com/package/@kruschdev/pascal-mep-kernel)
5
+ [![Zero Dependencies](https://img.shields.io/badge/Dependencies-0-10b981.svg)](./package.json)
6
+ [![Kernel Tests](https://img.shields.io/badge/Tests-169%2F169_Passing-22c55e.svg)](./src/__tests__)
7
+ [![Full Suite](https://img.shields.io/badge/Full_Suite-658%2F658_Passing-22c55e.svg)](#6-plugin-pascal-mep-surfaces--catalog-ecosystem)
8
+ [![Purity Gate](https://img.shields.io/badge/Purity_Gate-5%2F5_Framework--Free-38bdf8.svg)](./scripts/check-purity.ts)
9
+
10
+ A zero-dependency, framework-free TypeScript spatial anatomy, legal-cavity routing, and declarative code constraint kernel shared across my [Pascal Editor](https://github.com/pascalorg/editor) Structural, MEP, and Architectural Surfaces plugins.
11
+
12
+ 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.
13
+
14
+ ![Aymeric House Finished Architecture vs 4-Trade Coordinated MEP Cutaway](./assets/social-preview.png)
15
+
16
+ ## Aymeric House 4-Trade Cutaway Showcase (Recorded Live in Pascal Editor)
17
+
18
+ ![Live Pascal Editor Cutaway Showcase on Aymeric House: Finished Two-Story Architecture peeling into Framing X-Ray and layering Structural (IRC), Plumbing (IPC), Dual-Wing HVAC (IMC), and Electrical (NEC) to 1,412 coordinated nodes with 0/0/0/0 audit errors](./assets/aymeric-house-4trade-cutaway.gif)
19
+
20
+ **[Watch 4-Trade Deep-Dive Walkthrough w/ Breaker Box & BOMs (`assets/aymeric-house-4trade-deepdive-x.mp4`)](./assets/aymeric-house-4trade-deepdive-x.mp4)** · **[Cutaway Showcase (`assets/aymeric-house-4trade-cutaway.mp4`)](./assets/aymeric-house-4trade-cutaway.mp4)** · **[Media Kit](./docs/MEDIA-KIT.md)** · **[Deep-Dive Script](./docs/DEEPDIVE-SCRIPT.md)**
21
+
22
+ 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**.
23
+
24
+ ## 6-Plugin Pascal MEP, Surfaces & Catalog Ecosystem
25
+
26
+ 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`:
27
+
28
+ | Priority | Plugin | Standards | Unit Tests | Role in Ecosystem |
29
+ |---|---|---|---|---|
30
+ | **Core** | [`@kruschdev/pascal-mep-kernel`](https://github.com/kruschdev/pascal-mep-kernel) | 3-Layer Engine | `169 / 169` | Spatial anatomy, legal-cavity router, declarative rule evaluator |
31
+ | **#1** | [`@kruschdev/pascal-plugin-structural`](https://github.com/kruschdev/pascal-plugin-structural) | IRC / AWC NDS / AISC | `104 / 104` | Framing skeleton, engineered beams/columns, connectors, fire blocking |
32
+ | **#2** | [`@kruschdev/pascal-plugin-plumbing`](https://github.com/kruschdev/pascal-plugin-plumbing) | IPC / UPC / IFGC | `79 / 79` | Gravity-sloped DWV, dry vents, PEX manifolds, fuel gas, dryer vents |
33
+ | **#3** | [`@kruschdev/pascal-plugin-hvac`](https://github.com/kruschdev/pascal-plugin-hvac) | IMC / Manual J-D-S / IECC | `95 / 95` | Dual-wing split/mini-split HVAC, trunks, ERV, exhausts, condensate |
34
+ | **#4** | [`@kruschdev/pascal-plugin-electrical`](https://github.com/kruschdev/pascal-plugin-electrical) | NEC / NFPA 72 | `135 / 135` | Panels, 3D cover-off interior, circuits, opening-safe & courtyard-safe routing |
35
+ | **#5** | [`@kruschdev/pascal-plugin-surfaces`](https://github.com/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 |
36
+ | **Catalog** | [`@kruschdev/pascal-plugin-catalog`](https://github.com/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 |
4
37
 
5
38
  ## Architecture (3 Layers)
6
39
 
7
40
  1. **Layer 1: Shared Cross-Trade Spatial Anatomy (`@kruschdev/pascal-mep-kernel/anatomy`)**
8
- - `WeakMap`-memoized `compileBuildingAnatomy(nodes)` so all four trades observe the exact same building geometry:
41
+ - `WeakMap`-memoized `compileBuildingAnatomy(nodes)` so all four trades observe identical building geometry in O(1) amortized lookups.
9
42
  - Story and level hierarchy (`resolveNodeLevelId`, `belongsToLevel`, `compareLevelsVertically`, `resolveLevelHeightM`, `isGroundOrLowestWalledLevel`, `isHighestWalledLevelInBuilding`, `findImmediateLowerWalledLevel`) ranking explicit `level` ordinal before `baseElevation`.
10
43
  - 7-type canonical roof shell (`flat`, `shed`, `gable`, `hip`, `dutch`, `mansard`, `conical`) with multi-hop parent `roof` transform accumulation, per-segment spatial adoption, and upper-wing seating.
11
- - Unified wall and opening extraction (both native `door`/`window` nodes and wall-attached `item` openings) with unclamped `rawSillYM` (supporting floor-to-ceiling storefront glass), framed `framedSillYM`, and exact 3D `OrientedPrismY` keepout prisms.
12
- - Concave building footprint enclosure (`pointInPolygon2D`, planar half-edge bounded faces, 16-ray fallback, NFD-normalized room polygons, footprint clustering).
44
+ - Unified wall and opening extraction (native `door`/`window` nodes plus wall-attached `item` openings) with unclamped `rawSillYM` for floor-to-ceiling storefront glass, framed `framedSillYM`, and exact 3D `OrientedPrismY` keepout prisms.
45
+ - Concave building footprint enclosure (`pointInPolygon2D`, planar half-edge bounded faces, 16-ray fallback, NFD-normalized multilingual room polygons, outdoor courtyard exclusion, and footprint clustering).
13
46
  - Cross-trade spatial occupancy grid (`TradeOccupancyGrid`, exact rotated OBB beam/column clash detection, `resolveMepRunExtents`, and strict trade-priority ordering `structural < plumbing < hvac < electrical`).
14
47
 
15
48
  2. **Layer 2: Legal-Space-First Routing Graph (`@kruschdev/pascal-mep-kernel/router`)**
16
49
  - `compileLegalCavityGraph` builds 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.
17
- - `routeInLegalCavities` solves constrained shortest paths (`orthogonal`, `euclidean-cavity`, `gravity-slope`, and `non-descending-vent`) with `TradeOccupancyGrid` reservation.
50
+ - `routeInLegalCavities` solves constrained shortest paths across `orthogonal`, `euclidean-cavity`, `gravity-slope`, and `non-descending-vent` modes with `TradeOccupancyGrid` reservation and cumulative bend budgets.
18
51
 
19
52
  3. **Layer 3: Single-Source Declarative Code Rule Engine (`@kruschdev/pascal-mep-kernel/rules`)**
20
- - Typed `DeclarativeRule` schema and dual-projection evaluator (`filterLegalCandidates` for placement/routing generators and `evaluateDeclarativeRules` for live compliance auditors) guaranteeing placement thresholds are never looser than audit thresholds (`effectivePlacementThreshold` + `validateRuleTable`).
53
+ - Typed `DeclarativeRule` schema and dual-projection evaluator (`filterLegalCandidates` for placement/routing generators and `evaluateDeclarativeRules` for live compliance auditors).
54
+ - Enforces placement-vs-audit soundness (`effectivePlacementThreshold` + `validateRuleTable`) so placement rules are never looser than audit rules.
55
+
56
+ ## Installation and Subpath Exports
57
+
58
+ ```bash
59
+ npm install @kruschdev/pascal-mep-kernel
60
+ # or
61
+ bun add @kruschdev/pascal-mep-kernel
62
+ ```
63
+
64
+ The 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.
65
+
66
+ | Subpath | Purpose | Runtime Constraints |
67
+ |---|---|---|
68
+ | `@kruschdev/pascal-mep-kernel` | Unified barrel re-exporting types, anatomy, router, and rules | Zero deps, zero React/Three/`@pascal-app/*`/`node:*` |
69
+ | `@kruschdev/pascal-mep-kernel/types` | Canonical `Vec2`, `Vec3`, `OrientedPrismY`, `SceneNodeLike`, and trade priority types | Pure TypeScript |
70
+ | `@kruschdev/pascal-mep-kernel/anatomy` | `compileBuildingAnatomy`, roof shell, openings, concave footprints, `TradeOccupancyGrid` | Pure TypeScript |
71
+ | `@kruschdev/pascal-mep-kernel/router` | `compileLegalCavityGraph`, `routeInLegalCavities`, gravity/vent/orthogonal/cavity modes | Pure TypeScript |
72
+ | `@kruschdev/pascal-mep-kernel/rules` | `DeclarativeRule` schema, `validateRuleTable`, `filterLegalCandidates`, `evaluateDeclarativeRules` | Pure TypeScript |
73
+
74
+ ## Corpus and Suite Verification
21
75
 
22
- ## Verification
76
+ - **Unit Tests**: `169 / 169` kernel tests (`135,888` assertions) and `658 / 658` tests across the full 7-repo stack (`158,984` assertions, `0` failures).
77
+ - **Boundary Purity**: `5 / 5` kernel subpaths verified 100% framework-free and zero-dependency (`34 / 34` entry boundary gates across the full stack).
78
+ - **Real-World Corpus**: Audited across `246` real public Pascal buildings (`145 / 246` completely `0/0/0/0` clean across all four trades, `PLB 245/246`, `HVC 222/246`, `ELC 198/246`, `STR 167/246`, `0` crashes, `0` NaN geometry outputs).
23
79
 
24
80
  ```bash
25
- bun run check # tsc --noEmit && bun test && bun run check:purity && bun run build
81
+ bun install
82
+ bun run check # tsc --noEmit && bun test src && bun run check:purity && bun run build
26
83
  ```
27
84
 
28
85
  ## License
29
86
 
30
- MIT
87
+ MIT. Created by Kevin Ruschman ([@kruschdev](https://github.com/kruschdev)).
@@ -71,6 +71,10 @@ export type FootprintPointOptions = {
71
71
  export type FootprintSegmentOptions = FootprintPointOptions & {
72
72
  /** Margin (meters) from an already-exterior endpoint to ignore when checking outdoor void crossing. */
73
73
  readonly skipExteriorEndpointMarginM?: number;
74
+ /** Whether `skipExteriorEndpointMarginM` applies to the start endpoint (default `true`). */
75
+ readonly allowStartExteriorSkip?: boolean;
76
+ /** Whether `skipExteriorEndpointMarginM` applies to the end endpoint (default `true`). */
77
+ readonly allowEndExteriorSkip?: boolean;
74
78
  /** Sampling step along XZ segment in meters. */
75
79
  readonly stepM?: number;
76
80
  };
@@ -19,9 +19,15 @@ export type BuildingAnatomy = {
19
19
  readonly levelIds: readonly string[];
20
20
  readonly getLevelHeightM: (levelId: string | null, opts?: ResolveLevelHeightOptions) => number;
21
21
  readonly getWalls: (levelId: string | null, opts?: ExtractCanonicalWallsOptions) => readonly CanonicalWall[];
22
- readonly getOpeningPrisms: (levelId: string | null) => readonly TaggedOpeningPrism[];
22
+ readonly getOpeningPrisms: (levelId: string | null, opts?: {
23
+ readonly includeHidden?: boolean;
24
+ readonly includeUnparented?: boolean;
25
+ }) => readonly TaggedOpeningPrism[];
23
26
  readonly getRoofShell: (levelId: string | null, opts?: CompileRoofShellOptions) => LevelRoofShell;
24
- readonly getFootprint: (levelId: string | null) => LevelFootprintModel;
27
+ readonly getFootprint: (levelId: string | null, opts?: {
28
+ readonly includeHidden?: boolean;
29
+ readonly includeUnparented?: boolean;
30
+ }) => LevelFootprintModel;
25
31
  readonly createOccupancyGrid: (levelId: string | null, opts: ExtractTradeOccupancyOptions) => TradeOccupancyGrid;
26
32
  };
27
33
  /**
@@ -57,8 +57,8 @@ import {
57
57
  extractCanonicalRoofSegments2,
58
58
  compileLevelRoofShell2,
59
59
  compileBuildingAnatomy2
60
- } from "../chunk-2e23cyn0.js";
61
- import"../chunk-jfzqztgh.js";
60
+ } from "../chunk-kmtew7g8.js";
61
+ import"../chunk-yd3hcm7n.js";
62
62
  export {
63
63
  ELECTRICAL_CONDUIT_HALF_OD_M2 as ELECTRICAL_CONDUIT_HALF_OD_M,
64
64
  PLUMBING_PIPE_HALF_OD_M2 as PLUMBING_PIPE_HALF_OD_M,
@@ -63,7 +63,10 @@ export declare function areLevelsInSameBuilding(nodes: Readonly<Record<string, S
63
63
  export declare function levelSortOrder(level: SceneNodeLike | undefined): number;
64
64
  /**
65
65
  * Strict vertical comparator between two level nodes (`< 0` means `a` is below `b`).
66
- * Ranks `level` ordinal first, breaking ties with `elevation`, then `baseElevation`, then `index`.
66
+ * Uses a canonical quantized 4-tuple `[levelSortOrder, elevation, baseElevation, index]`
67
+ * so ordering is strictly transitive and overflow-free (a valid strict weak ordering for
68
+ * `Array.prototype.sort`) while always ranking explicit `level` ordinal before
69
+ * `elevation` / `baseElevation` / `index` (`INV-MEP-04`).
67
70
  */
68
71
  export declare function compareLevelsVertically(a: SceneNodeLike | undefined, b: SceneNodeLike | undefined): number;
69
72
  /** True when a level represents a below-grade basement story (`level < 0` or elevation `< -0.5 m`). */
@@ -80,7 +83,8 @@ export declare function resolveWallHeightM(nodes: Readonly<Record<string, SceneN
80
83
  /**
81
84
  * Single authoritative level height resolver across all 4 trades.
82
85
  * Prefers max explicit wall height in `(1.5, 12]` on the level, then `level.height` in `(1.5, 12]`,
83
- * then `defaultHeightM` (`2.7 m`), optionally clamped at `minClampM`.
86
+ * then hidden wall height in `(1.5, 12]` (preserving Framing X-Ray height when drywall is hidden
87
+ * and `level.height` is omitted), then `defaultHeightM` (`2.7 m`), optionally clamped at `minClampM`.
84
88
  */
85
89
  export declare function resolveLevelHeightM(nodes: Readonly<Record<string, SceneNodeLike>>, levelId?: string | null | undefined, options?: ResolveLevelHeightOptions): number;
86
90
  /**
@@ -67,7 +67,9 @@ export type LevelRoofShell = {
67
67
  * Determine whether a wall-less roof level should be adopted onto `targetLevelId`
68
68
  * (the highest walled level in the same building at or below `roofLevel`).
69
69
  */
70
- export declare function shouldAdoptWallLessRoofLevel(nodes: Readonly<Record<string, SceneNodeLike>>, targetLevelId: string, roofLevel: SceneNodeLike): boolean;
70
+ export declare function shouldAdoptWallLessRoofLevel(nodes: Readonly<Record<string, SceneNodeLike>>, targetLevelId: string, roofLevel: SceneNodeLike, opts?: {
71
+ readonly includeHidden?: boolean;
72
+ }): boolean;
71
73
  /**
72
74
  * Per-segment wall-less roof level adoption: picks the highest walled level at or below
73
75
  * `roofLevel` whose visible walls overlap the segment's XZ bounding box (padded by `0.8 m`),
@@ -76,7 +78,9 @@ export declare function shouldAdoptWallLessRoofLevel(nodes: Readonly<Record<stri
76
78
  * Ensures 1-story wing roofs placed on a wall-less Roof level seat onto the 1st-floor wing
77
79
  * walls instead of floating at 2nd-floor eave elevation.
78
80
  */
79
- export declare function shouldAdoptRoofSegmentOntoLevel(nodes: Readonly<Record<string, SceneNodeLike>>, targetLevelId: string, roofLevel: SceneNodeLike, segCenterX: number, segCenterZ: number, halfX: number, halfZ: number): boolean;
81
+ export declare function shouldAdoptRoofSegmentOntoLevel(nodes: Readonly<Record<string, SceneNodeLike>>, targetLevelId: string, roofLevel: SceneNodeLike, segCenterX: number, segCenterZ: number, halfX: number, halfZ: number, opts?: {
82
+ readonly includeHidden?: boolean;
83
+ }): boolean;
80
84
  /**
81
85
  * Evaluate the roof-plane surface elevation `y` of a single `CanonicalRoofSegment` at world `(wx, wz)`,
82
86
  * or `null` if `(wx, wz)` lies outside the segment's plan footprint (including eave overhang + `footprintPadM`).