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

A proposal for a more comprehensive CLI property interface #38

Merged
merged 12 commits into from
Sep 18, 2023

Conversation

JustusAdam
Copy link
Collaborator

What Changed?

Expands the cli function to a two-step workflow that includes running the dfpp graph generation and then reading that graph for property enforcement.

Why Does It Need To?

Simplifies running properties to a single command as graph generation can be integrated and use some automatic configuration. At the same time leaves all control to the user still which can opt to run custom graph generation commands or do them completely manually.

Checklist

  • Above description has been filled out so that upon quash merge we have a
    good record of what changed.
  • New functions, methods, types are documented. Old documentation is updated
    if necessary
  • Documentation in Notion has been updated
  • Tests for new behaviors are provided
    • New test suites (if any) ave been added to the CI tests (in
      .github/workflows/rust.yml) either as compiler test or integration test.
      Or justification for their omission from CI has been provided in this PR
      description.

@JustusAdam JustusAdam changed the title A proposal for a more complrehensive CLI property interface A proposal for a more comprehensive CLI property interface Sep 15, 2023
@JustusAdam
Copy link
Collaborator Author

While this is making this PR multi-concern I did sketch your diagnostics approach @willcrichton. What do you think?

@willcrichton
Copy link
Collaborator

Yeah this is basically what I was thinking. Re: your point about multi-property concurrency, this might also be a good time to implement multiple properties for one app. One way to do this is to give each property a unique name, and make the diagnostics a HashMap<String, Mutex<Vec<Diagnostic>>> or something like that.

@JustusAdam
Copy link
Collaborator Author

Maybe but I think we should merge this first and do that in a second step.

@JustusAdam
Copy link
Collaborator Author

I'd imagine an ergonomic way to do that is to have a .policy(name) method that returns some sort of wrapper around Context which automatically adds the name to the properties.

@JustusAdam JustusAdam merged commit 70ca09a into main Sep 18, 2023
4 checks passed
@JustusAdam JustusAdam deleted the cli-interface-proposal branch September 18, 2023 19:20
JustusAdam added a commit that referenced this pull request Oct 2, 2023
## What Changed?

Implements a suggestion from #38.

Adds the ability to register simple context information, such as the
currently executing policy or combinator with the `Context` that is
emitted as part of the diagnostics.

For instance the named policy `community-safety` in a hypothetical
combinator `reaches` would output diagnostics such as:

```
[policy: community-safety] [reaches] Vacuous: no nodes matching starting conditions
```

This is achieved by transparently attaching diagnostic context. 

First off the `error` and `warning` convenience methods on `Context`
still work. Both are now part of the `Diagnostics` trait,

The trait is also implemented on `PolicyContext`, which is created by
`Context::named_policy()` an transparently attaches the name of the
policy to all diagnostic messages emitted from it. It `Deref`s to
`Context` so all if its functionality is included.
Both `Context` and `PolicyContext` can also create a `CombinatorContext`
with the `named_combinator()` method that attaches a combinator name.
`CombinatorContext` also `Deref`s to `Context`.


## Why Does It Need To?

Right now every diagnostic message has to track where it occurs. By
adding this way of accumulating contextual information we can, for
instance, have a combinator like `always_happens_before` interrogate
itself and dispatch generic diagnostics which are then enriched with
contextual information, making them more specific and understandable
again.

## Checklist

- [x] Above description has been filled out so that upon quash merge we
have a
  good record of what changed.
- [x] New functions, methods, types are documented. Old documentation is
updated
  if necessary
- [x] A module level documentation section for how to use diagnostic
context
- [ ] Documentation in Notion has been updated
- [ ] Tests for new behaviors are provided
  - [ ] New test suites (if any) ave been added to the CI tests (in
`.github/workflows/rust.yml`) either as compiler test or integration
test.
*Or* justification for their omission from CI has been provided in this
PR
    description.
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.

2 participants