Skip to main content
Version: 3.0.0

Rules Engine Framework

Version: v3.0.0 Status: Normative (text), Illustrative (diagrams only) Scope: Infrastructure requirements for rule execution, sequencing, and error handling during PCR analysis Domain: RULES-ENGINE


Statement

The system shall orchestrate the execution of PCR analysis rules, controlling which rules apply to a given analysis context, the sequence in which they execute, and how errors and warnings affect analysis flow.

The Rules Engine is the infrastructure layer that governs all rule execution. It does not define what individual rules calculate or validate; those are specified in separate rule documents. This framework ensures deterministic, configurable rule execution across all analysis contexts.


Quick Reference

IDCore BehaviorPriorityStatus
REQ-RULES-ENGINE-001Executes rules only when valid mapping exists for current contextHIGHDraft
REQ-RULES-ENGINE-002Executes rules in ascending order by configured run orderHIGHDraft
REQ-RULES-ENGINE-003Stops or continues analysis based on error code configurationHIGHDraft

Key Integration Points: Kit Configuration (rule mappings), Individual Rule Implementations, Analysis Pipeline


Rule Execution Flowchart (Illustrative)

This diagram illustrates the high-level rule execution flow. It does not specify UI layout, configuration interfaces, or internal rule algorithms.


Definitions

TermDefinition
RuleA discrete analysis algorithm that evaluates PCR data and returns a result or error code
Rules MappingConfiguration that relates a rule ID to a combination of Dye, Target Name, Mix, and optionally Sample Type
Rule SetupConfiguration that defines the execution order for rules
Error CodesConfiguration that defines behavior for each possible error/warning code
Does prevent AnalyseA per-error-code flag determining whether the error stops analysis

Rule Categories (Illustrative)

The following diagram shows how individual rules are organized by function. Each rule has its own detailed specification document.


Requirements

Rule Execution Control (REQ-RULES-ENGINE-001)

FR-ENGINE-001: Conditional Rule Execution Based on Mapping

The system shall execute a rule only when a valid mapping exists in the Rules Mapping configuration for the current analysis context.

Acceptance Criteria

Mapping Evaluation:

  • Execute a rule only when the Rules Mapping contains an entry matching the rule ID to the current Dye, Target Name, and Mix
  • Evaluate mappings before attempting rule execution
  • Skip rules that have no matching mapping entry for the current context

Sample Type Filtering:

  • When Sample Type filtering is enabled, require the mapping to also match the current Sample Type
  • When Sample Type filtering is disabled, evaluate only Dye, Target Name, and Mix for rule mapping

Error Handling

  • No rules mapped for analysis context: Complete analysis without executing any rules
  • Rules Mapping configuration unavailable: Halt analysis and report configuration error

Trace: Source: 3.0.0-Rules (Row 1) | Jira: BT-674 | Tests: See scenarios


Sequential Execution (REQ-RULES-ENGINE-002)

FR-ENGINE-002: Sequential Rule Execution Order

The system shall execute rules in ascending order based on the numeric run order defined in the Rule Setup configuration.

Acceptance Criteria

Ordering:

  • Execute rules in ascending order based on run order value from Rule Setup
  • A rule with order value N shall complete before any rule with order value greater than N begins
  • The execution sequence shall be deterministic for any given Rule Setup configuration

Error Handling

  • Duplicate order values: Execute rules with same order value in a deterministic (implementation-defined) sequence
  • Rule Setup configuration unavailable: Halt analysis and report configuration error

Trace: Source: 3.0.0-Rules (Row 2) | Jira: BT-674 | Tests: See scenarios


Error and Warning Handling (REQ-RULES-ENGINE-003)

FR-ENGINE-003: Error/Warning Flow Control

The system shall handle rule errors and warnings by stopping or continuing analysis based on the "Does prevent Analyse" configuration for each error code.

Acceptance Criteria

Blocking Errors:

  • When a rule returns an error code where "Does prevent Analyse" is true, stop analysis immediately
  • When analysis stops, return the error/warning code and message
  • Interpret "Does prevent Analyse" as true when the configuration value is 'x'

