Skip to content

fix: deterministic sorting in AuditChainService - Closes #1525 #1526 - #1618

Open
PremSahith wants to merge 1 commit into
viru0909-dev:mainfrom
PremSahith:main
Open

fix: deterministic sorting in AuditChainService - Closes #1525 #1526#1618
PremSahith wants to merge 1 commit into
viru0909-dev:mainfrom
PremSahith:main

Conversation

@PremSahith

Copy link
Copy Markdown
Contributor

Pull Request

Description

This PR fixes the non-deterministic sorting issue in AuditLogRepository that was causing intermittent false-positive "Chain broken" alerts in AuditChainService.verifyChain().

The original sorting logic only ordered by timestamp, which returned concurrent identical timestamp entries in a non-deterministic order. I've appended Id as a secondary deterministic sort criterion to the repository methods and updated the service/tests to ensure the retrieval sequence always matches the stable sequence required by the Merkle hash chain.

Closes #1525 #1526

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Checklist:

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@PremSahith
PremSahith requested a review from viru0909-dev as a code owner July 17, 2026 06:14
@vercel

vercel Bot commented Jul 17, 2026

Copy link
Copy Markdown

@PremSahith is attempting to deploy a commit to the CodeBlooded's projects Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions

Copy link
Copy Markdown
Contributor

Hi @PremSahith, thanks for contributing to Nyay Setu! 🎉

I have automatically:

  • 👤 Assigned this PR to you.
  • 🏷️ Applied the gssoc:approved label.

Our workflows will now analyze your changes to classify:

  • 📈 PR Difficulty: level:*
  • 🧩 PR Type: type:*
  • 🌟 PR Quality: quality:*

Tip

Ensure your PR description references the issue it resolves (e.g. Closes #123). This allows the bot to inherit any additional labels from that issue!

Happy coding! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG]: Non-deterministic sorting in AuditChainService causes intermittent chain verification failures

1 participant