Documentation
Table of Contents

Class GuardrailSourceOptions

Namespace
IntentSharp.Guardrails
Assembly
IntentSharp.Guardrails.dll

Settings for reading rule files from a document store: where the manifest is, which documents are pinned to a hash, the kinds, subjects and settings a rule file may name beyond the library's own, and the code layer of the settings. Used by DocumentGuardrailSource, RuleDocumentValidator and GuardrailFiles, which copy the values when they are created, so a later change does not reach them.

public sealed class GuardrailSourceOptions
Inheritance
object
GuardrailSourceOptions
Inherited Members
object.Equals(object)
object.Equals(object, object)
object.GetHashCode()
object.GetType()
object.ReferenceEquals(object, object)
object.ToString()
Extension Methods

Remarks

A kind, subject or setting a rule file names must also be known to the client that checks the rules: AddGuardrails(IServiceCollection, IDocumentStore, Action<GuardrailSourceOptions>, params string[]) and WithGuardrailFiles(IntentClientBuilder, IDocumentStore, Action<GuardrailSourceOptions>, params string[]) pass what is declared here, and the code settings, to the client as well. Declare each one in one place: here, in the service collection, or on the builder with AddSetting(SettingDescriptor) and AddSubject(SubjectDescriptor), which WithGuardrailFiles passes to its source and validator when the client is built. The same descriptor (the same object, or one equal in every property) declared in two of those places is one declaration.

Constructors

GuardrailSourceOptions()

Creates the options with the default manifest and nothing pinned or declared.

Properties

CodeSettings

The code layer of the settings, by setting name: what a setting takes when no file sets it, as CodeSettings is for a client. The source reads rules.ambiguousSet here when the settings document in its store does not set it, and WithGuardrailFiles(IntentClientBuilder, IDocumentStore, Action<GuardrailSourceOptions>, params string[]) and AddGuardrails(IServiceCollection, IDocumentStore, Action<GuardrailSourceOptions>, params string[]) pass every value to the client's code layer as well. Each name must be a declared setting and each value one the setting takes.

ExpectedHashes

Documents pinned to a content hash, by path: the store's content hash of the running version each must have. Opt-in; empty pins nothing. When a pinned document's running version has another hash, or none, the source stops serving rules: Current throws a GuardrailLoadException naming both hashes, so every check that names a set is refused until the document is reverted or the pin is changed. The manifest, a rule file and a compiled companion may each be pinned.

Kinds

Custom kinds a rule may use, each with a name that contains a dot, such as acme.luhn. A rule whose kind is neither built in nor listed here is a load problem.

Manifest

The manifest: the document that lists, in order, the rule files to read. No folder is ever scanned; a rule file is read only when the manifest lists it. The default is intentsharp.guardrails.json at the root of the store. Its .json, .yaml and .yml spellings are the same manifest, and two of them in the store at once is a problem that keeps the last good list.

Settings

Settings declared beyond the core settings, which a rule file's settings: block may set. A setting declared nowhere is a load problem.

Subjects

Subjects declared beyond the core subjects, such as a target's own subjects. A rule on a security subject cannot be detect-only, and an edit that widens a rule on one is flagged; a rule on a subject declared nowhere is accepted, since a target declares its subjects when it is checked, and an edit that widens it is flagged as well.