Non-Blocking Errors:

  • When a rule returns an error code where "Does prevent Analyse" is false, continue executing subsequent rules
  • Apply the "Does prevent Analyse" logic to any subsequent errors encountered during continued analysis
  • When analysis completes without blocking errors, return the first non-blocking error/warning encountered
  • Interpret "Does prevent Analyse" as false when the configuration value is empty string ''

Uniform Treatment:

  • Apply identical logic to warnings as to errors

Error Handling

  • Error code not found in Error Codes configuration: Treat as blocking error and stop analysis
  • Error Codes configuration unavailable: Halt analysis and report configuration error

Trace: Source: 3.0.0-Rules (Row 3) | Jira: BT-674 | Tests: See scenarios


Configuration Options

OptionDefaultDescriptionAffects
sample_type_filtering_enabled[Client-specific]When enabled, rule mappings must match Sample Type in addition to Dye, Target Name, and MixREQ-RULES-ENGINE-001

Assumptions

  • At least one rule is configured and mapped before analysis is attempted
  • Rule Setup tab contains valid numeric order values for all mapped rules
  • Error Codes tab contains entries for all error codes that rules may return
  • Client configuration determines whether Sample Type filtering is enabled

Individual Rule Specifications

Each rule listed below has its own specification document with detailed requirements, acceptance criteria, and tests.

Signal Quality Rules

RuleDocumentDescription
THRESHOLDrule-threshold.mdValidates runfile threshold values against expected configuration
MANUAL_BASELINErule-baseline-check.mdDetects when manual baseline intervention is required
MINIMUM_FLUORESCENCErule-minimum-fluorescence.mdValidates minimum fluorescence thresholds
DOWNWARD_SIGMOIDrule-downward-sigmoid.mdDetects downward sigmoid curve patterns
DOWNWARD_SIGMOID_CONTROLrule-downward-sigmoid-control.mdApplies downward sigmoid checks to control wells
NEGATIVE_SIGMOIDrule-negative-sigmoid.mdDetects negative sigmoid curve patterns
NEGATIVE_SIGMOID_CONTROLrule-negative-sigmoid-control.mdApplies negative sigmoid checks to control wells
POSITIVE_SIGMOIDrule-positive-sigmoid.mdDetects positive sigmoid curve patterns
POSITIVE_SIGMOID_CONTROLrule-positive-sigmoid-control.mdApplies positive sigmoid checks to control wells
UNEXPECTED_FLrule-unexpected-fl.mdDetects unexpected fluorescence patterns

Control Validation Rules

RuleDocumentDescription
NECrule-nec.mdValidates Negative Extraction Controls
BPECrule-bpec.mdValidates BioProduct Extraction Controls
CCrule-cc.mdValidates Control Charts
CONTROL_FAILrule-control-fail.mdHandles control failures
MINCONTROLSrule-mincontrols.mdValidates minimum control counts
EXTRACTION_CONTROLSrule-extraction-controls.mdValidates extraction controls
WESTGARDSrule-westgards.mdApplies Westgard QC rules

Inhibition Detection Rules

RuleDocumentDescription
INHIBITION_CTrule-inhibition-ct.mdDetects inhibition via CT values
INHIBITION_QUALITATIVErule-inhibition-qualitative.mdQualitative inhibition detection
INHIBITION_QUANTIFICATIONrule-inhibition-quantification.mdQuantitative inhibition detection
INHIBITION_SERUM_QUANTITATIVErule-inhibition-serum-quantitative.mdSerum-specific quantitative inhibition
SYSTEMIC_INHIBITIONrule-systemic-inhibition.mdDetects systemic inhibition patterns
NEGATIVE_CONTROL_INHIBITIONrule-negative-control-inhibition.mdInhibition in negative controls
IC_QUAL_SERUMrule-ic-qual-serum.mdIC qualification for serum samples
ICCTrule-icct.mdInternal Control CT validation

Classification and Discrepancy Rules

