fix(agent-mesh): decay trust for agents without a positive signal #4297
All Vouch review confidence checks passed
Residual risk 0.21 = Change Risk (0.52) × (1 − Review Confidence (0.60)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.52 · 650 lines diff across 8 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.388
Shallow Review Depth
shallow_review_depth
0.289
Real PR Conversation Timeline
1 comments
"Review active on #4297"
general
weight: 0.35
MohammadHaroonAbuomar
Related Issue
None. This is a bug I found in
agentmesh.reward.trust_decay.NetworkTrustEngine; the sections below are filled in as the template asks.Problem & Solution
Problem. Spec §12.1 (
docs/specs/AGENTMESH-IDENTITY-TRUST-1.0.md) says trust scores MUST decay over time when no positive signals are received.apply_temporal_decay()measures idle time from the later of the last positive signal and the last decay pass. For an agent that never had a positive signal it usesself._last_positive.get(agent_did, now), so the start time is always the current pass,hours_sinceis 0, and_last_decayis never written. On main, an agent whose score came only fromset_score()orprocess_trust_event()never decays, however long the timer runs:Agents with no positive signal are the ones decay is meant for, but they are exempt. An agent that has had one positive signal does decay.
Solution. When decay sees an agent with neither a positive signal nor a previous decay pass, it records that pass as
_last_decayand skips it. Later passes measure from there, using the samemax(last positive, last decay)logic added in #4161. So:test_no_decay_for_newly_registered_agentis unchanged and passes);decay_rateper hour, down to the existing floor of 100;Agents that already have a positive signal behave exactly as before.
Impact on Your Work
An agent that misbehaves and never earns a positive signal keeps its score indefinitely, while a well-behaved agent that earned one bonus decays. Scores of idle, unproven agents never move toward the revocation and warning thresholds the decay is supposed to push them to.
Timeline
None.
Alternatives Considered
set_score()/ when the score is first created. That would measure from the agent's real first appearance, butset_score()runs on every score change, and the existing tests set_last_positiveafterset_score()with explicitnowvalues, which a wall-clock timestamp written inset_score()would override. Starting at the first decay pass keeps the change insideapply_temporal_decay(), the only place that reads these timestamps.-infonly. That would charge an unbounded number of hours on the first pass and send every new agent straight to the floor.Type of Change
Package(s) Affected
Testing
Unit Testing
tests/test_trust_decay.py::TestDecayOverTime:test_agent_without_positive_signal_decays_after_first_pass: no decay on the first pass, then 790 after one hour and 780 after two.test_agent_hit_by_trust_event_decays_without_positive_signal: a score created only byprocess_trust_event()(490) decays to 460 three hours after the first pass.test_positive_signal_after_first_pass_restarts_the_clock: a positive signal after the first pass is still what decay measures from.The first two fail on main and pass here. The third passes on both and guards the interaction with positive signals.
Manual Testing
tests/test_trust_decay.pyandtests/test_spec_identity_trust_conformance.py: 195 passed.test_renewed_credential_extends_expiry,test_handshake_with_freshness_bypasses_cache,test_auto_release_after_duration.ruff checkreports the same 38 pre-existing findings (typing-style UP rules and an import-order finding in the test) on main and on this branch, none on the changed lines.Checklist
Attribution & Prior Art
AI Assistance
I used Claude Code (Claude Opus) to help find the bug and draft the fix and tests. I reviewed the full diff and will handle review comments myself.
IP, Patents, and Licensing
🤖 Generated with Claude Code