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

[Task] SafeMode - dynamic configuration values. #28

Open
Gnuxie opened this issue Sep 23, 2024 · 0 comments
Open

[Task] SafeMode - dynamic configuration values. #28

Gnuxie opened this issue Sep 23, 2024 · 0 comments

Comments

@Gnuxie
Copy link
Member

Gnuxie commented Sep 23, 2024

Description

We can make recoverable introspectable config for #27 and make protection settings more robust by introducing "dynamic configuration values". This will basically be the successor the "ProtectionSettings", but more generic, as they will be used for Draupnir's account data too.

So there are two concepts. Dynamic configuration, and dynamic configuration values. The configuration represents the entire unit, so ProtectionSettings or the PolicyRoomsConfig. There are three states that a DynamicConfiguration can be in once it has parsed serialized data.

  1. Unable to deserialize from JSON at all, that's to say JSON.parse failed.
    • This includes schema migration issues.
  2. Specific configuration values fail to validate.
    • Collections either contain invalid values, or the collection has been replaced with another value, like number or string.
  3. All specific configuration values are valid.

This is not the end of the story however, as in the case of PolicyRoomsConfig we can discover bad data well after parsing. For example, a room reference could be valid according to the schema but may not refer to any reachable matrix room (ie, it is impossible to join the room because no servers know of its existence). We would need to present the value causing this error as invalid within the context of the DynamicConfigurationValue so that the user is able to remove it. To do this, we will have to provide iterators for DynamicConfigurationCollection that provide both the value and its path information (so that it can be reported easily and hopefully prompts can be provided in Draupnir to remove the value specifically).

Acceptance Criteria

  • DynamicConfiguration interface exists that allows you to parse a config from a JSON object.
    • It has methods for what to do if a JSON object cannot be obtained whatsoever.
  • DynamicConfigurationValue interface exists
  • DynamicConfigurationCollection interface exists.
  • Tangent, why is collection any different to DynamicConfiguration isn't it just a nested thing where the key is a number instead.
  • Tangent, aren't we just recreating schema but with better traceability for what went wrong? Probably.
  • Tangent How would we even unify collections and objects.
  • I don't think we can even worry about this stuff now tbh.
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

1 participant