Skip to main content
Version: Next

STD: Rules Engine Framework

Version: v1.0.1 Status: Draft SRS Source: rules/rules.md Rule Name: RULES ENGINE (Framework) Domain: RULES-ENGINE


Overview

This document specifies tests for the Rules Engine framework using decision tables and test vectors. The Rules Engine is the infrastructure layer that governs all rule execution: which rules apply to a given analysis context (conditional execution), the sequence in which they execute (sequential ordering), and how errors and warnings affect analysis flow (error/warning flow control).

Rule Characteristics:

  • Infrastructure layer (not an individual rule algorithm)
  • Conditional execution based on Rules Mapping configuration
  • Deterministic sequential execution by configured run order
  • Error/warning flow control via does_prevent_analyse flag (per-well: blocks further rule execution for affected well(s), not the entire pipeline)
  • Implicitly exercised by every individual rule test, but requires explicit verification

Test Method: TM-API (per Test Plan Section 3.3 - Rules use automated API tests)

Verification Approach: Rule verification is performed using data-driven test vectors. Each row in a decision table represents a complete verification scenario with defined inputs and expected outputs. This format enables exhaustive condition coverage while remaining concise and auditable.

Note: These three REQs are implicitly exercised by every rule test in the system -- any test that runs a rule through the analysis pipeline exercises mapping lookup, execution ordering, and error flow control. However, explicit verification is needed to confirm edge cases (e.g., empty mappings, duplicate run orders, mixed blocking/non-blocking error sequences) that individual rule tests do not isolate.


Coverage Summary

REQ IDTitleConditionsTest VectorsCoverageGapsAutomation Status
REQ-RULES-ENGINE-001Conditional Rule Execution Based on Mapping68100%NoneImplicit (all rule tests exercise mapping)
REQ-RULES-ENGINE-002Sequential Rule Execution Order45100%NoneImplicit (multi-rule tests exercise ordering)
REQ-RULES-ENGINE-003Error/Warning Flow Control68100%NoneImplicit (error-producing rule tests exercise flow control)

Totals: 3 REQs, 16 Conditions, 21 Test Vectors, 100% Coverage


Input Variables (Common)

VariableTypeValid ValuesDescription
rules_mapping[]arraymapping entriesRules Mapping sheet entries (Rule ID, Dye, Target Name, Mix, Sample Type)
rule_setup[]arraysetup entriesRule Setup sheet entries (Rule ID, run_order)
error_codes[]arrayerror code entriesError Codes sheet entries (code, does_prevent_analyse)
analysis.dyestringFAM, HEX, ROX, ...Dye for the current analysis context
analysis.target_namestringtarget identifierTarget Name for the current analysis context
analysis.mixstringMix1, Mix2, ...Mix for the current analysis context
analysis.sample_typestring?Serum, Plasma, ...Sample Type for the current analysis context (when filtering enabled)
config.sample_type_filtering_enabledbooltrue, falseWhether Sample Type filtering is active
rule.resultstring?null, error_codeResult returned by an executed rule
error.does_prevent_analysestring'x', ''Per-error-code flag: 'x' = blocking, '' = non-blocking

Output Variables (Common)

VariableTypeDescription
rule.executedboolWhether a given rule was executed
execution_orderarrayOrdered list of rules that actually executed
analysis.haltedboolWhether analysis of the affected well(s) stopped before completing all rules (per-well; other wells continue through the pipeline normally)
analysis.error_codestring?Error/warning code returned from analysis
analysis.error_messagestring?Error/warning message returned from analysis

REQ-RULES-ENGINE-001: Conditional Rule Execution Based on Mapping

Acceptance Criteria Mapping

AC IDAcceptance CriterionTest Vectors
AC-001-1Execute rule when mapping matches Dye, Target Name, and MixTV-ENGINE-001-001
AC-001-2Skip rule when no mapping matches current contextTV-ENGINE-001-002, TV-ENGINE-001-003
AC-001-3Evaluate mappings before attempting rule executionTV-ENGINE-001-002
AC-001-4When Sample Type filtering enabled, require Sample Type matchTV-ENGINE-001-005, TV-ENGINE-001-006
AC-001-5When Sample Type filtering disabled, evaluate only Dye, Target Name, MixTV-ENGINE-001-004
AC-001-6No rules mapped: complete analysis without executing any rulesTV-ENGINE-001-007

Decision Table: Rule Mapping Match

Tests whether a rule executes based on the presence and match of a Rules Mapping entry for the current analysis context.

TVmapping.dyemapping.targetmapping.mixanalysis.dyeanalysis.targetanalysis.mixrule.executedCovers
TV-ENGINE-001-001FAMCOVIDMix1FAMCOVIDMix1trueAC: Valid mapping exists, rule executes
TV-ENGINE-001-002FAMCOVIDMix1HEXCOVIDMix1falseAC: Dye mismatch, rule skipped (no error, no output)
TV-ENGINE-001-003FAMCOVIDMix1FAMHEVMix2falseAC: Target and Mix mismatch, rule skipped

