Skip to content

Add extra front-end types and make MainPodBuilder emit these#166

Merged
robknight merged 8 commits intomainfrom
robknight/custom-predicate-frontend
Apr 7, 2025
Merged

Add extra front-end types and make MainPodBuilder emit these#166
robknight merged 8 commits intomainfrom
robknight/custom-predicate-frontend

Conversation

@robknight
Copy link
Collaborator

@robknight robknight commented Mar 25, 2025

Closes #161

In order to allow for serialization of front-end versions of Custom Statements, it's necessary to include the definition of the matching Custom Deduction. This PR adds front-end types for custom predicate definitions, including statement templates.

Unfortunately this leads to some duplication of code already implemented in the middleware, for example for wildcard matching. This is needed in the front-end for MainPodBuilder, but the compiler also needs a version of the same thing for Operation::check. It's not a huge amount of code, but there is some risk that we change how the middleware works without changing how the front-end works, or vice versa. If we're intending to do a larger tidy-up of the code later then maybe we can decide what to do about this then.

@robknight robknight requested a review from ax0 March 25, 2025 18:54
@robknight robknight force-pushed the robknight/custom-predicate-frontend branch 2 times, most recently from 694a8b4 to 84d75fa Compare March 25, 2025 18:59
@arnaucube arnaucube requested a review from ed255 March 25, 2025 21:18
@arnaucube arnaucube added this to the Milestone 4 milestone Mar 25, 2025
Copy link
Collaborator

@ax0 ax0 left a comment

Choose a reason for hiding this comment

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

LGTM!

STB::new(NP::ValueOf)
.arg(("attestation_pod", literal(KEY_TYPE)))
.arg(PodType::MockSigned), // TODO
.arg(Value::from(middleware::Value::from(PodType::MockSigned))), // TODO
Copy link
Collaborator

Choose a reason for hiding this comment

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

These Value type conversions are getting out of hand.

@robknight robknight force-pushed the robknight/custom-predicate-frontend branch from 84d75fa to fac4ee7 Compare March 26, 2025 17:11
Copy link
Collaborator

@ed255 ed255 left a comment

Choose a reason for hiding this comment

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

LGTM!

STB::new(NP::ValueOf)
.arg(("attestation_pod", literal(KEY_TYPE)))
.arg(PodType::MockSigned), // TODO
.arg(Value::from(middleware::Value::from(PodType::MockSigned))), // TODO
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
.arg(Value::from(middleware::Value::from(PodType::MockSigned))), // TODO
.arg(middleware::Value::from(PodType::MockSigned)), // TODO

This also works, and it's a bit shorter.
But I agree with @ax0 that maybe the From implementations between types of the same name in frontend and middleware may be making the code harder to follow.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I'll explore enriching the middleware types with "metadata" so that we can avoid duplicating so many types in the frontend. #171

impl Origin {
pub fn new(pod_class: PodClass, pod_id: PodId) -> Self {
Self { pod_class, pod_id }
pub fn new(pod_id: PodId) -> Self {
Copy link
Collaborator

Choose a reason for hiding this comment

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

maybe we can remove the Origin type altogether?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I suggest we leave this for the refactor #171 so that we can move on with this PR now.

@robknight robknight merged commit a6cd02e into main Apr 7, 2025
4 checks passed
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.

Implement custom predicate types on the frontend

4 participants