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

Versioning Constraints - DON'T MERGE without UI #1278

Merged
merged 10 commits into from
Feb 29, 2024

Conversation

Mythicaeda
Copy link
Contributor

@Mythicaeda Mythicaeda commented Jan 11, 2024

Description

This PR is essentially an overhaul of how constraints were represented in the DB.

Below is a breakdown of the changes. Keep in mind when discussing permissions that unless a permission explicitly addresses the aerie_admin role, assume that it doesn't apply.

  1. The constraints table has been replaced by the constraint_metadata and constraint_definition tables. The constraint_definition table contains the various versioned definitions of a constraint, while constraint_metadata contains the metadata consistent across all definitions (ie the name of the constraint). Once a version is created, it can only be updated by an admin user. The owner of a constraint can freely delete unused versions (see 3). Any user can create versions of public constraints (see 2). Both the overall constraint and each specific version can be tagged.
  2. There is now the concept of public vs private constraints. All constraints start private unless otherwise specified and can be freely toggled between public and private. All public constraints must have unique names, but private constraints can have names that overlap. Only the owner of a private constraint can make new versions, and any user can make new versions of a public constraint. Only the owner of a private constraint can add it to constraint specifications (see 3), but once a private constraint has been added, any user able to edit the specification can freely manage the entry on the specification. Any user can add public constraints to constraint specifications they have permissions to manage. A constraint cannot be SELECTed unless it is public, or the user doing the SELECT either owns the constraint or can manage a constraint specification it is on.
  3. There is now the concept of a model and plan constraint specification, which replaces the former concept of "model constraints" and "plan constraints". A model specification is a recommended set of constraint and constraint versions for all plans using the model. A plan specification is the set of constraints that are checked during the action. If no version is specified (referred to as "version locking" in the tests), the latest version will be used. If a constraint is disabled on the specification, it will not be checked. When a plan is created, its constraint spec is prepopulated with the constraint spec of its model.

QUICK LIST BREAKING CHANGES:

  • The structure of the return type for the CheckConstraints action has been altered:
    • the type field has been removed
    • the constraintRevision field has been added
  • The constraints table has been split into two tables: constraint_metadata and constraint_definition. Additionally, plans and models now have constraint specifications. Any GQL queries referencing the constraints table will now need to reference at least one of these four tables, with which specific one varying based on what the query was doing.

Verification

DB Tests:

  • The DB Tags Tests were updated to test the new tags table
  • Inserting a constraint in the DB has been updated to not depend on plans

e2eTests:

  • Tests that checked/depended on definitionOutdated were removed
  • ConstraintsTests for versioning and enabling/disabling constraints were added

Documentation

Open Docs ticket

Future work

Scheduling Goals need to be changed in a similar way

@Mythicaeda Mythicaeda added breaking change A change that will require updating downstream code feature A new feature or feature request constraints Anything related to the constraints domain database Anything related to the database labels Jan 11, 2024
@Mythicaeda Mythicaeda self-assigned this Jan 11, 2024
@Mythicaeda Mythicaeda requested a review from a team as a code owner January 11, 2024 21:02
@Mythicaeda Mythicaeda requested review from mattdailis and removed request for joswig January 11, 2024 21:04
@Mythicaeda Mythicaeda force-pushed the feat/version-constraint-goals branch from b29a4b1 to 5db94c3 Compare January 11, 2024 22:01
@Mythicaeda Mythicaeda force-pushed the feat/version-constraint-goals branch from 5db94c3 to 6c81e85 Compare January 11, 2024 22:34
@Mythicaeda Mythicaeda force-pushed the feat/version-constraint-goals branch from 6c81e85 to 71ff624 Compare January 11, 2024 23:35
@dandelany dandelany changed the title Versioning Constraints Versioning Constraints - DON'T MERGE without UI Jan 18, 2024
@Mythicaeda Mythicaeda force-pushed the feat/version-constraint-goals branch from 71ff624 to b1632e5 Compare January 22, 2024 18:41
@Mythicaeda
Copy link
Contributor Author

Change just pushed was to tweak the Hasura Metadata to allow users to add and view all constraints on the plan's model spec, even if they are private. Users would've had issues when syncing their plan to the model spec without this change.

- Update Tests in TagsTests
- Add functions in TagsTests for applying/fetching tags on a constraint definition
- Update inserting a constraint in MerlinDBTestHelper
- remove ConstraintType
- add constraintRevision
- remove MissionModelRepository.getConstraints
- rename getAllConstraintsInPlan to getPlanConstraints
- Update and Add GQL queries related to constraints
- Update types
- Add ConstraintsTests for versioning and enabling/disabling constraints
- Remove tests that checked `definitionOutdated`, which doesn't exist anymore
@Mythicaeda Mythicaeda force-pushed the feat/version-constraint-goals branch from c8bbb03 to a22e725 Compare February 28, 2024 23:50
@Mythicaeda Mythicaeda merged commit df597af into develop Feb 29, 2024
10 checks passed
@Mythicaeda Mythicaeda deleted the feat/version-constraint-goals branch February 29, 2024 00:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change A change that will require updating downstream code constraints Anything related to the constraints domain database Anything related to the database DON'T MERGE Do Not Merge This Branch feature A new feature or feature request
Projects
None yet
2 participants