Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Non-deterministic output of Authorizer.dump_code() #193

Closed
divarvel opened this issue Oct 30, 2023 · 2 comments
Closed

Non-deterministic output of Authorizer.dump_code() #193

divarvel opened this issue Oct 30, 2023 · 2 comments

Comments

@divarvel
Copy link
Collaborator

divarvel commented Oct 30, 2023

Facts are stored as a HashMap internally, so their order is not defined.

The Display impl for Authorizer does sort everything, so it has a stable output. It also adds more information in comments (namely the facts and rules origins, which is extremely important).

I guess we could just call .to_string() in dump_code() to keep backwards compatibility. However, the Display implementation for Authorizer only uses facts and rules from the Datalog::World value, so it may discard facts and rules added to the authorizer before calling authorize. I guess that overlaps with #192

@divarvel
Copy link
Collaborator Author

divarvel commented Oct 31, 2023

I am working on a fix for missing facts and rules in Authorizer.to_string()

@Geal
Copy link
Contributor

Geal commented Nov 29, 2024

Fixed by #250
The most reasonable approach was to call .to_string() before sorting, because making an Ord implementation for Fact implied messing with parameters

@Geal Geal closed this as completed Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants