10 Commits
Author SHA1 Message Date
patrickandClaude Opus 5.5 16338a2507 fix(healing): judge post-heal verification against the pre-heal decisions
CI / Unit tests (push) Successful in 3s
CI / Unit tests (pull_request) Successful in 3s
A decision issued in the seconds between a heal and its verification is
missing from the kernel until the bouncer's next poll, so verification
reported the heal as failed even though it had fixed the drift it was
started for. Seen on a node: a metadata heal fixed a stale TTL, a new
ban arrived inside the 5 s window, and the heal was logged as failed;
the next audit found the node in sync.

reconcile() now records the decision values it saw (last_truth_values)
and takes an optional baseline_truth. Post-heal verification passes the
values the drift was found against; values whose LAPI membership changed
since then are left out of the drift, logged with a count, returned as
lapi_changed_values, and checked by the next regular audit. Drift on
decisions that existed when the heal started still fails verification.
The regular audit and the membership re-check are unchanged.

Tests: baseline handling in reconcile, the verification call, and a
replay of the logged sequence (failed before, success now). 78 tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-13 23:32:41 -05:00
patrickandClaude Opus 5.5 772892b78d feat(healing): re-check membership mismatches before healing
A decision created moments before an audit shows up as missing=1 until
the bouncer's next poll, which triggered a bouncer restart for nothing.

When the audit finds a membership mismatch, wait membership_recheck_delay
seconds (default 30, 0 disables) and audit again; only drift that is still
present is reported and healed. Metadata drift is not delayed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-13 19:38:39 -04:00
patrick f5615faeae fix(healing): normalize history timestamps to UTC in heal flap gate 2026-03-06 22:31:24 -05:00
patrick 3b1e25d5cd feat(reporter): add uptime and fleet counters to state snapshot 2026-03-05 20:57:16 -05:00
patrick b34ac69ac1 feat(reporter): persist drift metrics and last heal result in state snapshot 2026-03-05 20:35:18 -05:00
patrick 9b53a4c491 fix(healing): handle post-heal verify exceptions without crashing loop 2026-03-01 21:14:59 -05:00
patrick 9edce6b31d perf(healing): scan heal history from file tail instead of full read
- add tail-based HEAL line lookup to avoid O(file-size) reads in should_heal()
- keep a safe fallback full scan when no HEAL marker is found in tail window
- add regression test for large history files with recent HEAL marker
2026-03-01 21:12:55 -05:00
patrick 0f7f03f005 Fix metadata-drift healing by flushing CrowdSec nft sets before restart
Add drift-aware heal path in FirewallAuditor to remediate metadata drift by discovering and flushing
  *-cscli sets in crowdsec/crowdsec6 tables, then restarting the bouncer.

Update execute_heal_and_verify to pass drift context to heal_with_drift when supported, keeping
  backward compatibility via heal().

Add unit tests covering metadata-drift flush+restart behavior, non-metadata restart-only behavior,
  and drift context propagation.
2026-02-25 14:59:44 -05:00
patrick 480eea8095 refactor(agent): split orchestration into config, healing, and main modules 2026-02-10 22:11:33 -05:00
patrick 5fc5b8c114 test(agent): add coverage for drift gating and post-heal verification; remove bare except 2026-02-10 22:04:57 -05:00