NAME

Dist::Conformance::Check - The interface of a check, and what the checks share

VERSION

version 0.001

SYNOPSIS

use 5.040;
use Dist::Conformance::Check::ClaudeMd;
use Dist::Conformance::Snapshot::Directory;
use Dist::Conformance::Source::Directory;

my $check = Dist::Conformance::Check::ClaudeMd->from_config(
    name   => 'ClaudeMd',
    config => { file => 'CLAUDE.md', mentions => ['perl-slop:reading-perl'] },
    source => Dist::Conformance::Source::Directory->new( directory => '/bogus/standards' ),
    where  => 'the check ClaudeMd',
);
my ( $status, $detail ) = $check->check( Dist::Conformance::Snapshot::Directory->new( root => '/bogus/checkout' ) );

DESCRIPTION

A check is one question about a repository, such as "does it have the current perlcritic profile", asked of a Dist::Conformance::Snapshot. It knows two things:

how to check

"check" reads the snapshot, and returns a status and a detail.

how to update

"update" changes a checkout so that the check passes, through a Dist::Conformance::Update, which records what it changed and writes nothing on a dry run. What it cannot do safely, it says so, as a sentence for a person, rather than guessing.

A check holds no expectations of its own. The files, the templates, the header, whether a miss fails or is only worth knowing: all of that is its configuration, which comes from the flavor (see Dist::Conformance::Flavor) and from .conformance.yml (see Dist::Conformance::Config). Each check module documents the keys that it takes, and validates them against its "config_schema" before it runs.

ATTRIBUTES

name

The name of the check in the flavor.

config

Its configuration, validated, with the defaults of "config_schema" filled in.

source

The Dist::Conformance::Source that the templates come from.

variables

The values of the placeholders of the templates.

METHODS

config_schema

The schema of the keys that this check takes, as a hash reference with properties, and required if any are. Every key in it is documented in the POD of the check. The base class takes none of its own; "schema" adds "THE KEYS THAT EVERY CHECK TAKES".

schema

The whole schema of the configuration: "config_schema", the keys that every check takes, and no others.

from_config

(%arguments). A new check, whose config is validated against "schema" first. where names the configuration in an error, such as the check ClaudeMd of the flavor troglodyne.

check

($snapshot). Returns ($status, $detail): the status is pass, fail or info, and the detail is one line for a person. A subclass must implement it.

update

($update). Changes the checkout of $update->snapshot through the Dist::Conformance::Update. Returns nothing that the caller reads.

The default is for a check that cannot change anything: when "check" fails, it records the detail and that there is no automatic fix.

template

($path). Returns the template at $path in the source with the variables filled in, and then the sorted names of the placeholders that no variable fills. Dies when the source has no such file.

write_template

($update, $path, $template, $mode). Writes the template $template to $path, with $mode, through $update. When a placeholder is left, writes nothing and records what is needed. Returns whether it wrote.

missing

($snapshot, @paths). The paths of @paths that the snapshot does not have, in their order.

STATUSES

pass

The repository meets the standard.

fail

It does not. conformance check exits non-zero when any check fails.

info

Worth knowing, and not a failure: an optional file is absent, or a hook differs from its template because the repository customized it.

A check that dies while checking reports fail, with the error as the detail.

WHAT UPDATE CHANGES

An update brings the checkout to what the configuration describes, whatever status "check" reports. A status of info changes what check reports, not what update does: Dist::Conformance::Check::ClaudeSettings with missing: info still writes the settings when they are missing. To keep update away from something, skip its check in .conformance.yml, or configure the check not to write it, such as replace: false.

A file that a check writes comes from a template of the standards, with each {{NAME}} replaced by the variable NAME of the flavor or of .conformance.yml. A template that still has a placeholder that nothing sets is not written: the update says which variables it needs instead.

THE KEYS THAT EVERY CHECK TAKES

module

The module of the check: Foo means Dist::Conformance::Check::Foo, and a name with :: in it is the whole package name. Default the name of the check. So a flavor can run one module twice under two names.

level

fail or info. At info, a failure of this check is reported as info, so that it never fails a run. Default fail.

THE CHECKS

Dist::Conformance::Check::ClaudeMd

CLAUDE.md exists and names the skills that it must.

Dist::Conformance::Check::CriticProfile

The perlcritic profile starts with the header of its template.

Dist::Conformance::Check::ToolConfiguration

The configuration files of the tools exist.

Dist::Conformance::Check::GitHooks

The hooks are tracked, match their templates, and are installed.

Dist::Conformance::Check::DistFiles

A distribution has the files that its build needs.

Dist::Conformance::Check::DataSchema

A JSON or YAML file, such as .perl-slop.json, matches a schema.

Dist::Conformance::Check::ClaudeSettings

.claude/settings.json enables the plugins.

Dist::Conformance::Check::Workflows

The CI workflows exist.

WRITING A CHECK

Subclass this module, and name the subclass in a flavor:

package My::Check::HasReadme;

use 5.040;
use Mojo::Base 'Dist::Conformance::Check', -signatures;

sub config_schema ($class) {
    return { required => ['file'], properties => { file => $Dist::Conformance::Schema::PATH, template => $Dist::Conformance::Schema::PATH } };
}

sub check ( $self, $snapshot ) {
    my $file = $self->config->{file};
    return $snapshot->contains($file) ? ( 'pass', "$file exists" ) : ( 'fail', "$file is missing" );
}

sub update ( $self, $update ) {
    my $config = $self->config;
    return if $update->snapshot->contains( $config->{file} );
    return $self->write_template( $update, $config->{file}, $config->{template} ) if defined $config->{template};
    return $update->by_hand("Write $config->{file}");
}

And in the flavor:

checks:
  Readme:
    module: My::Check::HasReadme
    file: README.md
    template: templates/README.md

A check must not keep state between calls: one object checks, and then can update, and the snapshot can have changed in between. A check reads only through the snapshot, so that it runs against a repository that is not on this machine, and writes only through the update.

SEE ALSO

Please see those modules/websites for more information related to this module.

BUGS

Please report any bugs or feature requests on the bugtracker website https://github.com/Troglodyne-Internet-Widgets/Dist-Conformance/issues

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.

AUTHORS

Current Maintainers:

  • George S. Baugh <george@troglodyne.net>

COPYRIGHT AND LICENSE

Copyright (c) 2026 Troglodyne LLC

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.