Multi-Provider Pipeline -- BN -> Solver -> CLIPS
Demonstrates the flagship nxusKit integration pattern: chaining Bayesian Network prediction, constraint solver optimization, and CLIPS rule-based safety enforcement in a 3-stage pipeline. Each stage feeds its output into the next, showing how probabilistic, combinatorial, and symbolic reasoning compose through a unified SDK.
Chain probabilistic prediction, constraint optimization, and rule-based safety enforcement into a single production-ready pipeline using one unified SDK.
Scenarios: festival · rescue · bakery
Edition
Section titled “Edition”Pro — requires a Pro (or trial) entitlement.
CLIPS integration path (stage 3)
Section titled “CLIPS integration path (stage 3)”Stage 3 is CLIPS: the Go path uses provider chat (go/clips_wire.go, ClipsInput / ClipsOutput JSON in the chat API). The Rust path uses the Session API (nxuskit::clips::ClipsSession — load rules, fact_assert_structured, run). Use the path that matches your integration style; both enforce the same rule files.
Schema: conformance/clips-json-contract.json. Docs: nxusKit SDK sdk-packaging/docs/rule-authoring.md — ClipsInput JSON Reference (#clipsinput-json-reference; bundle: docs/rule-authoring.md).
What this demonstrates
Section titled “What this demonstrates”Difficulty: Advanced ♦🏁 · CLIPS · Solver · BN
- Summary: Three-stage BN prediction → Solver optimization → CLIPS safety pipeline
- Scenario: Chain Bayesian Network prediction into Solver optimization with CLIPS safety enforcement
tech_tagsin manifest:BN, Solver, CLIPS— example idbn-solver-clips-pipelineinconformance/examples_manifest.json.
Prerequisites
Section titled “Prerequisites”- SDK: Use an installed SDK tree (
NXUSKIT_SDK_DIR,NXUSKIT_LIB_PATHas needed);test-examples.shresolves Go/Rust/Python deps from that tree only — see README.md,scripts/setup-sdk.sh, andscripts/test-examples.sh. - Languages in this example: go, rust (paths under this directory; Python may live under a sibling
python/or shared reference per Language Implementations).
Key nxusKit Features Demonstrated
Section titled “Key nxusKit Features Demonstrated”| Feature | Description | Rust | Go |
|---|---|---|---|
| BnNetwork | Load and query Bayesian Network from BIF file | BnNetwork::from_bif() | LoadBnNetwork() |
| BnEvidence | Set observed evidence for inference | evidence.set_discrete() | ev.SetDiscrete() |
| Variable Elimination | Exact posterior inference algorithm | net.infer(&ev, "ve") | net.Infer(ev, "ve") |
| SolverSession | Create and configure Z3 constraint solver | SolverSession::new() | NewSolverSession() |
| Constraint Optimization | Single-objective optimization with constraints | session.solve() | session.Solve() |
| CLIPS (stage 3) | Rule engine for safety | ClipsSession: load_file, fact_assert_structured, run | Provider chat: NewClipsProvider(), JSON in ChatRequest |
| Fact assertion | Solver → CLIPS | Structured slots → fact_assert_structured | JSON facts in user message |
| Alert / conclusion readout | Derived template facts | facts_by_template + fact_slot_values | Parse ClipsOutput.conclusions |
| Pipeline Composition | 3-stage data flow across provider types | Stage 1 -> 2 -> 3 | Stage 1 -> 2 -> 3 |
Technologies
Section titled “Technologies”Solver, BN
Pipeline Architecture
Section titled “Pipeline Architecture”┌─────────────┐ Posteriors ┌──────────────┐ Assignments ┌───────────────┐│ BN Network │ ──────────────> │ Solver │ ──────────────> │ CLIPS Rules ││ (Prediction) │ │ (Optimization)│ │ (Safety) │└─────────────┘ └──────────────┘ └───────────────┘ model.bif problem.json rules.clp evidence.jsonStage 1 — BN Prediction: Loads a Bayesian Network from a BIF file, sets observed evidence, and runs Variable Elimination to compute posterior distributions over a target variable (crowd size, survivor probability, or demand level).
Stage 2 — Solver Optimization: Uses the BN prediction to inform a Z3 constraint optimization problem. Variables, constraints, and objectives are loaded from problem.json. The solver finds optimal assignments (band-to-stage, team-to-zone, or item-to-oven mappings).
Stage 3 — CLIPS Safety Enforcement: Converts solver assignments into CLIPS facts and asserts them into a rule engine loaded with domain-specific safety rules. The engine fires rules to detect violations and generates typed alerts (critical, warning, info).
Attach an installed SDK (NXUSKIT_SDK_DIR). See the repository README.md and scripts/test-examples.sh.
# From `/examples/integrations/bn-solver-clips-pipeline`:cd rust && cargo buildcd go && make buildcd rustcargo run -- --scenario festivalcargo run -- --scenario rescue --verbosecargo run -- --scenario bakery --stepcd gomake build./bin/bn-solver-clips-pipeline --scenario festival./bin/bn-solver-clips-pipeline --scenario rescue --verbose./bin/bn-solver-clips-pipeline --scenario bakery --stepOr directly:
cd gogo run . --scenario festivalScenarios
Section titled “Scenarios”Festival (Music Festival Stage Planning)
Section titled “Festival (Music Festival Stage Planning)”A music festival needs to assign bands to stages while maximizing audience enjoyment. The BN predicts crowd size from weather, headliner popularity, and time of day. The solver optimizes band-to-stage assignments. CLIPS rules enforce noise limits and pyrotechnic safety regulations.
- BN predicts:
crowd_sizegiven weather, headliner popularity, time of day - Solver optimizes: band-to-stage assignments maximizing
total_enjoyment - CLIPS enforces: noise proximity limits, pyrotechnic material restrictions
Rescue (Search and Rescue Operation)
Section titled “Rescue (Search and Rescue Operation)”A disaster response team must deploy rescue units across zones. The BN estimates survivor probability from building damage, time since event, and weather conditions. The solver assigns teams to zones to maximize rescues. CLIPS rules enforce operational safety protocols.
- BN predicts:
survivor_probabilitygiven building damage, hours since event, weather - Solver optimizes: team-to-zone assignments maximizing
total_survivors_rescued - CLIPS enforces: helicopter wind limits, team deployment protocols
Bakery (Production Scheduling)
Section titled “Bakery (Production Scheduling)”A bakery plans its daily production across multiple ovens. The BN forecasts demand level from day of week, season, and local events. The solver schedules items across ovens to minimize waste. CLIPS rules enforce allergen isolation and food safety regulations.
- BN predicts:
demand_levelgiven day of week, season, local events - Solver optimizes: item-to-oven assignments minimizing
total_waste - CLIPS enforces: allergen cross-contamination, gluten-free isolation, scheduling conflicts
Interactive Modes
Section titled “Interactive Modes”All examples support debugging flags for inspecting pipeline internals:
# Verbose mode - show intermediate data, network variables, fact assertions, rule tracescargo run -- --scenario festival --verbose # Rustgo run . --scenario festival --verbose # Go
# Step mode - pause at each pipeline stage with explanationscargo run -- --scenario rescue --step # Rustgo run . --scenario rescue --step # Go
# Combined modecargo run -- --scenario bakery --verbose --stepgo run . --scenario bakery --verbose --stepOr use environment variables:
export NXUSKIT_VERBOSE=1export NXUSKIT_STEP=1Scenario Data Format
Section titled “Scenario Data Format”Each scenario directory contains four files:
| File | Purpose | Consumed By |
|---|---|---|
model.bif | Bayesian Network definition in BIF format (variables, parents, CPTs) | Stage 1: BnNetwork |
evidence.json | Observed variable values as {"variable": "state"} pairs | Stage 1: BnEvidence |
problem.json | Solver problem with variables, constraints, and objectives | Stage 2: SolverSession |
rules.clp | CLIPS rule definitions for domain-specific safety checks | Stage 3: ClipsProvider |
expected-output.json | Golden output describing expected pipeline results | Testing/validation |
Adding a New Scenario
Section titled “Adding a New Scenario”- Create a new directory under
scenarios/ - Define the BN model in
model.bifwith evidence and prediction variables - Create
evidence.jsonwith the observed evidence - Define the optimization problem in
problem.json - Write CLIPS safety rules in
rules.clpwith appropriate templates - Add the scenario’s CLIPS template mapping to
knownScenariosin the source code - Create
expected-output.jsonwith the expected pipeline results
Real-World Applications
Section titled “Real-World Applications”| Application | How this example applies |
|---|---|
| Event planning | Predict attendance, optimize resource allocation, enforce safety codes |
| Emergency response | Estimate survival windows, deploy rescue assets, enforce operational protocols |
| Manufacturing | Forecast demand, schedule production, enforce quality and safety standards |
| Logistics | Predict delivery volumes, optimize fleet routing, enforce regulatory compliance |
| Healthcare | Predict patient load, optimize staff scheduling, enforce clinical safety protocols |
Testing
Section titled “Testing”# Rustcd rust && cargo test
# Gocd go && go test -vEach scenario includes an expected-output.json that describes the expected structure of the pipeline results, useful for regression testing and validation.