RuleDocumentDescription
WDCLSrule-wdcls.mdWell classification discrepancy detection
WDCLSCrule-wdclsc.mdWell classification discrepancy (controls)
WDCLS_INVERT_SIGMOIDrule-wdcls-invert-sigmoid.mdClassification with inverted sigmoid
WDCLSC_INVERT_SIGMOIDrule-wdclsc-invert-sigmoid.mdClassification (controls) with inverted sigmoid
WDCTrule-wdct.mdWell CT discrepancy detection
WDCTCrule-wdctc.mdWell CT discrepancy (controls)
AMBrule-amb.mdAmbiguous result handling
ADJrule-adj.mdAdjudication rule
ADJ_ZIKArule-adj-zika.mdZika-specific adjudication
INDETERMINATE_CTSrule-indeterminate-cts.mdHandles indeterminate CT values
MANAGING_INCONCLUSIVErule-managing-inconclusive.mdManages inconclusive results

Combined Outcome Rules

RuleDocumentDescription
COMBINED_OUTCOMErule-combine-outcomes.mdCore combined outcome matching
SINGLE_WELL_COMBINED_OUTCOMErule-single-well-combined-outcome.mdSingle-well outcome evaluation
MULTIPLE_WELLS_COMBINED_OUTCOMErule-multiple-wells-combined-outcome.mdMulti-well outcome evaluation
COMBINED_OUTCOMES_CONTROLrule-combined-outcomes-control.mdCombined outcomes for controls
MIXES_MISSINGrule-mixes-missing.mdDetects missing mix conditions

Quantification Rules

RuleDocumentDescription
RQUANTrule-rquant.mdReportable quantity calculation
MANAGING_QUANTITIESrule-managing-quantities.mdQuantity management rules
QUANTITY_WEIGHTrule-quantity-weight.mdWeighted quantity calculations
QUANT_VALIDATIONrule-quant-validation.mdQuantity validation
STDQTrule-stdqt.mdStandard quantity determination
NOTTS_QUANT_MULTIPLYrule-notts-quant-multiply.mdNottingham quantity multiplier
STANDARD_CURVE_VALIDATIONrule-standard-curve-validation.mdStandard curve validation
LINEAR_REGRESSION_VALIDATIONrule-linear-regression-validation.mdLinear regression validation
QSSCrule-qssc.mdQuantification standard sample check

Reporting Rules

RuleDocumentDescription
RRESOLUTIONrule-rresolution.mdReport resolution rule
RWACrule-rwac.mdReport with acceptance criteria
REPORTING_QUALrule-reporting-qual.mdQualitative reporting
REPORTING_QUANT_AS_QUALrule-reporting-quant-as-qual.mdReport quantitative as qualitative
REPEAT_SAMPLErule-repeat-sample.mdRepeat sample handling
CT_CUTOFF_WFINALCLSrule-ct-cutoff-wfinalcls.mdCT cutoff with final classification

Other Rules

RuleDocumentDescription
WCrule-wc.mdCross-Talk DEPRECATED - Rule never implemented
WTrule-wt.mdWell target rule
WCAFrule-wcaf.mdWell classification after final
DELTA_CTrule-delta-ct.mdDelta CT calculation

UI Notes (Illustrative)

Rule Configuration Interfaces

  • Rules Mapping tab: Interface for configuring rule-to-context mappings (Dye, Target Name, Mix, Sample Type)
  • Rule Setup tab: Interface for configuring rule execution order
  • Error Codes tab: Interface for configuring error code behaviors including "Does prevent Analyse" flag

Implementation (Illustrative)

ComponentLocation
Rule ModelRule.php
Rules ControllerHttp/Controllers/RulesController
Rule Base InterfaceAnalyzer/Contracts/AnalyzerRuleContract

Traceability Matrix

RequirementTitleVerificationImplementationTest CasesStatus
REQ-RULES-ENGINE-001Conditional Rule Execution Based on MappingTestRule, RulesController[Pending]Draft
REQ-RULES-ENGINE-002Sequential Rule Execution OrderTestRule.execute()[Pending]Draft
REQ-RULES-ENGINE-003Error/Warning Flow ControlTestRule.execute()[Pending]Draft

