Repository navigation
fix(heartbeat): degrade when the chain fails to verify or a configured anchor goes stale - #518
Merged
Merged
Conversation
…d anchor goes stale (#318) The beat already carried the trail head and Merkle root, but said success while the chain was broken or the external commitment had quietly stopped. - chain facts: verify_trail_tail over the newest 200 records each beat, bounded so the cost does not grow with trail age. Broken chain degrades with the failure message in the reason, loudest of the degrade causes. No trail yet attests chain_verified=null, not a degrade: a fresh machine and a tampered one must not read identically. - anchor facts: only for a log configured via AGENTMETRY_ANCHOR_LOG, since the sibling default sits on the same disk an attacker would rewrite and a machine that never anchored should not degrade forever. Newest applicable checkpoint older than AGENTMETRY_ANCHOR_STALE_MINUTES (default 1440, 0 disables) degrades; a configured log with no readable checkpoint for this trail degrades as silent. Checkpoints naming another trail are not scored, per the cry-wolf rule from verify_anchors. - Sigma: agentmetry_recorder_degraded matches any degraded beat, so the new causes flow into it; its description and field list now name them. pytest tests/test_heartbeat.py: 26 passed (10 new). Benchmark unchanged: 119 cases, 21 rules, 63 firings, 0 missed, 0 false positives. Ruff clean. Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <[email protected]>
…r tests Generated by Mistral Vibe. Co-Authored-By: Mistral Vibe <[email protected]>
This was referenced Nov 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #318.
What
The heartbeat already attested the trail head and Merkle root, but stayed
successwhile the local chain was broken or an operator's external anchor commitment had quietly stopped. Two new definite facts now degrade the beat:Chain verification. Each beat runs
verify_trail_tailover the newest 200 records: they must link, each hash must recompute, and the file must still end where the sidecar says the writer stopped. A full genesis walk isagentmetry verify's job; the tail is where appends, crashed writes and tail deletions land, at a cost bounded by the window and not by trail age. Broken chain degrades withLOCAL CHAIN FAILED TO VERIFY: <message>as the loudest degrade reason. A machine with no trail yet attestschain_verified: null, not a degrade: a fresh install and a tampered one must not read identically.Anchor staleness. Only a log configured via
AGENTMETRY_ANCHOR_LOGis checked: the sibling default sits on the same disk an attacker would rewrite, and a machine that never anchored should not degrade forever. The newest checkpoint applicable to this trail older thanAGENTMETRY_ANCHOR_STALE_MINUTES(default 1440,0disables the age check) degrades the beat; a configured log with no readable checkpoint for this trail degrades as silent. Checkpoints naming a different trail are skipped rather than scored, the same cry-wolf ruleverify_anchorsalready follows.The Sigma rule
agentmetry_recorder_degradedmatches any degraded beat, so both new causes flow into existing customer detections; its description and field list now name them.Why it is shaped this way
degradedstays a definite claim: only failures that say the record or the commitment are impaired set it, never an unconfigured or absent anchor.policy_rejectedalready meets (locations an admin chose, never developer content).Evidence
pytest tests/test_heartbeat.py: 27 passed (10 new: healthy chain attests verified; tampered record degrades with the failure message; no trail is not a tamper alarm; fresh anchor stays green; stale anchor degrades; configured-but-silent log degrades; another trail's checkpoints are not scored; sibling default is not the beat's business; the limit is configurable and 0 disables)pytest tests/test_trail_anchor.py tests/test_trail_chain.py tests/test_coverage_observed.py tests/test_supply_chain_boundaries.py tests -k sigma: all passpython -m agentmetry.cli benchmark: 119 cases, 21 rules, 63 firings, 0 missed, 0 false positives (detection untouched)ruff check agentmetry tests: clean