Contributor guide¶
How to add something to CredenceStack without breaking its rules. The rules themselves are in design principles; the system they apply to is in architecture. Each section below names the checks that fail when a step is missed, so the fastest way to learn the rules is to make the change and run:
uv run pytest -q -m "not guides"
uv run python scripts/docs_audit.py --quick
A command¶
- Write it in
src/credencestack/cli/<group>.pywith@command(app, "<name>"). It takessettings: Settingsfirst; every option comes fromcli/options.pywhen one exists. - Its docstring has a one-line summary, a paragraph, and
Usage examples:that run offline. Write paths as`<out>/kind-<id>/`(in backticks, or the help renderer drops the angle brackets). - Add it to
COMMANDSincli/grammar.py, in its help group. - Output goes through
cli.console.outonly (a header, tables, the closing paths and the next command);--jsonprints one document.
Enforced by tests/unit/test_cli_grammar.py (in the grammar, flags from the vocabulary,
summary, description and examples, examples run offline), tests/unit/test_structure.py
(no print outside the console) and the docs hook, which regenerates
docs/reference/cli.md on every build (test_generated_cli_and_configuration_references_are_current).
A flag¶
Use an existing flag if one means the same thing (--out, --seed, --pack,
--pack-path, --json, the --otel* family). A new flag goes in FLAGS in
cli/grammar.py; the names in BANNED_FLAGS are refused. A flag that maps to a setting
says so in its help ((setting otel.metrics)).
Enforced by test_flags_use_the_vocabulary and the docs audit's CLI check (every
credencestack ... --flag written in the docs exists).
A setting¶
Add the field, with a docstring, to its section in src/credencestack/settings.py. It is
read from credencestack.toml, CREDENCESTACK_<SECTION>_<KEY> and the matching flag, in
that order of precedence. Secrets never go in a setting that is written to a manifest:
add the key to LOCAL_KEYS; paths go in PATH_KEYS so manifests stay portable.
Enforced by tests/unit/test_settings.py and the generated
docs/reference/configuration.md.
A report section¶
Reports are built as a credencestack.reports.Report (sections of tables, metrics,
charts and notes) and rendered by the one template set in reports/templates/. Add a
section in the builder for that output kind (reports/evidence.py, reports/bench.py,
reports/brittleness.py); never add a template. Colours come from reports/tokens.json;
confidential content is shown only as its confidential:<hash> id and generic
description.
Enforced by tests/unit/test_reports.py (WCAG AA for every token pair, both renderers,
no external requests in HTML) and the confidential fixture tests.
A span, attribute, event or metric¶
Register it in src/credencestack/otel/semconv.py first: the name constant, an
AttributeDoc with the spans that carry it and its privacy class (safe, content,
never), and the SpanDoc, EventDoc or MetricDoc. Metric attributes must be
low-cardinality (no ids). Then emit it, and regenerate the golden trees with
uv run python scripts/gen_otel_golden.py.
Enforced by tests/unit/test_otel_workflows.py (unregistered() over every workflow,
with and without content capture; privacy; metric attributes) and the golden-tree tests.
The telemetry reference is generated from the registry.
A mutator¶
A Mutator subclass in the domain's module under forge/mutators/ (or a plugin, see
writing your own mutator). Prefer labeling = "recompute";
describe() names no scenario content.
Enforced by tests/unit/test_forge_mutators.py (every mutator applies to some seed,
generated scenarios are valid and re-label to their expectation, determinism,
confidential mutators never leak) and tests/unit/test_forge_generator.py. The
mutator catalogue is generated.
A term¶
The vocabulary is in design principles: one word per
concept. Define a new term once, in docs/glossary.md, and link to it. Old and banned
words (oracle, held-back, adapter in user docs, and the rest of BANNED_TERMS in
scripts/docs_audit.py) fail the audit in the docs, CLI help, report templates and error
messages.
Enforced by the docs audit's glossary and banned-terms checks.
Utilities and errors¶
One module per utility: YAML and JSON through _internal/io.py, hashing through
_internal/hashing.py, random generators through _internal/seeding.py, intervals
through _internal/stats.py, number formatting through _internal/fmt.py, loggers from
_internal/log.py. Every exception a user can see derives from CredenceStackError
(InputError, ConfigError, UsageError, DependencyError, ...) and carries a hint and
a docs page where one helps.
Enforced by tests/unit/test_structure.py.
Documentation¶
Write to the style guide. Commands and outputs on user pages are
generated (scripts/gen_doc_examples.py) and included as snippets, never pasted. Every page
is in the mkdocs.yml navigation; every link resolves; counts come from the code.
Enforced by scripts/docs_audit.py and mkdocs build --strict.