@kruschdev/pascal-mep-kernel 0.0.0-stage → 0.1.0

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/dist/index.js ADDED
@@ -0,0 +1,186 @@
1
+ import {
2
+ TRADE_PRIORITY_RANK2,
3
+ INCHES_TO_METERS2,
4
+ METERS_TO_FEET2,
5
+ FEET_TO_METERS2,
6
+ SQM_TO_SQFT2,
7
+ isVec32,
8
+ toTupleAabb32,
9
+ fromTupleAabb32,
10
+ expandAabb32,
11
+ aabb3Intersects2,
12
+ segmentIntersectsAabb32,
13
+ createOrientedPrismY2,
14
+ segmentIntersectsOrientedPrismY2,
15
+ orientedPrismIntersectsAabb32,
16
+ extractNodeYawRad2,
17
+ polylineLengthM2,
18
+ polylineHorizontalLengthM2,
19
+ countPathBendDegrees2,
20
+ countPathElbows2,
21
+ round22,
22
+ round32,
23
+ round42
24
+ } from "./chunk-jfzqztgh.js";
25
+ import {
26
+ resolveNodeLevelId2,
27
+ belongsToLevel2,
28
+ resolveLevelBuildingId2,
29
+ areLevelsInSameBuilding2,
30
+ levelSortOrder2,
31
+ compareLevelsVertically2,
32
+ isBasementLevel2,
33
+ levelHasWalls2,
34
+ resolveWallHeightM2,
35
+ resolveLevelHeightM2,
36
+ getLowerWalledLevelIds2,
37
+ resolveLowerWalledLevelsSummary2,
38
+ isGroundOrLowestWalledLevel2,
39
+ isHighestWalledLevelInBuilding2,
40
+ findImmediateLowerWalledLevel2,
41
+ classifyOpeningKind2,
42
+ extractCanonicalWallOpenings2,
43
+ extractCanonicalWalls2,
44
+ extractLevelOpeningPrisms2,
45
+ countPathOpeningPrismHits2,
46
+ findNearestWallToPoint2,
47
+ distancePointToSegment2D2,
48
+ pointInPolygon2D2,
49
+ polygonArea2D2,
50
+ polygonAreaAndCentroid2,
51
+ polygonBounds2D2,
52
+ clipSegmentToPolygon2D2,
53
+ extractBoundedWallFaces2,
54
+ isPointEnclosedByWalls2,
55
+ extractBaseRoomPolygons2,
56
+ computeLevelBounds2,
57
+ clusterLevelFootprints2,
58
+ isOutdoorOrUnwalledSlab2,
59
+ compileLevelFootprint2,
60
+ PLUMBING_PIPE_HALF_OD_M2,
61
+ ELECTRICAL_CONDUIT_HALF_OD_M2,
62
+ parseNominalInches2,
63
+ resolveMepRunExtents2,
64
+ extractBeamPrism2,
65
+ extractColumnPrism2,
66
+ getHvacEquipmentPrism2,
67
+ getHvacEquipmentAabb2,
68
+ getHvacPlenumPrism2,
69
+ getHvacPlenumAabb2,
70
+ getPlumbingFixturePrism2,
71
+ getPlumbingFixtureAabb2,
72
+ getPlumbingEquipmentPrism2,
73
+ getPlumbingEquipmentAabb2,
74
+ getElectricalDedicatedSpacePrisms2,
75
+ extractEquipmentPrisms2,
76
+ extractTradeOccupancyObstacles2,
77
+ TradeOccupancyGrid2,
78
+ shouldAdoptWallLessRoofLevel2,
79
+ shouldAdoptRoofSegmentOntoLevel2,
80
+ evaluateRoofSegmentSurfaceY2,
81
+ extractCanonicalRoofSegments2,
82
+ compileLevelRoofShell2,
83
+ compileBuildingAnatomy2
84
+ } from "./chunk-2e23cyn0.js";
85
+ import {
86
+ compileLegalCavityGraph2,
87
+ findLegalWallRiserPier2,
88
+ routeInLegalCavities2
89
+ } from "./chunk-0w98adg9.js";
90
+ import {
91
+ effectivePlacementThreshold2,
92
+ evaluatePlacementCandidate2,
93
+ filterLegalCandidates2,
94
+ evaluateDeclarativeRules2,
95
+ validateRuleTable2
96
+ } from "./chunk-sab5aaa6.js";
97
+ export {
98
+ ELECTRICAL_CONDUIT_HALF_OD_M2 as ELECTRICAL_CONDUIT_HALF_OD_M,
99
+ FEET_TO_METERS2 as FEET_TO_METERS,
100
+ INCHES_TO_METERS2 as INCHES_TO_METERS,
101
+ METERS_TO_FEET2 as METERS_TO_FEET,
102
+ PLUMBING_PIPE_HALF_OD_M2 as PLUMBING_PIPE_HALF_OD_M,
103
+ SQM_TO_SQFT2 as SQM_TO_SQFT,
104
+ TRADE_PRIORITY_RANK2 as TRADE_PRIORITY_RANK,
105
+ TradeOccupancyGrid2 as TradeOccupancyGrid,
106
+ aabb3Intersects2 as aabb3Intersects,
107
+ areLevelsInSameBuilding2 as areLevelsInSameBuilding,
108
+ belongsToLevel2 as belongsToLevel,
109
+ classifyOpeningKind2 as classifyOpeningKind,
110
+ clipSegmentToPolygon2D2 as clipSegmentToPolygon2D,
111
+ clusterLevelFootprints2 as clusterLevelFootprints,
112
+ compareLevelsVertically2 as compareLevelsVertically,
113
+ compileBuildingAnatomy2 as compileBuildingAnatomy,
114
+ compileLegalCavityGraph2 as compileLegalCavityGraph,
115
+ compileLevelFootprint2 as compileLevelFootprint,
116
+ compileLevelRoofShell2 as compileLevelRoofShell,
117
+ computeLevelBounds2 as computeLevelBounds,
118
+ countPathBendDegrees2 as countPathBendDegrees,
119
+ countPathElbows2 as countPathElbows,
120
+ countPathOpeningPrismHits2 as countPathOpeningPrismHits,
121
+ createOrientedPrismY2 as createOrientedPrismY,
122
+ distancePointToSegment2D2 as distancePointToSegment2D,
123
+ effectivePlacementThreshold2 as effectivePlacementThreshold,
124
+ evaluateDeclarativeRules2 as evaluateDeclarativeRules,
125
+ evaluatePlacementCandidate2 as evaluatePlacementCandidate,
126
+ evaluateRoofSegmentSurfaceY2 as evaluateRoofSegmentSurfaceY,
127
+ expandAabb32 as expandAabb3,
128
+ extractBaseRoomPolygons2 as extractBaseRoomPolygons,
129
+ extractBeamPrism2 as extractBeamPrism,
130
+ extractBoundedWallFaces2 as extractBoundedWallFaces,
131
+ extractCanonicalRoofSegments2 as extractCanonicalRoofSegments,
132
+ extractCanonicalWallOpenings2 as extractCanonicalWallOpenings,
133
+ extractCanonicalWalls2 as extractCanonicalWalls,
134
+ extractColumnPrism2 as extractColumnPrism,
135
+ extractEquipmentPrisms2 as extractEquipmentPrisms,
136
+ extractLevelOpeningPrisms2 as extractLevelOpeningPrisms,
137
+ extractNodeYawRad2 as extractNodeYawRad,
138
+ extractTradeOccupancyObstacles2 as extractTradeOccupancyObstacles,
139
+ filterLegalCandidates2 as filterLegalCandidates,
140
+ findImmediateLowerWalledLevel2 as findImmediateLowerWalledLevel,
141
+ findLegalWallRiserPier2 as findLegalWallRiserPier,
142
+ findNearestWallToPoint2 as findNearestWallToPoint,
143
+ fromTupleAabb32 as fromTupleAabb3,
144
+ getElectricalDedicatedSpacePrisms2 as getElectricalDedicatedSpacePrisms,
145
+ getHvacEquipmentAabb2 as getHvacEquipmentAabb,
146
+ getHvacEquipmentPrism2 as getHvacEquipmentPrism,
147
+ getHvacPlenumAabb2 as getHvacPlenumAabb,
148
+ getHvacPlenumPrism2 as getHvacPlenumPrism,
149
+ getLowerWalledLevelIds2 as getLowerWalledLevelIds,
150
+ getPlumbingEquipmentAabb2 as getPlumbingEquipmentAabb,
151
+ getPlumbingEquipmentPrism2 as getPlumbingEquipmentPrism,
152
+ getPlumbingFixtureAabb2 as getPlumbingFixtureAabb,
153
+ getPlumbingFixturePrism2 as getPlumbingFixturePrism,
154
+ isBasementLevel2 as isBasementLevel,
155
+ isGroundOrLowestWalledLevel2 as isGroundOrLowestWalledLevel,
156
+ isHighestWalledLevelInBuilding2 as isHighestWalledLevelInBuilding,
157
+ isOutdoorOrUnwalledSlab2 as isOutdoorOrUnwalledSlab,
158
+ isPointEnclosedByWalls2 as isPointEnclosedByWalls,
159
+ isVec32 as isVec3,
160
+ levelHasWalls2 as levelHasWalls,
161
+ levelSortOrder2 as levelSortOrder,
162
+ orientedPrismIntersectsAabb32 as orientedPrismIntersectsAabb3,
163
+ parseNominalInches2 as parseNominalInches,
164
+ pointInPolygon2D2 as pointInPolygon2D,
165
+ polygonArea2D2 as polygonArea2D,
166
+ polygonAreaAndCentroid2 as polygonAreaAndCentroid,
167
+ polygonBounds2D2 as polygonBounds2D,
168
+ polylineHorizontalLengthM2 as polylineHorizontalLengthM,
169
+ polylineLengthM2 as polylineLengthM,
170
+ resolveLevelBuildingId2 as resolveLevelBuildingId,
171
+ resolveLevelHeightM2 as resolveLevelHeightM,
172
+ resolveLowerWalledLevelsSummary2 as resolveLowerWalledLevelsSummary,
173
+ resolveMepRunExtents2 as resolveMepRunExtents,
174
+ resolveNodeLevelId2 as resolveNodeLevelId,
175
+ resolveWallHeightM2 as resolveWallHeightM,
176
+ round22 as round2,
177
+ round32 as round3,
178
+ round42 as round4,
179
+ routeInLegalCavities2 as routeInLegalCavities,
180
+ segmentIntersectsAabb32 as segmentIntersectsAabb3,
181
+ segmentIntersectsOrientedPrismY2 as segmentIntersectsOrientedPrismY,
182
+ shouldAdoptRoofSegmentOntoLevel2 as shouldAdoptRoofSegmentOntoLevel,
183
+ shouldAdoptWallLessRoofLevel2 as shouldAdoptWallLessRoofLevel,
184
+ toTupleAabb32 as toTupleAabb3,
185
+ validateRuleTable2 as validateRuleTable
186
+ };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Layer 2 — Legal Cavity Graph Compiler (`@kruschdev/pascal-mep-kernel/router`).
3
+ *
4
+ * Compiles a building level's `BuildingAnatomy` into a 3D legal-space-first routing graph
5
+ * (`LegalCavityGraph`) where physical violations are impossible by construction (`INV-MEP-01`, `INV-MEP-06`):
6
+ *
7
+ * 1. Solid Wall Stud-Bay Layer (`under-sill`, `mid-wall`, `top-plate`):
8
+ * - Splits walls at junctions/intersections (`0.25 m` snap) and opening jamb boundaries
9
+ * (`startU - 0.08`, `endU + 0.08` clamped within `[0.03, wall.lengthM - 0.03]`).
10
+ * - Emits solid king-stud riser piers (`WallRiserPier`) where vertical travel
11
+ * `[0.02 .. levelH - 0.04]` has zero intersection with any 3D opening keepout prism.
12
+ * - Emits horizontal & vertical wall edges ONLY when zero 3D opening prisms are intersected
13
+ * and roof clearance holds. Shares vertices at corners/junctions on the same band.
14
+ * 2. Conditioned Overhead Plenum & Attic Layer (`overhead-plenum`, `attic`):
15
+ * - Builds an interior-only 2D grid + room-centroid + pier-projection graph strictly inside
16
+ * `footprint` (`precedence: 'room-first'`) and strictly beneath `roofShell.roofEnvelopeY`.
17
+ * - Connects orthogonal neighbors (plus attic diagonals) ONLY when both `footprint.isSegmentInside`
18
+ * and `roofShell.isPathClearOfRoof` pass, eliminating courtyard bridging and roof pokes.
19
+ * 3. Under-Slab / Crawlspace Trench Layer (`under-slab`):
20
+ * - Emits interior-footprint vertices and orthogonal edges at `subFloorElevationM` (default `-0.35 m`),
21
+ * connected downward from solid wall riser piers.
22
+ *
23
+ * Pure framework-free TypeScript (`INV-MEP-01`): zero React, Three.js, `@pascal-app/*`, Next, Zod, or `node:*`.
24
+ */
25
+ import type { BuildingAnatomy } from '../anatomy';
26
+ import type { CompileCavityGraphOptions, LegalCavityGraph, WallRiserPier } from './types';
27
+ /**
28
+ * Compile a 3D legal-space-first routing graph (`LegalCavityGraph`) for a building level.
29
+ * Every emitted vertex and edge is legal by construction against opening keepout prisms,
30
+ * concave interior footprint boundaries, and the 7-type roof shell (`INV-MEP-01`, `INV-MEP-06`).
31
+ */
32
+ export declare function compileLegalCavityGraph(anatomy: BuildingAnatomy, levelId: string | null, opts?: CompileCavityGraphOptions): LegalCavityGraph;
33
+ /**
34
+ * Find the closest legal solid king-stud riser pier on `wallId` to `desiredT` whose
35
+ * safe vertical span covers `[fromY, toY]` without intersecting any door/window prism.
36
+ */
37
+ export declare function findLegalWallRiserPier(graph: LegalCavityGraph, wallId: string, desiredT: number, fromY: number, toY: number): WallRiserPier | null;
@@ -0,0 +1,11 @@
1
+ /**
2
+ * Layer 2 — Legal-Space-First Routing Graph (`@kruschdev/pascal-mep-kernel/router`).
3
+ *
4
+ * Compiles building anatomy into legal navigable cavities (wall stud bays minus 3D
5
+ * door/window prisms, enclosed overhead plenums clamped below roof surfaces, and
6
+ * under-slab/crawlspace trenches) and solves constrained shortest paths with strict
7
+ * cross-trade occupancy reservation (`INV-MEP-06`, `INV-MEP-07`).
8
+ */
9
+ export type { CavityBand, RoutingPhysicsMode, CavityVertex, CavityEdge, WallRiserPier, CompileCavityGraphOptions, LegalCavityGraph, CavityRouteRequest, CavityRouteResult, } from './types';
10
+ export { compileLegalCavityGraph, findLegalWallRiserPier } from './cavity-graph';
11
+ export { type RouteInLegalCavitiesParams, routeInLegalCavities } from './shortest-path';
@@ -0,0 +1,12 @@
1
+ import {
2
+ compileLegalCavityGraph2,
3
+ findLegalWallRiserPier2,
4
+ routeInLegalCavities2
5
+ } from "../chunk-0w98adg9.js";
6
+ import"../chunk-2e23cyn0.js";
7
+ import"../chunk-jfzqztgh.js";
8
+ export {
9
+ compileLegalCavityGraph2 as compileLegalCavityGraph,
10
+ findLegalWallRiserPier2 as findLegalWallRiserPier,
11
+ routeInLegalCavities2 as routeInLegalCavities
12
+ };
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Layer 2 — Constrained Shortest-Path Solver Over Legal Building Cavities (`@kruschdev/pascal-mep-kernel/router`).
3
+ *
4
+ * Implements `routeInLegalCavities` (`INV-MEP-01`, `INV-MEP-06`, `INV-MEP-07`):
5
+ * 1. Zero-mutation dynamic endpoint port splicing (`from` / `to` -> allowed `LegalCavityGraph` vertices)
6
+ * plus legal direct same-cavity shortcuts.
7
+ * 2. Two-pass constrained A* with a deterministic binary min-heap and direction-bucket bend tracking:
8
+ * - Pass 1 (Hard-Free): strictly rejects obstacle clashes, opening-prism hits, roof violations,
9
+ * outdoor-void excursions, physics-mode violations, and `maxBendDegrees` overruns.
10
+ * - Pass 2 (Degraded Diagnostic Fallback): invoked ONLY if Pass 1 finds no path (e.g., an
11
+ * irreducible blocker around an endpoint), allowing penalized transitions (`+5000` per clash)
12
+ * so the solver never returns empty/NaN and always reports exact `clashObstacleIds` & `ok: false`.
13
+ * 3. Physics-mode post-shaping & strict enforcement:
14
+ * - `'orthogonal'`: collinear compaction, orthogonal/wall-aligned legs, optional `lateralStaggerM`.
15
+ * - `'euclidean-cavity'`: line-of-sight string-pulling inside unobstructed open cavities.
16
+ * - `'gravity-slope'`: strict monotonic downward fall (`y(i) = y(i-1) - horizDist * (minSlopeInPerFt / 12)`),
17
+ * zero uphill segments (`dy <= 0.002`), and exact `slopeInPerFt`.
18
+ * - `'non-descending-vent'`: IPC 905.5 horizontal floor (`>= minHorizontalElevationM`) and
19
+ * IPC 905.2 inverted-U prevention (`<= tieInY`, non-descending).
20
+ * 4. Optional `INV-MEP-07` run reservation on `TradeOccupancyGrid` when `reserveOnCommit === true`.
21
+ *
22
+ * Pure framework-free TypeScript (`INV-MEP-01`): zero React, Three.js, `@pascal-app/*`, Next, Zod, or `node:*`.
23
+ */
24
+ import { type BuildingAnatomy, type TradeOccupancyGrid } from '../anatomy';
25
+ import type { CavityRouteRequest, CavityRouteResult, LegalCavityGraph } from './types';
26
+ export type RouteInLegalCavitiesParams = {
27
+ readonly anatomy: BuildingAnatomy;
28
+ readonly graph: LegalCavityGraph;
29
+ readonly occupancy: TradeOccupancyGrid;
30
+ readonly request: CavityRouteRequest;
31
+ };
32
+ /**
33
+ * Route an MEP run inside the pre-compiled `LegalCavityGraph` with dynamic zero-mutation endpoint
34
+ * splicing, two-pass constrained A* (hard-free -> degraded diagnostic fallback), physics-mode
35
+ * post-shaping, full spatial audit, and optional `TradeOccupancyGrid` reservation (`INV-MEP-07`).
36
+ */
37
+ export declare function routeInLegalCavities(params: RouteInLegalCavitiesParams): CavityRouteResult;
@@ -0,0 +1,108 @@
1
+ /**
2
+ * Layer 2 — Legal-Space-First Routing Graph Types (`@kruschdev/pascal-mep-kernel/router`).
3
+ * Shared contract between `cavity-graph.ts` (cavity compiler) and `shortest-path.ts` (constrained solver).
4
+ */
5
+ import type { TradeId, Vec3 } from '../types';
6
+ export type CavityBand = 'under-sill' | 'mid-wall' | 'top-plate' | 'overhead-plenum' | 'attic' | 'under-slab' | 'crawlspace';
7
+ export type RoutingPhysicsMode = 'orthogonal' | 'euclidean-cavity' | 'gravity-slope' | 'non-descending-vent';
8
+ export type CavityVertex = {
9
+ readonly id: number;
10
+ readonly pos: Vec3;
11
+ readonly band: CavityBand;
12
+ readonly wallId?: string;
13
+ readonly wallT?: number;
14
+ readonly isRiserPier?: boolean;
15
+ readonly maxClearY?: number;
16
+ };
17
+ export type CavityEdge = {
18
+ readonly to: number;
19
+ readonly lengthM: number;
20
+ readonly horizontalLengthM: number;
21
+ readonly band: CavityBand;
22
+ readonly isWallEdge: boolean;
23
+ readonly isVerticalTransition: boolean;
24
+ readonly wallId?: string;
25
+ readonly baseCostWeight: number;
26
+ };
27
+ export type WallRiserPier = {
28
+ readonly wallId: string;
29
+ readonly t: number;
30
+ readonly x: number;
31
+ readonly z: number;
32
+ readonly minSafeY: number;
33
+ readonly maxSafeY: number;
34
+ };
35
+ export type CompileCavityGraphOptions = {
36
+ /** Clearance below roof surface in meters. Default: `0.14`. */
37
+ readonly roofClearanceM?: number;
38
+ /** Vertical half-extent of the routed run (e.g. half duct height or pipe radius). Default: `0.02`. */
39
+ readonly halfY?: number;
40
+ /** Horizontal half-extent of the routed run. Default: `0.02`. */
41
+ readonly halfXZ?: number;
42
+ /** Overhead plenum grid spacing inside enclosed footprint (meters). Default: `1.5`. */
43
+ readonly plenumGridStepM?: number;
44
+ /** Include under-slab / crawlspace trench layer (ground story). Default: `true`. */
45
+ readonly includeSubFloorLayer?: boolean;
46
+ /** Band label assigned to the compiled sub-floor layer (`'under-slab'` or `'crawlspace'`). Default: `'under-slab'`. */
47
+ readonly subFloorBand?: 'under-slab' | 'crawlspace';
48
+ /** Sub-floor trench elevation (meters, negative below finished floor). Default: `-0.35`. */
49
+ readonly subFloorElevationM?: number;
50
+ /** Overhead attic elevation (meters above floor). Auto-derived from wallH & roof if omitted. */
51
+ readonly atticElevationM?: number;
52
+ /** Flat-roof / lower-story ceiling soffit margin below `levelH`. Default: `0.16` if `levelH >= 2.6` else `0.08`. */
53
+ readonly flatSoffitMarginM?: number;
54
+ /** Outdoor room polygons excluded from interior plenum cavities. */
55
+ readonly outdoorPolygons?: readonly (readonly (readonly [number, number])[])[];
56
+ /** Explicit interior room polygons. */
57
+ readonly interiorPolygons?: readonly (readonly (readonly [number, number])[])[];
58
+ };
59
+ export type LegalCavityGraph = {
60
+ readonly levelId: string | null;
61
+ readonly levelHeightM: number;
62
+ readonly vertices: readonly CavityVertex[];
63
+ readonly adjacency: readonly (readonly CavityEdge[])[];
64
+ readonly wallRiserPiers: ReadonlyMap<string, readonly WallRiserPier[]>;
65
+ readonly bandsPresent: ReadonlySet<CavityBand>;
66
+ readonly ceilingPlenumY: number;
67
+ readonly atticY: number | null;
68
+ readonly subFloorY: number | null;
69
+ readonly compiledHalfXZ?: number;
70
+ readonly compiledHalfY?: number;
71
+ readonly compiledRoofClearanceM?: number;
72
+ readonly minBaseWeight?: number;
73
+ };
74
+ export type CavityRouteRequest = {
75
+ readonly trade: TradeId;
76
+ readonly from: Vec3;
77
+ readonly to: Vec3;
78
+ readonly halfXZ: number;
79
+ readonly halfY: number;
80
+ readonly clearanceM: number;
81
+ readonly allowedBands: readonly CavityBand[];
82
+ readonly mode: RoutingPhysicsMode;
83
+ readonly maxBendDegrees?: number;
84
+ readonly minSlopeInPerFt?: number;
85
+ readonly minHorizontalElevationM?: number;
86
+ readonly roofClearanceM?: number;
87
+ readonly preferWallFollowing?: boolean;
88
+ readonly lateralStaggerM?: number;
89
+ readonly reserveOnCommit?: boolean;
90
+ readonly runId?: string;
91
+ readonly ignoreObstacleNodeIds?: ReadonlySet<string>;
92
+ };
93
+ export type CavityRouteResult = {
94
+ readonly ok: boolean;
95
+ readonly path: readonly Vec3[];
96
+ readonly lengthM: number;
97
+ readonly horizontalLengthM: number;
98
+ readonly bendDegrees: number;
99
+ readonly elbowCount: number;
100
+ readonly bandsUsed: readonly CavityBand[];
101
+ readonly avoidedObstacleIds: readonly string[];
102
+ readonly clashObstacleIds: readonly string[];
103
+ readonly openingHits: number;
104
+ readonly roofViolation: boolean;
105
+ readonly outdoorVoidViolation: boolean;
106
+ readonly slopeInPerFt?: number;
107
+ readonly reservationId?: string;
108
+ };
@@ -0,0 +1,60 @@
1
+ /**
2
+ * Layer 3 — Dual-Projection Declarative Building/MEP Code Rule Evaluator (`@kruschdev/pascal-mep-kernel/rules`).
3
+ *
4
+ * Evaluates the EXACT same `DeclarativeRule` table in two mathematically coupled projections:
5
+ * - `'placement'` mode (generators / `filterLegalCandidates`): tightens every threshold inward by
6
+ * `Math.max(0, rule.placementMarginM ?? 0)` via `effectivePlacementThreshold`.
7
+ * - `'audit'` mode (auditors / `evaluateDeclarativeRules`): enforces exact statutory thresholds.
8
+ *
9
+ * Soundness invariant (`INV-MEP-08`):
10
+ * `evaluatePlacementCandidate(rules, c, 'placement').legal === true`
11
+ * ALWAYS implies
12
+ * `evaluatePlacementCandidate(rules, c, 'audit').legal === true`.
13
+ */
14
+ import { type TradeId } from '../types';
15
+ import type { CandidateEvaluationResult, DeclarativeRule, PlacementCandidate, RuleEvaluationMode, RuleEvaluationSummary, RuleTableValidationResult, RuleViolation } from './schema';
16
+ /**
17
+ * Derive a placement-mode threshold from an authoritative audit threshold and an optional
18
+ * non-negative safety margin (`INV-MEP-08`).
19
+ *
20
+ * - `direction === 'min'`: placement requires `actual >= auditLimit + margin` (higher minimum).
21
+ * - `direction === 'max'`: placement requires `actual <= auditLimit - margin` (lower maximum).
22
+ *
23
+ * Negative, `NaN`, or non-finite `placementMarginM` values are strictly clamped to `0` so
24
+ * placement can NEVER be looser than audit.
25
+ */
26
+ export declare function effectivePlacementThreshold(auditLimit: number, placementMarginM: number | undefined, direction: 'min' | 'max'): number;
27
+ /**
28
+ * Evaluate a single `PlacementCandidate` against every matching rule in `rules`.
29
+ *
30
+ * - `mode === 'placement'` (default): applies tightened `effectivePlacementThreshold` margins.
31
+ * - `mode === 'audit'`: applies exact statutory thresholds.
32
+ */
33
+ export declare function evaluatePlacementCandidate(rules: readonly DeclarativeRule[], candidate: PlacementCandidate, mode?: RuleEvaluationMode): CandidateEvaluationResult;
34
+ /**
35
+ * Generator-side filter: partition placement candidates into `legal` (zero violations in
36
+ * `'placement'` mode) and `rejected` (paired with their blocking `RuleViolation[]`).
37
+ */
38
+ export declare function filterLegalCandidates<T extends PlacementCandidate>(rules: readonly DeclarativeRule[], candidates: readonly T[]): {
39
+ legal: T[];
40
+ rejected: Array<{
41
+ candidate: T;
42
+ violations: readonly RuleViolation[];
43
+ }>;
44
+ };
45
+ /**
46
+ * Auditor-side evaluator: run all rules matching `opts.trade` in `'audit'` mode across all
47
+ * `candidates` and return the canonical `{ ok, tool, summary, data }` JSON contract.
48
+ */
49
+ export declare function evaluateDeclarativeRules(rules: readonly DeclarativeRule[], candidates: readonly PlacementCandidate[], opts: {
50
+ readonly trade: TradeId;
51
+ readonly tool?: string;
52
+ }): RuleEvaluationSummary;
53
+ /**
54
+ * Validate structural and invariant integrity of a declarative rule table:
55
+ * - Non-empty, unique `id` across all rules
56
+ * - Non-empty `codeRef` on every rule
57
+ * - Finite, non-negative `placementMarginM` (`>= 0`) whenever specified (`INV-MEP-08`)
58
+ * - Valid finite parameter ranges for geometric/code thresholds
59
+ */
60
+ export declare function validateRuleTable(rules: readonly DeclarativeRule[]): RuleTableValidationResult;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Layer 3 — Single-Source Declarative Building & MEP Code Rule Engine (`@kruschdev/pascal-mep-kernel/rules`).
3
+ *
4
+ * Expresses NEC / IRC / IPC / IMC spatial & topological constraints once as typed data so
5
+ * placement/routing generators and post-hoc compliance auditors read the exact same rule table
6
+ * (`INV-MEP-08`).
7
+ */
8
+ export type * from './schema';
9
+ export type { CandidateCheckResult, CandidateEvaluationResult } from './schema';
10
+ export { effectivePlacementThreshold, evaluatePlacementCandidate, filterLegalCandidates, evaluateDeclarativeRules, validateRuleTable, } from './evaluator';
@@ -0,0 +1,15 @@
1
+ import {
2
+ effectivePlacementThreshold2,
3
+ evaluatePlacementCandidate2,
4
+ filterLegalCandidates2,
5
+ evaluateDeclarativeRules2,
6
+ validateRuleTable2
7
+ } from "../chunk-sab5aaa6.js";
8
+ import"../chunk-jfzqztgh.js";
9
+ export {
10
+ effectivePlacementThreshold2 as effectivePlacementThreshold,
11
+ evaluateDeclarativeRules2 as evaluateDeclarativeRules,
12
+ evaluatePlacementCandidate2 as evaluatePlacementCandidate,
13
+ filterLegalCandidates2 as filterLegalCandidates,
14
+ validateRuleTable2 as validateRuleTable
15
+ };