Examples - mineproductivity.decision¶
Purpose¶
Runnable, minimal, self-contained scripts demonstrating Decision Intelligence: an audited, explained, ranked decision pipeline over real KPI/Analytics evidence, action prioritization and dependency-respecting planning, live event-driven decision sessions, and third-party strategy plugins.
Scope¶
Example scripts and their direct output. No test assertions live here (see tests/unit/decision/ for that); each script is meant to be read and run by a human evaluating the package.
Responsibilities¶
- Show idiomatic usage of the Decision Intelligence public API.
- Serve as executable documentation that stays correct because it is actually run.
- Demonstrate the §3.2 discipline end-to-end: every fact a
DecisionPipelinereasons over comes fromkpis.KPIEngine.execute()oranalytics.BatchAnalyticsRunner- nothing indecisionrecomputes a KPI or a statistic.
Contents¶
_evidence.py- shared, internal helper: parses the cycle/maintenance/production CSVs from thetests/fixtures/kpis/sample dataset (the same oneexamples/kpis/uses), builds a realKPIEngine, and carries five prior shifts' already-computedUTIL.OEEvalues for trend context. Not itself an example; the evidence-driven scripts below import it.01_pipeline_over_evidence.py- the design spec §9 worked example, end-to-end: a fleet-availabilityPolicyevaluated against the real shift'sUTIL.OEEand its week-longTREND.Linearslope - rule evaluation (RuleEngineStage), recommendation (ThresholdDecisionStrategy), declarativeThresholdconfirmation, explanation (ExplanationStage), ranking (WeightedScoreRanking), and theDecisionAuditTrailrecord, all throughDecisionPipeline/BatchDecisionRunner.02_action_planning.py-ActionPrioritizer+ActionPlanner: ranking ("which recommendation is best," §16) kept distinct from prioritization ("which action happens first under limited capacity," §20), a dependency-respectingActionPlan(§21), and the loudResult.errrejection of a cyclic dependency declaration.03_realtime_session.py-RealTimeDecisionSessionover anevents.EventBus: each published cycle event refreshes that equipment'sPROD.TPHthrough the realKPIEngineand re-runs the pipeline;latest()serves per-scope results without re-running; includes a real-time/batch parity check and per-event audit-trail traceability.04_plugin_strategy.py- a third-party-styleDecisionStrategyregistered via entry points (EntryPointSpec(group="mineproductivity.decision", target_registry="decision"), design spec §32), mirroringexamples/registry/01_register_and_discover.py's real-discovery pattern.
Sample Dataset¶
tests/fixtures/kpis/ holds one realistic shift (A-2026-06-25, 06:00–18:00 UTC, bingham-west); _evidence.py loads the three event types UTIL.OEE's dependency graph consumes. The five prior shifts' OEE values in _evidence.OEE_HISTORY are disclosed stand-ins for results a production deployment would read back from its own KPI store - the fixture dataset covers a single shift, so earlier points cannot be recomputed here.
Dependencies¶
mineproductivity[analytics] (for the pandas-backed default ExecutionBackend). No network access; the sample dataset is local.
Running the Examples¶
pip install -e ".[analytics]"
python examples/decision/01_pipeline_over_evidence.py
python examples/decision/02_action_planning.py
python examples/decision/03_realtime_session.py
python examples/decision/04_plugin_strategy.py
Each script exits 0 and prints its own output; there is nothing to configure.
Future Work¶
Add a concrete RootCauseAnalyzer/WhatIfEngine walkthrough once a first-party or third-party plugin implementing either interface-only extension point exists (deliberately never shipped inside decision itself, design spec §33).