Skip to content

Validate profiles inside rc, as data, with no per-extension types - #13

Merged
colinjlacy merged 2 commits into
runtimeconditions:mainfrom
itvi-1234:validate-in-rc-cli
Nov 16, 2026
Merged

colinjlacy merged 2 commits into
runtimeconditions:mainfrom
itvi-1234:validate-in-rc-cli

Conversation

@itvi-1234

Copy link
Copy Markdown
Member

rc profile validate used the validator of go-rc-profiler, which is part of one language's profiler. The validator needs only the profile, the core profile schema and the extension definitions, so it now lives in rc, in internal/validate, where every profiler's output can use it.

The profile is checked against the core profile schema, which the build embeds after checking its SHA-256 (scripts/build.go). A build without the schema refuses to validate instead of calling a profile valid. That covers the profile's own fields (apiVersion, kind, metadata, workload), the shape of the extension list, and that every condition has a kind and an interface type.

Beyond that the validator knows nothing about any extension. Everything else comes from the definitions of the extensions the profile declares:

  • every other field of a condition has to be defined for its kind and interface type by one of the declared extensions, which also catches a field used without declaring its extension;
  • an interface field that an extension defines has to be defined for the condition's kind and type;
  • where extensions enumerate the values of a field path such as interface.operations[].method or configuration.env[].property, every string at that path has to be one of them;
  • the extension schemas are applied to the condition as written;
  • a profile has to name the whole dependency closure of its extensions.

An extension can give a field any shape (a string, a list of strings, a list of objects, nested lists) and a new extension needs no change here.

The tests use made-up extensions and a made-up core schema, not real ones, and cover each shape, malformed input, the core fields, the definition checks, catalog loading, 400 random combinations of shapes, and a fuzz test. The command's own tests use the same made-up extensions.

rc profile validate used the validator of go-rc-profiler, which is part of one language's
profiler. The validator needs only the profile, the core profile schema and the extension
definitions, so it now lives in rc, in internal/validate, where every profiler's output can use it.

The profile is checked against the core profile schema, which the build embeds after checking its
SHA-256 (scripts/build.go). A build without the schema refuses to validate instead of calling a
profile valid. That covers the profile's own fields (apiVersion, kind, metadata, workload), the
shape of the extension list, and that every condition has a kind and an interface type.

Beyond that the validator knows nothing about any extension. Everything else comes from the
definitions of the extensions the profile declares:
- every other field of a condition has to be defined for its kind and interface type by one of the
  declared extensions, which also catches a field used without declaring its extension;
- an interface field that an extension defines has to be defined for the condition's kind and type;
- where extensions enumerate the values of a field path such as interface.operations[].method or
  configuration.env[].property, every string at that path has to be one of them;
- the extension schemas are applied to the condition as written;
- a profile has to name the whole dependency closure of its extensions.

An extension can give a field any shape (a string, a list of strings, a list of objects, nested
lists) and a new extension needs no change here.

The tests use made-up extensions and a made-up core schema, not real ones, and cover each shape,
malformed input, the core fields, the definition checks, catalog loading, 400 random combinations
of shapes, and a fuzz test. The command's own tests use the same made-up extensions.
Comment thread internal/validate/schema.go Resolved
The core schema accepts conditions: [] with or without extensions, and rc already did. The if in
the test schema only requires extensions when there are conditions, but it read as if it forbade
an empty list, so it now has a comment. Tests cover an empty list with no extensions and with an
extension declared, and a condition with no declared extensions.
@colinjlacy
colinjlacy merged commit b9d670b into runtimeconditions:main Nov 16, 2026
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.

2 participants