buf-plugin-field-option-safe-for-ml

command
v0.6.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 24, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package main implements a plugin that implements two Rules:

  • A lint Rule that checks that every field has the option (acme.option.v1.safe_for_ml) explicitly set.
  • A breaking Rule that verifes that no field goes from having option (acme.option.v1.safe_for_ml) going from true to false. That is, if a field is marked as safe, it can not then be moved to unsafe.

This is an example of a plugin that will check a custom option, which is a very typical case for a custom lint or breaking change plugin. In this case, we're saying that an organization wants to explicitly mark every field in its schemas as either safe to train ML models on, or unsafe to train models on. This plugin enforces that all fields have such markings, and that those fields do not transition from safe to unsafe.

This plugin also demonstrates the usage of categories. The Rules have IDs:

  • FIELD_OPTION_SAFE_FOR_ML_SET
  • FIELD_OPTION_SAFE_FOR_ML_STAYS_TRUE

However, the Rules both belong to category FIELD_OPTION_SAFE_FOR_ML. This means that you do not need to specify the individual rules in your configuration. You can just specify the Category, and all Rules in this Category will be included.

To use this plugin:

# buf.yaml
version: v2
lint:
  use:
   - STANDARD # omit if you do not want to use the rules builtin to buf
   - FIELD_OPTION_SAFE_FOR_ML
breaking:
  use:
   - WIRE_JSON # omit if you do not want to use the rules builtin to buf
   - FIELD_OPTION_SAFE_FOR_ML
plugins:
  - plugin: buf-plugin-field-option-safe-for-ml

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL