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

Procedural constraints annotation processor + build logic #1611

Open
wants to merge 8 commits into
base: develop
Choose a base branch
from

Conversation

skovati
Copy link
Contributor

@skovati skovati commented Nov 22, 2024

Description

This PR does a few things related to procedural constraints workflow:

  • creates the ConstraintProcedure annotation and handles it together with scheduling procedures in the same processor.
  • Modifies the procedure-building gradle script to do scheduling and constraints procedures together.
  • Implements the EditablePlan, Plan, and SImulationResults interfaces for stateless-aerie plan objects.
  • Creates a basic test constraint ObeyConservationOfBanana and tests it using plan stubs and stateless simulation. This is less a test of the constraint itself, and more a test-that-testing-is-actually-possible kind of thing.

Verification

Documentation

I still need to update the procedural constraints docs.

Future work

We now have nearly everything for a full-loop external scheduler run. Once we make a plan serializer, you could make a driver that loads a plan from file, runs a series of constraints and goals (with simulation), and outputs a result plan.

@Mythicaeda
Copy link
Contributor

This PR is currently orphaned, pair programming hosted by @mattdailis prior to handoff.

This PR has compiled a constraint w/o arguments, so it's potentially close.

@JoelCourtney to add example constraints to this branch

Decision to be made: support non-records or updating docs? @JoelCourtney proposing to just update docs and allow non-records later.

Let's start with only records and double-back for non-record support.

@JoelCourtney JoelCourtney force-pushed the feature/procedural-constraints-processor branch from db9d10f to 4dc61a6 Compare February 11, 2025 23:52
@JoelCourtney
Copy link
Contributor

State of PR:

The annotation processor worked without any extra work. It was actually so good at combining the scheduling / constraints workflows that the gradle task can't tell them apart, and the original buildAllSchedulingProcedureJars task would build the constraints as well. So I've just removed the Scheduling, making it buildAllProcedureJars. I don't see why the user would need separate workflows for them anyway. The annotation processor does still generate different value mapper types for goals & constraints. Since this gives us a bit of type safety during procedure loading, I figured I'd leave it and not combine them. So:

  • two different annotations
  • one annotation processor
  • two value mappers
  • one gradle command

I haven't made the equivalent of the scheduler's Procedure.java for constraints. I'm not sure that's included in this task, but I can work on it because it seems like the logical next step.

@JoelCourtney JoelCourtney marked this pull request as ready for review February 12, 2025 22:54
@JoelCourtney JoelCourtney requested a review from a team as a code owner February 12, 2025 22:54
@JoelCourtney JoelCourtney requested a review from jmdelfa February 12, 2025 22:54
@JoelCourtney JoelCourtney force-pushed the feature/procedural-constraints-processor branch from 29b501a to 60626ae Compare March 11, 2025 22:20
@JoelCourtney JoelCourtney force-pushed the feature/procedural-constraints-processor branch from 60626ae to aea67e7 Compare March 11, 2025 23:32
@JoelCourtney JoelCourtney force-pushed the feature/procedural-constraints-processor branch from aea67e7 to b2ee0d9 Compare March 11, 2025 23:36
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
5.5% Duplication on New Code (required ≤ 3%)

See analysis details on SonarQube Cloud

while(currentAnchorId != null && anchoredToStart){
currentActivityDirective = completeMapOfDirectives.get(currentAnchorId);
currentAnchorId = currentActivityDirective.anchorId();

if (currentAnchorId.equals(firstId)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line needs to be reversed to avoid a NPE: if(firstId.equals(currentAnchorId)

This is because we know for a fact that firstId is not null, as we otherwise wouldn't have entered the while loop, but we expect currentAnchorId to become null at some point, assuming there is no cycle.

Copy link
Contributor

@Mythicaeda Mythicaeda Mar 14, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Additionally, I'm not sure if tracking a single id (as opposed to the set of all seen ids so far) is sufficient to detect a cycle, as the cycle may start further up than the initial directive id. If it is, could you please break down why it is?

For context, the database uses the "set of all seen ids" approach to detecting cycles.

Set proposal based on what I did to get tests working on my branch:

final var seenIds = new HashSet<ActivityDirectiveId>();
seenIds.add(currentAnchorId);

while(currentAnchorId != null && anchoredToStart){
    currentActivityDirective = completeMapOfDirectives.get(currentAnchorId);
    currentAnchorId = currentActivityDirective.anchorId();

    if (seenIds.contains(currentAnchorId)) {
        throw new IllegalStateException("Anchor ID cycle detected on " + currentAnchorId);
    }
//...

Mythicaeda added a commit that referenced this pull request Mar 14, 2025
This fix belongs in #1611 but I want tests on my branch to pass
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

Successfully merging this pull request may close these issues.

Annotation Processor updates for Procedural Constraints
3 participants