agent-governance-toolkit icon indicating copy to clipboard operation
agent-governance-toolkit copied to clipboard

[Bug]: AuditLog exports silently truncate audit evidence after 10,000 entries

Open electricwolfemarshmallowhypertext opened this issue 2 months ago • 1 comments

Package

agent-governance-toolkit-core

Description

AuditLog.export() and AuditLog.export_cloudevents() silently return only the most recent 10,000 matching audit records. If the log contains 10,001 records, the earliest record is missing from the export. Neither method warns that records were omitted or provides pagination to retrieve the rest.

For an unfiltered export, export() also reports the Merkle root of the entire audit chain, despite including only part of that chain. An independent verifier therefore cannot reproduce the reported root from the exported records.

This produces incomplete audit evidence and breaks verification of larger exports. The original records remain in the log; the loss occurs in the exported output.

Both export methods should return all matching records, while the separate query() API should retain its existing result limits.

How does this impact your work?

I found this while testing whether audit exports contain every recorded event and can be independently verified. With 10,001 records, both export methods omit the earliest record, and the plain export’s reported Merkle root cannot be reproduced from the records it includes.

This prevents reliable full-log exports above 10,000 records. The stored records are still intact, so a workaround is to retrieve them directly with query() using a large enough limit and build the export manually. However, that requires custom handling, and the normal export methods give no warning that their output is incomplete.

Timeline

No response

Steps to Reproduce

  1. Use upstream commit 76099fb5d221b1c862e63cb727b4e2f47cf763be, without the local export fix.
  2. Create an AuditLog and add 10,001 entries using log(). Keep the first entry’s ID.
  3. Call export() without time filters. Check entry_count and the length of entries: both are 10,000, and the first entry is missing.
  4. Call export_cloudevents() without time filters. It also returns only 10,000 events, with the first entry missing.
  5. Independently rebuild the Merkle root from the plain export’s entry hashes. It does not match the reported merkle_root. Rebuilding from all 10,001 original entries does match.

Environment

  • Operating system: Windows 11, build 26200
  • Python: 3.12.10
  • PowerShell: 7.6.5
  • pytest: 8.4.2
  • Pydantic: 2.13.4
  • Component: AgentMesh, tested directly from the repository source
  • Commit tested: 76099fb5d221b1c862e63cb727b4e2f47cf763be
  • Setup: Local tests using an in-memory audit log; no external services required

Logs / Error Output

The export methods do not raise an error or warn that records are missing. These are the actual test failures before the fix:


test_export_includes_all_entries_and_reproducible_root

> assert exported["entry_count"] == 10001
E assert 10000 == 10001



test_cloudevents_export_includes_all_entries_and_hashes

> assert len(events) == 10001
E AssertionError: assert 10000 == 10001



2 failed, 13 deselected, 3 warnings in 2.15s


Both tests expected all 10,001 records. Each export returned only 10,000.

Code of Conduct

  • [x] I agree to follow the Microsoft Open Source Code of Conduct

Fix is ready in PR #4096. It removes the hidden 10,000-entry export cap while keeping query() bounded, with regression coverage for full export completeness and Merkle-root reproducibility.