Skip to content
BETAGuardrails are in beta. The library, the configuration format and the CLI command can still change.

Guardrails / Collectors

Repository files

Presence, size and line counts of the well known files a repository is expected to carry, plus any extra path the guardrail asks for.

Facts keyfiles
Versionv1
Scriptfiles.py
Timeout30 seconds

Inputs

InputDescriptionDefaultEnvironment
pathsComma separated paths to describe, relative to the directory the CLI runs in.README.md,README.rst,LICENSE,LICENSE.md,CONTRIBUTING.md,CODE_OF_CONDUCT.md,SECURITY.md,.gitignoreGUARDRAIL_INPUT_PATHS
pathOne further path to describe, so a guardrail configured with its own path is collected too.``GUARDRAIL_INPUT_PATH

A guardrail that declares an input of the same name passes it through, so the guardrail's configuration in buildnote.json is what decides these values.

A guardrail asks for these facts by name, and reads them back the same way:

json
{
  "collect": ["files"]
}
python
files = guardrail.facts("files")

Facts

The document files collects. A path carrying [] is an entry of the list before it, and one carrying [path] is a key of the object before it.

FactMeaning
filesEvery requested path, by path exactly as it was asked for. A path nobody asked for is absent, so read the one the guardrail configured rather than iterating.
files[path].presentWhether the path is a file.
files[path].bytesSize in bytes. Absent when the file is not present or could not be read.
files[path].linesLine count. Absent when the file is not present or could not be read.
files[path].nonBlankLinesLines carrying something other than whitespace. Absent when the file is not present or could not be read.
files[path].unreadableWhy the file could not be read, present only when it could not be.

A collector that cannot finish prints what it had along with an incomplete key saying why, so the facts below the point it stopped are absent. A check that cares reads incomplete before the rest.

Example facts

The example facts collected by files collector:

json
{
  "files": {
    "README.md": {
      "present": true,
      "bytes": 22,
      "lines": 3,
      "nonBlankLines": 2
    },
    "README.rst": {
      "present": false
    },
    "LICENSE": {
      "present": true,
      "bytes": 12,
      "lines": 1,
      "nonBlankLines": 1
    },
    "LICENSE.md": {
      "present": false
    },
    "CONTRIBUTING.md": {
      "present": false
    },
    "CODE_OF_CONDUCT.md": {
      "present": false
    },
    "SECURITY.md": {
      "present": false
    },
    ".gitignore": {
      "present": true,
      "bytes": 7,
      "lines": 1,
      "nonBlankLines": 1
    }
  }
}

Collected for

GuardrailCategoryInputs
build/dependency-updates-configuredbuildpaths
docs/agent-instructionsdocspaths
docs/changelogdocspath
docs/code-of-conductdocspath
docs/contributingdocspath
docs/license-presentdocspaths
docs/readmedocspath
docs/security-policydocspath
secrets/gitignore-presentsecretspath
secrets/no-credential-files-committedsecretspaths

All collectors

Buildnote Limited
Registered in England and Wales, Reg: 16140412