Files
AutopilotMonitor/rules/dist
Oliver Kieselbach 6007b9ecc5 fix(rules,web): pin rule template interpolation to the required-condition event
Codex review (P2): ANALYZE-APP-013's `failed_app_name` + `detection_hresult`
optional conditions scanned all app_install_failed events independently of
the required condition. In a session with multiple app failures the
template could interpolate {{appName}} / {{errorCode}} from a different
event than the one that matched `failureType == esp_apps_detection_failure`.

Two coordinated changes:

1. `interpolateRuleTemplate` gains an "auto-field" resolution tier between
   the explicit byField path and the bySignal fallback. The backend's
   `RuleEngine.AddDataFieldsToEvidence` already injects a whitelist of
   identifying fields (appId, appName, errorPatternId, errorCode, exitCode,
   status) onto every matched-condition evidence dict — the interpolator
   now reads those, pinning to the FIRST matched condition (= the required
   condition) so a rule with a single required match resolves all four
   tokens against the same source event.

2. ANALYZE-APP-013 is trimmed to a single required condition; the redundant
   optional conditions for appName / errorCode are removed because the
   auto-field tier already exposes them from the required match. Same
   pattern applied to ANALYZE-ENRL-001's `failed_app` condition.

Coverage: 4 new vitest cases (multi-failure correct interpolation, first-
condition-wins shadowing, explicit-field precedence, internal-field leakage
guard). 413/413 web tests.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-28 14:10:03 +02:00
..
2026-04-07 09:47:59 +02:00