Repository navigation
fix(agent-mesh): keep audit state consistent during concurrent writes - #4147
Conversation
Capture verification snapshots and publish audit entries with their agent/type indexes under the chain lock. Use one snapshot for service summaries and collector verification responses. Add deterministic regression coverage for concurrent appends, rollback, index publication, and response consistency. Signed-off-by: Electric Wolfe Marshmallow Hypertext <tionne@gmail.com>
|
Azure Pipelines: There may be pipelines that require an authorized user to comment /azp run to run. |
PR Review Summary
Verdict: AI review comments are untrusted advisory output. The summary reports workflow-generated completion status only, not model-authored pass/fail claims. |
MohammadHaroonAbuomar
left a comment
There was a problem hiding this comment.
Approving at 8c241a6. Verified in code and by probe: each entry and both indexes now publish under the one chain lock, and a failure in either the tree update or an index append rolls all of it back together (probed with the very first append and with the second index failing after the first succeeded: chain, both indexes and root end exactly as before, and the sink is not called); verify_chain, entry_count and summary() read one committed snapshot and verify outside the lock, so a rollback in progress can no longer produce a false integrity failure, which main did; the collector responses are byte-identical for the same log. Under two appenders and 43k summary samples, main reported a root that did not match its count 795 times; this branch never did. The 71 new tests are event-driven, and 40 of them fail against main's sources. No path takes the lock while holding it, sink writes stay outside it, and after this change I find no remaining unlocked reader of chain or index state in agent-mesh. All 123 checks are green.
Three optional follow-ups:
- audit.py:669 and :683: the indexed readers copy the whole entry list under the lock and then filter, which is O(n·limit); at 10k entries one read costs about 14 ms and two hot readers hold appends to about 540/s. Walking the list from the end with a set of the wanted ids, stopping once all are found, gives the same order and limit semantics at about 16 µs per read and appends near 1240/s.
- services/audit/init.py:138:
summary()reaches through_log._chain._snapshot()and_verify_entries; a publicverify_snapshot()onAuditLogreturning entries, root and validity would let the service and collector stop depending on chain internals. - audit.py:726: the
verify_integritydocstring still says "Always valid."
…microsoft#4147) Capture verification snapshots and publish audit entries with their agent/type indexes under the chain lock. Use one snapshot for service summaries and collector verification responses. Add deterministic regression coverage for concurrent appends, rollback, index publication, and response consistency. Signed-off-by: Electric Wolfe Marshmallow Hypertext <tionne@gmail.com> Signed-off-by: yuvrajsingh2428 <offcyuvi2428@gmail.com>
Related Issue
Fixes #4146
Problem & Solution
Concurrent writes can expose a pending entry during verification, leave agent/type indexes inconsistent with the committed chain, or produce service responses whose count and Merkle root describe different states.
This change:
Sink calls remain outside the chain lock. Public signatures and response shapes are unchanged.
Type of Change
Non-breaking bug fix.
Package Affected
AgentMesh (agent-mesh).
Testing
Regression coverage includes append rollback, concurrent index-bucket creation, reversed sink completion, sink failures and callbacks, index-publication failures, consistent service/collector snapshots, and existing corruption detection.
AI Assistance
Codex assisted with implementation, regression tests, and validation.