# Danger zones. When a value crosses one, its tile flashes and the state is HELD
# (peak hold) until min/max are reset - F6, or the start of a recording - so a
# half-second event during a pull cannot go unnoticed. The strip at the very top
# of the window names the rule as well, on every page and in TUNE, so it is seen
# when the tile is not on screen; alarm_sound=1 in settings.txt adds one beep.
#
#   key  >|<  threshold                       fires when the value is beyond it
#   ... if key2 >|< t2                        ...but only while a second value is too
#   ... if key2 >|< t2 and key3 >|< t3        ...and a third, and so on
#
# Keys are the tile keys (see README / src\ParamsExt.cs). Edit freely; no rebuild
# needed, the file is read when the app starts.
#
# THESE ARE STARTING VALUES, NOT TUNING ADVICE. Set them with your tuner for this
# engine and this tune. The shift light is separate - it is set from the screen.

# knock - any retard at all is worth seeing
#
# There is no fine_knock rule here on purpose. The standard Fine Knock Learn
# (0x000199) and COBB's fkl_ext (FF85B0) are the same channel - proved on
# 2026-09-24, when the standard byte read -1.00/-0.75/-0.25 exactly where the
# float read -1.05/-0.70/-0.35, it being one byte at (x*0.25)-32 and so only able
# to land on quarter-degree steps. The Accessport logs the float and does not
# read the standard one at all, so fine_knock is switched off in logcolumns.txt
# and a rule on it would only ever report "NOT CHECKED - no fine_knock column".
#
# On reflash day both come back for one drive: see logcolumns.txt for why.
fbk          <  -0.5
fkl_ext      <  -0.5
# DAM is COBB's FF6BD1 (dam_ext) - what the Accessport logs. The standard P90
# byte read identically on every row ever recorded and was retired 2026-09-27.
dam_ext      <   0.95

# Lean under load. An air/fuel ratio is only lean FOR A GIVEN AIRFLOW, so this
# needs the engine to be both breathing hard and on boost before it means
# anything. The gate is the throttle PLATE, not the pedal: this is a drive-by-
# wire car and the ECU opens the plate a long way ahead of the driver - 30-40 %
# pedal already puts the plate at 98 %, so the plate is what says how much air
# the engine is actually being given.
#
# "af_ratio1 > 12.5 if boost > 3" on its own used to fire every time the car
# pulled out of a junction, because this engine makes 3 psi at a quarter pedal.
# The ECU's own trims say nothing is wrong there: on boost the short-term
# correction stays inside -3.1 % to +5.5 %, so it is hitting its target.
afr          >  12.5   if tps > 95 and boost > 6
af_ratio1    >  12.5   if tps > 95 and boost > 6

# fuel pressure. The rail follows manifold pressure behind its regulator, so a
# healthy reading is roughly 46 psi plus boost (2026-09-21 Accessport log: 38 at
# idle, 58 at 12.6 psi). Falling below 45 while on boost is the pump or the
# regulator giving up - and a lean engine a moment later.
fuel_psi     <  45     if boost > 8

# pressure and temperature
#
# Over-boost is judged on boost_ext: COBB's float at FF64C8, the boost the
# Accessport logs. Until 2026-11-12 this rule read "boost > 22" and could never
# fire: the standard boost channel is one byte, (x-128)*37/255, and stops at
# 18.43 psi, so it sat here from the day it was written without ever being an
# alarm (docs/review-2026-10-03.md, R1). boost_ext has no such ceiling. The app
# now checks every rule in this file for exactly that when it starts, and says
# so in logs\app.log and at the top of the window.
#
# Like every COBB address, boost_ext is a pointer into this tune's RAM: check it
# against the Accessport's own log after a reflash (tools\compare-ap.py). On an
# ECU it was not measured on it is not read at all, and this rule is silent.
boost_ext    >  22
coolant      > 220
intake_temp  > 150

# Fuelling headroom and trims.
#
# The trims are how you ask "is it getting the fuel the map asked for" without
# knowing what the map asks for: if the engine were short, the short-term
# correction would sit positive under load and the long-term learning would
# follow it there.
#
# UNDER LOAD is the part that matters, and the gate is not optional. Off boost -
# overrun, trailing throttle, fuel cut - the correction legitimately swings to
# +-16 % and the front sensor is unreliable anyway; across the eleven logs of
# 2026-09-21 an ungated +-7 fired on 171 rows, all of it that. On boost the same
# correction lives inside -3.1 % to +5.5 %, so gated at +-7 it is a real limit
# that this engine has never tripped.
inj_duty     >  90
af_corr1     >   7     if boost > 3
af_corr1     <  -7     if boost > 3

# Adding this much fuel ANYWHERE is worth seeing wherever it happened. There is
# deliberately no matching negative rule: on a closed throttle the ECU cuts
# fuelling hard and the correction runs down to its -25 % clamp as a matter of
# course (8 rows of the 2026-09-21 logs, all of them coasting at -8 psi), so a
# large negative reading off boost is the car working, not a fault.
af_corr1     >  20

# Learning is slow and load-independent by nature: it is the ECU telling you it
# has decided the engine needs more or less fuel than the map says. Across those
# same logs it stayed inside -2.3 % to +4.7 %.
af_learn1    >   7
af_learn1    <  -7

# over-rev (the shift light is set on screen; this is the "way past it" warning)
rpm          > 7200

# oil, from the MTX-D gauge (defs/aux-gauge.txt). STARTING VALUES: set with the tuner.
# Pressure is gated on rpm because a stopped engine has none and that is not a
# fault; the gauge's own low-pressure warning is the number to copy here.
# run_s is seconds since the engine started, worked out from rpm (Danger.cs,
# RunClock). The oil pump needs a moment at every start while the revs flare
# past 1,500: on 2026-09-28 the oil read 0 psi until 2.8 s after the engine
# caught, and without this the rule fired at every start. 8 s leaves room for
# a slower start without hiding a real loss for long. (Since corrected: that
# "0 psi" was the gauge's last pre-crank reading held while it was silent -
# docs/review-2026-10-03.md, R2 - so the 8 s is a guess, not a measurement.)
# The gauge also reports ~0.12 s late (up to 0.28 s), so a rule on it fires
# only if its conditions held over the last 0.3 s (RuleJudge, lag_s in
# defs/aux-gauge.txt): a dip taken at idle no longer trips it as the revs climb,
# and a real loss at speed still fires on the first low reading.
oil_psi      <  12     if rpm > 1500 and run_s > 8
oil_temp     > 260