Notes

  • This domain defines Rules Engine infrastructure, not individual rule implementations
  • Individual rules are separate requirements documented in their respective domains (linked above)
  • The Rules Engine executes rules but does not define what each rule calculates or validates

Acceptance Tests

Test: REQ-RULES-ENGINE-001

Back to requirement

Test: Rule executes when mapping exists

Given: A rule "RuleA" is mapped to Dye "FAM", Target "COVID", Mix "Mix1"
And: Analysis is requested for Dye "FAM", Target "COVID", Mix "Mix1"
When: The Rules Engine processes the analysis
Then: "RuleA" shall execute

Test: Rule skipped when no mapping exists

Given: A rule "RuleA" is mapped to Dye "FAM", Target "COVID", Mix "Mix1"
And: Analysis is requested for Dye "HEX", Target "COVID", Mix "Mix1"
When: The Rules Engine processes the analysis
Then: "RuleA" shall not execute

Test: Sample Type filtering when enabled

Given: Sample Type filtering is enabled
And: A rule "RuleA" is mapped to Dye "FAM", Target "COVID", Mix "Mix1", Sample Type "Serum"
And: Analysis is requested for Dye "FAM", Target "COVID", Mix "Mix1", Sample Type "Plasma"
When: The Rules Engine processes the analysis
Then: "RuleA" shall not execute

Test: REQ-RULES-ENGINE-002

Back to requirement

Test: Rules execute in ascending order

Given: "RuleA" has run order 10
And: "RuleB" has run order 5
And: "RuleC" has run order 15
And: All rules are mapped to the current analysis context
When: The Rules Engine processes the analysis
Then: Rules shall execute in order: RuleB, RuleA, RuleC

Test: REQ-RULES-ENGINE-003

Back to requirement

Test: Blocking error stops analysis

Given: Error code "E001" has "Does prevent Analyse" = true
And: "RuleA" (order 1) returns error code "E001"
And: "RuleB" (order 2) is mapped to the analysis context
When: The Rules Engine processes the analysis
Then: Analysis shall stop after "RuleA"
And: "RuleB" shall not execute
And: Error code "E001" shall be returned

Test: Non-blocking error allows continuation

Given: Error code "E002" has "Does prevent Analyse" = false
And: "RuleA" (order 1) returns error code "E002"
And: "RuleB" (order 2) completes successfully
When: The Rules Engine processes the analysis
Then: Both "RuleA" and "RuleB" shall execute
And: Error code "E002" shall be returned

Test: First non-blocking error returned after successful completion

Given: Error code "E002" has "Does prevent Analyse" = false
And: Error code "E003" has "Does prevent Analyse" = false
And: "RuleA" (order 1) returns error code "E002"
And: "RuleB" (order 2) returns error code "E003"
When: The Rules Engine processes the analysis
Then: Error code "E002" shall be returned (first encountered)

Design DocumentRelevant Sections
SDD AlgorithmsRunning Rules Architecture, Rule Mapping Architecture, Complex Functionality - Rules Engine

Appendix: Process Artifacts

Completion Checklist

  • All requirements are capability-level (describe behavior, not UI)
  • Requirement variants consolidated (no requirement explosion)
  • UI details are fully demoted to Illustrative section
  • Configuration options are not encoded as requirements
  • Acceptance criteria describe behavior, not UI mechanics
  • Every requirement has acceptance criteria and source traceability
  • Error handling addressed for I/O, validation, and external system requirements
  • Open questions documented with owners assigned
  • Consolidations documented in Reviewer Notes with reversibility info
  • Module can survive a full UI redesign unchanged
  • Refinements folded into Acceptance Criteria
  • Traceability matrix is complete

Reviewer Notes

No consolidation was performed. All three source items represent distinct, independently testable framework capabilities:

RequirementCapabilityJustification
REQ-RULES-ENGINE-001Rule mappingConditional execution based on context matching
REQ-RULES-ENGINE-002Rule orderingDeterministic execution sequence
REQ-RULES-ENGINE-003Error handlingFlow control based on error severity

These are infrastructure requirements that govern ALL rule execution, not variants of a single capability.

Reversibility: Source requirements preserved 1:1 from 3.0.0-Rules (Rows 1-3).