Decision Table: Multiple Rules with Selective Mapping

Tests that only rules with valid mappings execute when multiple rules are configured.

TVrules_configuredrules_mapped_to_contextrules_executedCovers
TV-ENGINE-001-004RuleA, RuleB, RuleCRuleA, RuleCRuleA, RuleCAC: Only mapped rules execute; RuleB skipped

Decision Table: Sample Type Filtering

Tests that Sample Type filtering correctly gates rule execution when enabled.

TVsample_type_filteringmapping.sample_typeanalysis.sample_typemapping_matchesrule.executedCovers
TV-ENGINE-001-005enabledSerumSerumtruetrueAC: Sample Type matches, rule executes
TV-ENGINE-001-006enabledSerumPlasmafalsefalseAC: Sample Type mismatch, rule skipped

Decision Table: Empty Rules Mapping

Tests that analysis completes gracefully when no rules are mapped.

TVrules_mappingrules_executedanalysis.haltedanalysis.error_codeCovers
TV-ENGINE-001-007[] (empty)nonefalsenullAC: No rules mapped, analysis completes without error
TV-ENGINE-001-008unavailablen/atrueCONFIGURATION_ERROREH: Rules Mapping unavailable, analysis halted

REQ-RULES-ENGINE-002: Sequential Rule Execution Order

Acceptance Criteria Mapping

AC IDAcceptance CriterionTest Vectors
AC-002-1Execute rules in ascending order by run_order valueTV-ENGINE-002-001
AC-002-2Rule with order N completes before rule with order > N beginsTV-ENGINE-002-001
AC-002-3Execution sequence is deterministic for a given configurationTV-ENGINE-002-002
AC-002-4Modified run_order changes execution sequenceTV-ENGINE-002-004

Decision Table: Execution Order

Tests that rules execute in the correct ascending order based on run_order configuration.

TVRuleA.run_orderRuleB.run_orderRuleC.run_orderexpected_execution_orderCovers
TV-ENGINE-002-00110515RuleB, RuleA, RuleCAC: Ascending order by run_order
TV-ENGINE-002-002101020{RuleA,RuleB} (implementation-defined), RuleCAC: Duplicate run_order, deterministic but implementation-defined

Decision Table: Order-Dependent Output

Tests that rule ordering affects analysis output when rules have data dependencies.

TVRuleA (run_order=5)RuleB (run_order=10)dependencyresult_correctCovers
TV-ENGINE-002-003Produces intermediate value XConsumes value XB depends on AtrueAC: Correct order produces correct result

Decision Table: Modified Run Order

Tests that changing run_order in configuration changes the actual execution sequence.

TVinitial_order (A=5, B=10)modified_order (A=15, B=10)initial_sequencemodified_sequenceCovers
TV-ENGINE-002-004A=5, B=10A=15, B=10A, BB, AAC: Config change alters execution order

Decision Table: Configuration Unavailable

TVrule_setupanalysis.haltedanalysis.error_codeCovers
TV-ENGINE-002-005unavailabletrueCONFIGURATION_ERROREH: Rule Setup unavailable, analysis halted

REQ-RULES-ENGINE-003: Error/Warning Flow Control

Per-well scope: The does_prevent_analyse flag operates at the well level, not the pipeline level. When a rule produces a blocking error for a well, that well is excluded from further rule evaluation, but the analysis pipeline continues processing all other wells normally. "Halts analysis" and "stops execution" in this section refer to halting further rule execution for the affected well(s) only.

Acceptance Criteria Mapping

AC IDAcceptance CriterionTest Vectors
AC-003-1Blocking error (does_prevent_analyse = 'x') prevents further rule execution for the affected well(s)TV-ENGINE-003-001
AC-003-2Non-blocking error (does_prevent_analyse = '') allows continued rule execution for the wellTV-ENGINE-003-002
AC-003-3First blocking error prevents further rule execution for the well; subsequent rules do not run for that wellTV-ENGINE-003-003
AC-003-4Non-blocking followed by blocking: first runs, second blocks further execution for the well, third skipped for that wellTV-ENGINE-003-004
AC-003-5All non-blocking: all rules execute for the well; first non-blocking error returnedTV-ENGINE-003-005
AC-003-6does_prevent_analyse config flag toggled changes behaviorTV-ENGINE-003-006

Decision Table: Blocking Error Prevents Further Rule Execution for Well

Tests that a rule returning a blocking error (does_prevent_analyse = 'x') prevents subsequent rule execution for the affected well(s).

TVRuleA.errorA.does_prevent_analyseRuleB.mappedRuleB.executedanalysis.haltedanalysis.error_codeCovers
TV-ENGINE-003-001E001'x' (true)truefalsetrueE001AC: Blocking error prevents further rule execution for the well; RuleB does not execute

Decision Table: Non-Blocking Error Allows Continuation

Tests that a rule returning a non-blocking error (does_prevent_analyse = '') allows subsequent rules to execute.

TVRuleA.errorA.does_prevent_analyseRuleB.executedRuleB.erroranalysis.haltedanalysis.error_codeCovers
TV-ENGINE-003-002E002'' (false)truenullfalseE002AC: Non-blocking error, RuleB executes, E002 returned

Decision Table: Multiple Blocking Errors

Tests that the first blocking error prevents further rule execution for the well and is the one returned.

TVRuleA.errorA.does_preventRuleB.errorB.does_preventRuleB.executedanalysis.error_codeCovers
TV-ENGINE-003-003E001'x' (true)E003'x' (true)falseE001AC: First blocking error prevents further execution for the well; RuleB never runs

Decision Table: Mixed Blocking and Non-Blocking Sequence

Tests a sequence of non-blocking then blocking errors.

TVRuleA (order=1)A.does_preventRuleB (order=2)B.does_preventRuleC (order=3)C.executedanalysis.error_codeCovers
TV-ENGINE-003-004E002 (warning)'' (false)E001 (error)'x' (true)n/afalseE001AC: A runs (non-blocking), B blocks further execution for the well (blocking), C skipped

Decision Table: All Non-Blocking Errors

Tests that when all errors are non-blocking, all rules execute and the first error is returned.

TVRuleA.errorA.does_preventRuleB.errorB.does_preventRuleC.errorC.does_preventall_executedanalysis.error_codeCovers
TV-ENGINE-003-005E002'' (false)E003'' (false)nulln/atrueE002AC: All rules execute; first non-blocking error (E002) returned

Decision Table: Config Flag Toggle

Tests that changing the does_prevent_analyse flag alters flow control behavior for the same error code.

TVerror_codedoes_prevent_analyse (before)behavior_beforedoes_prevent_analyse (after)behavior_afterCovers
TV-ENGINE-003-006E002'' (false)continues'x' (true)blocks further execution for the wellAC: Toggling flag changes blocking behavior

Decision Table: Unknown Error Code / Config Unavailable

TVerror_codeerror_codes_configdoes_prevent_analyseanalysis.haltedCovers
TV-ENGINE-003-007E999E999 not in configtreated as blockingtrueEH: Unknown error code treated as blocking
TV-ENGINE-003-008anyunavailablen/atrueEH: Error Codes config unavailable, analysis halted

Traceability to Existing Tests

RequirementJira TestsAutomation Status
REQ-RULES-ENGINE-001Implicitly by all rule BT testsImplicit -- every rule test exercises mapping lookup
REQ-RULES-ENGINE-002Implicitly by multi-rule BT testsImplicit -- multi-rule configs exercise ordering
REQ-RULES-ENGINE-003Implicitly by error-producing rule testsImplicit -- blocking/non-blocking behavior exercised in rule tests

Note: No dedicated BT tickets exist for explicit Rules Engine framework verification. All existing rule tests (e.g., BT-5134, BT-5172, BT-5221, etc.) implicitly exercise the engine but do not isolate the framework behaviors specified in REQ-RULES-ENGINE-001 through 003. Explicit test cases should be created to verify edge cases such as empty mappings, duplicate run orders, and mixed error flow sequences.


Gap Analysis

Identified Gaps

GapRequirementDescriptionPriority
GAP-001REQ-RULES-ENGINE-001No explicit test for empty Rules Mapping (TV-ENGINE-001-007) or config unavailable (TV-ENGINE-001-008)Medium
GAP-002REQ-RULES-ENGINE-002No explicit test isolating run_order sequencing independent of individual rule logicMedium
GAP-003REQ-RULES-ENGINE-003No explicit test for mixed blocking/non-blocking error sequences (TV-ENGINE-003-004, TV-ENGINE-003-005)Medium
GAP-004REQ-RULES-ENGINE-003No explicit test for unknown error code handling (TV-ENGINE-003-007)Low

Remediation Plan

  1. GAP-001 (Empty/Missing Mapping): Create a config variant with an empty Rules Mapping sheet and verify analysis completes with no rule execution. Create a second variant with a corrupt/missing Rules Mapping to verify configuration error handling.
  2. GAP-002 (Execution Order): Create a multi-rule config where two rules with different run_order values produce order-dependent output, verifying the lower-ordered rule executes first.
  3. GAP-003 (Mixed Error Flow): Create a config with at least three rules where the first produces a non-blocking warning, the second produces a blocking error, and verify the third does not execute.
  4. GAP-004 (Unknown Error Code): Create a rule that returns an error code not present in the Error Codes configuration and verify analysis halts (treated as blocking).