“Send in your skeletons Sing as their bones go marchin’ in again The need you buried deep The secrets that you keep are ever ready Are you ready? I’m finished makin’ sense Done pleading ignorance, that whole defense Spinning infinity, boy The wheel is spinnin’ me, it’s never ending, never ending Same old story” — Foo Fighters
Getting Started
This guide walks you from a fresh install to a passing pretender check in
a real repository. It covers the six steps most teams need on day one.
Prerequisites
- Rust toolchain (stable) — install via rustup.rs
- Git ≥ 2.x — required for
--diff-onlyand hook installation - Internet access for the initial
cargo install
1. Install
cargo install pretender
Verify the install:
pretender --version
2. Initialise your repository
Run the interactive wizard from the root of your repository:
pretender init
The wizard will:
- Ask which mode to run (
guidance/tiered/gate) - Ask which threshold preset to write (
default/strict— or pass--presetto skip the question) - Ask which languages your project uses
- Write
pretender.tomlto the repo root with the preset’s threshold tables - Offer to install the pre-commit hook
- Offer to generate a CI workflow file
A minimal generated pretender.toml looks like:
[pretender]
mode = "tiered"
languages = ["auto"]
[thresholds]
cyclomatic_max = 10
cognitive_max = 15
function_lines_max = 30
See the Configuration reference for every available key and the threshold presets.
3. Run your first check
pretender check .
pretender check . scans all files in the given paths. To check only files
changed relative to origin/main:
pretender check . --diff-only
Reading the output
⚠ src/parser.py — parse_token(): cyclomatic 14 > 10
role: test
parse_token: cyclomatic=14, cognitive=8, assertions=0, function_lines=15, params=2, nesting_max=2, abc=3.46
ADVISORY cyclomatic 14 > 10
| Symbol | Meaning |
|---|---|
⚠ | Advisory — metric exceeds the configured threshold (tiered mode) |
✗ | Violation — metric exceeds the threshold in gate mode |
In gate mode every violation exits non-zero. In the default tiered mode
advisories are printed but exit is still zero.
4. Fix a violation
Suppose parse_token() scores cyclomatic=14 against a threshold of 10.
Extract the per-branch logic into helpers to bring each function under the
threshold:
Before — one function with 14 branches:
def parse_token(token, context, strict):
if token.type == "string":
if strict and not token.value.startswith('"'):
raise ValueError("unquoted string")
return token.value.strip('"')
elif token.type == "number":
try:
return int(token.value)
except ValueError:
return float(token.value)
# … six more branches omitted for brevity
After — each helper is cyclomatic ≤ 3:
def _parse_string(token, strict):
if strict and not token.value.startswith('"'):
raise ValueError("unquoted string")
return token.value.strip('"')
def _parse_number(token):
try:
return int(token.value)
except ValueError:
return float(token.value)
def parse_token(token, context, strict):
if token.type == "string":
return _parse_string(token, strict)
elif token.type == "number":
return _parse_number(token)
# …
Recheck after refactoring:
pretender check src/parser.py
Adopting a gate baseline
Some violations are legitimate but hard to fix right now, and mechanical
changes (a tree-wide reformat, a generated file) shouldn’t read as “new”
violations forever. check --adopt writes the current scan’s violations into
a gate baseline — pretender-baseline.json, next to pretender.toml:
pretender check --adopt
# ✓ adopted 3 findings into pretender-baseline.json (file_lines 1, function_lines 2)
Commit that file. From then on, pretender check --mode gate fails only
on genuinely new violations — findings whose stable ID (path, function
name, rule — deliberately not line numbers) is not in the baseline. Known
violations pass with a summary line:
→ gate: 3 known (baselined), 0 new
Without a baseline file, gate mode keeps its fail-closed behavior: any
violation fails. A corrupt or unreadable baseline also fails the check
rather than silently degrading. Adopted findings still appear in reports
and resolution tracking — the baseline changes gate semantics, not
visibility. Refresh the baseline by re-running with --adopt.
5. Install the pre-commit hook
Keep violations from reaching the repository by running pretender before each commit:
pretender hooks install
This writes a .git/hooks/pre-commit script that runs pretender check --staged on the files you are about to commit. To remove it:
pretender hooks uninstall
6. Add CI integration
Generate a GitHub Actions workflow:
pretender ci generate github
This writes .github/workflows/pretender.yml. The workflow runs
pretender check on every pull request and, if mutation testing is
configured, gates merges on the mutation score defined by
thresholds.mutation_min in your pretender.toml.
For mutation testing details, see Mutation testing. To gate
on mutation score in CI, set thresholds.mutation_min in pretender.toml
— the generated workflow picks it up automatically.
Next steps
| Topic | Document |
|---|---|
All pretender.toml keys and defaults | Configuration reference |
| Mutation testing flags and JSON output | Mutation testing |
| Writing custom metric plugins | Writing plugins |
| Language-specific tracked nodes | Rust and all languages |
Ecosystem
pretender is part of the charly-vibes Tool Ecosystem — the map shows how it relates to its sibling tools.
FAQ
Answers to the questions that come up most when adopting pretender. For thresholds and every configuration key, see the Configuration reference; for a day-one walkthrough, see Getting Started.
Do I need this if I already use clippy / eslint / rubocop?
Those linters catch style and lint-level issues. pretender gates structural
quality: cyclomatic, cognitive and abc complexity per function, structural
clones, and minimum assertions per test — each against role-aware thresholds
(pretender explain <metric> prints them). It complements linters and type
checkers; it does not replace them.
What does pretender write or modify?
pretender.tomlin the repo root (written bypretender init)- Optionally
.git/hooks/pre-commit(orpre-push) — a native shim installed bypretender hooks install, removed bypretender hooks uninstall .github/workflows/pretender.ymlif you runpretender ci generate github- A cache directory under
XDG_CACHE_HOME(default~/.cache/pretender)
It never edits your source files.
How do I run it in CI?
pretender ci generate github writes a ready-to-commit workflow that runs the
check on every pull request. Commit the file; the gate then runs on GitHub’s
runners with no extra setup.
Why does it fail on a clean checkout of an existing repo?
Because the gate counts every function in the scanned paths, not only new
code. Legacy hot spots are expected: record them once as the known-findings
baseline (--adopt maintains pretender-baseline.json), after which only
new violations fail the gate. Scope any check to the PR diff with
--staged or --diff-only.
What is the advisory lease (--advisory-until)?
guidance and tiered modes report findings as advisories instead of hard
failures, and require a dated lease (advisory_until in pretender.toml or
--advisory-until YYYY-MM-DD). An expired or missing lease fails closed —
renewing it is a visible, reviewable diff, so a soft gate cannot silently
stay soft.
How do I disable or soften the gate?
- Soften: switch
modetoguidanceortieredinpretender.toml(with a current advisory lease); advisories print but exit 0. - Disable: remove the hook (
pretender hooks uninstall) and the generated CI workflow, or stop callingpretender checkin CI.
What about plugins?
The pretender plugins command exists but is [not yet implemented]; language
and metric plugins are on the roadmap. See Writing plugins for
the intended surface and Status for what ships today.
Release Status
Generated artifact (docs.yml, from Cargo.toml + git ref). Do not hand-edit — the repo source files remain authoritative.
- Version: v0.14.0
- Built from: main @ 520b033
Configuration Reference
pretender.toml is placed at the root of your repository. All sections and
keys are optional — omitted keys fall back to the defaults shown here.
Recommended baseline for Rust CLI repos
For charly-vibes suite repos (Rust CLI tools like pretender, wai, dont, espectacular, vampiro, testaruda, crua, livin), we recommend pinning roles and overriding the default thresholds to match a typical Rust project layout:
| Role | Paths | Notes |
|---|---|---|
test | tests/**, **/*_test.*, spec/** | Default — already matches |
unit-test | tests/unit/** | Explicit sub-role for fast unit tests |
integration-test | tests/integration/** | Explicit sub-role for slower integration |
script | scripts/**, examples/** | Default — already matches |
generated | **/*_generated.* | Default — pb.go, protobuf, etc. |
Why pin roles explicitly
Without a pretender.toml, pretender uses library defaults: all files get the
app role, tests are detected via heuristics only, and every role’s paths use
convention over configuration. This works, but has two downsides:
- No sub-role awareness —
tests/unit/andtests/integration/are not differentiated, so duration thresholds (duration_max_ms) never activate. - No version-controlled baseline — new team members or CI environments must guess which role layout your project uses.
Pinning roles in pretender.toml resolves both issues and makes the config
part of the reviewed, committed project state.
Baseline threshold values
These values are copied from templates/pretender.toml.example and represent
the recommended starting point for Rust CLI repos:
[thresholds]
cyclomatic_max = 10
cognitive_max = 15
function_lines_max = 30
file_lines_max = 400
nesting_max = 3
params_max = 4
abc_max = 30
duplication_pct_max = 5
void_mutators_max = 3
mut_ratio_max = 0.3
unwrap_max = 5
bool_cluster_max = 3
primitive_param_check = false
inheritance_depth_max = 2
[thresholds.test]
cyclomatic_max = 3
cognitive_max = 5
function_lines_max = 80
nesting_max = 2
params_max = 2
duplication_pct_max = 30
min_assertions = 1
mock_count_max = 5
unwrap_max = 5
lazy_cluster_min = 3
[thresholds.library]
exported_params_max = 3
exported_cyclomatic_max = 8
exported_lines_max = 30
require_docstring = true
[thresholds.unit-test]
duration_max_ms = 100
[thresholds.integration-test]
duration_max_ms = 2000
Threshold presets
pretender init writes the chosen preset’s threshold tables explicitly into
the generated config, so a project initted today keeps today’s values when a
later version changes the built-in defaults (re-init or hand-edit to pick up
new defaults).
default— the values above (the built-in defaults).strict— tighter headline limits for established codebases: appcyclomatic_max8,cognitive_max12,function_lines_max25,nesting_max2,params_max3,abc_max25,duplication_pct_max4,file_lines_max300; testcyclomatic_max2,cognitive_max3,function_lines_max60,nesting_max2. Enabled-check values are identical to the default preset.
Choose the preset interactively (the wizard asks Threshold preset (default/strict) [default]: after the mode question) or non-interactively
with pretender init --preset <default|strict> (default default). An
explicit --preset suppresses the prompt. Combining --mode gate with the
strict preset makes init print the migration hint: baseline the current
state with pretender check --adopt, or use mode = "tiered" with an
advisory lease, otherwise existing code violates the tighter thresholds
immediately.
Upgrading a gate-mode repo: previously-disabled checks (unwrap, void-mutators, bool clusters, mutable-binding ratio, lazy test clusters, inheritance depth, test mock counts) are now enabled by default, and
function_lines_maxtightened from 40 to 30. Without explicit thresholds in yourpretender.toml, new findings appear after upgrade. Runpretender check --adoptto baseline the current state, or switch tomode = "tiered"with an advisory lease.
that may not match the project’s quality targets.
Doctor check for effective hooks path
pretender doctor also includes a Hook location check: it resolves
core.hooksPath across all config scopes (local, global, system) using
genesis::git_hooks::effective_hooks_dir and warns when git will invoke
hooks from a directory other than where the pretender hook was installed
— the case where a global core.hooksPath shim (e.g. lefthook) silently
makes the installed gate inert. An empty-string core.hooksPath (git
disables hooks entirely) is reported as an error.
Deploying across the suite
Each suite repo should commit its own pretender.toml (start from the
template at templates/pretender.toml.example) and adjust thresholds as
needed. The canonical template lives in the pretender repo and serves as the
upstream source of truth for all suite repos.
[pretender]
| Key | Type | Default | Description |
|---|---|---|---|
mode | string | "gate" | Check behaviour: "gate" (any violation fails — the fail-closed default, softened only by an adopted gate baseline), "tiered" (failures scale with severity; advisory), "guidance" (hints only; advisory) |
advisory_until | ISO date string | — (required for tiered/guidance) | Advisory lease expiry (pretender-1te). Advisory modes are dated downgrades from the gate default: an expired, missing, or unparseable lease makes check FAIL, forcing a renewed, dated, reviewable decision. Renewal = push the date forward in this file (a visible diff). Gate mode never consults the lease. |
languages | array of strings | ["auto"] | Languages to analyse. "auto" detects from file extensions. Explicit values: "python", "rust", "go", "javascript", "typescript", "java", "ruby", "c", "cpp" |
exclude | array of glob strings | ["vendor/**", "node_modules/**", "**/*_generated.*"] | Path globs to skip during analysis |
respect_gitignore | boolean | true | When walking directories, skip anything ignored by git (repo + nested .gitignore, global core.excludesFile, .git/info/exclude) so target/, node_modules/, and vendored code aren’t scanned without per-repo exclude lists. Outside a git repo the walk is unfiltered. Explicitly passed file paths and --staged are never filtered. Pass --scan-ignored to check for a one-off exhaustive walk (pretender-094). |
[thresholds]
App-level metric limits applied to files assigned the app role (the default
for files not matched by any other role).
| Key | Type | Default | Description |
|---|---|---|---|
cyclomatic_max | integer | 10 | Maximum cyclomatic complexity per function |
cognitive_max | integer | 15 | Maximum cognitive complexity per function |
function_lines_max | integer | 30 | Maximum lines per function |
file_lines_max | integer | 400 | Maximum lines per file |
nesting_max | integer | 3 | Maximum control-flow nesting depth |
params_max | integer | 4 | Maximum formal parameters per function |
abc_max | integer | 30 | Maximum ABC score (√(A²+B²+C²)) per function |
duplication_pct_max | integer | 5 | Maximum structural duplication percentage (0–100) |
void_mutators_max | integer | 3 | Maximum void-mutator functions per file; 0 disables |
mut_ratio_max | number | 0.3 | Maximum mutable-binding ratio per file; 0.0 disables |
unwrap_max | integer | 5 | Maximum unwrap()/expect() calls per file; 0 disables |
bool_cluster_max | integer | 3 | Maximum boolean parameters per function; 0 disables |
primitive_param_check | boolean | false | Flag String/int parameters that should be newtypes |
excessive_fields_max | integer | 10 | Maximum fields per type definition before the excessive_fields rule flags it; 0 disables. Provisional default pending calibration (pretender-uwz) |
primitive_field_check | boolean | false | Enable the experimental, opt-in primitive_field rule on type-definition fields |
domain_patterns | string list | [] | Additional name patterns (case-insensitive substring match) extending the domain-name set primitive_field uses to flag candidate domain-typed fields; app-level only, not role-overridable |
inheritance_depth_max | integer | 2 | Maximum class inheritance depth; 0 disables |
Notes on the data-model rules:
excessive_fields_maxdefaults to 10, a provisional policy choice pending corpus calibration (pretender-uwz); documented precedents range from 7 (pylint too-many-instance-attributes) to 20 (SonarQube S1820).primitive_fieldis opt-in and experimental: it is off by default and its rule shape may change.- Generated and FFI-heavy paths (C
repr(C)layouts, codegen output) routinely tripexcessive_fields/primitive_field; exclude them or disable via role globs, e.g.[thresholds.<role>] excessive_fields_max = 0.
Planned (not yet enforced): Maintainability Index (
mi_min), coverage (coverage_line_min/coverage_branch_min), and mutation score (mutation_min) thresholds are not currently configurable. They were removed from the schema in v0.5.0 because they were never enforced — passing a config that sets these keys silently ignored them. Mutation score is already gateable viapretender mutation --score-min N; coverage and MI enforcement are future work.
[thresholds.unit-test]
Overrides for files assigned the unit-test sub-role. Inherits all [thresholds.test]
values and overlays the duration threshold.
| Key | Type | Default | Description |
|---|---|---|---|
duration_max_ms | integer | 0 | Maximum allowed test duration in milliseconds. 0 disables the check. |
[thresholds.integration-test]
Overrides for files assigned the integration-test sub-role. Inherits all [thresholds.test]
values and overlays the duration threshold.
| Key | Type | Default | Description |
|---|---|---|---|
duration_max_ms | integer | 0 | Maximum allowed test duration in milliseconds. 0 disables the check. |
[thresholds.test]
Overrides for files assigned the test role.
| Key | Type | Default | Description |
|---|---|---|---|
cyclomatic_max | integer | 3 | Cyclomatic limit for test functions |
cognitive_max | integer | 5 | Cognitive limit for test functions |
function_lines_max | integer | 80 | Line limit for test functions |
nesting_max | integer | 2 | Nesting limit for test functions |
params_max | integer | 2 | Parameter limit for test functions |
duplication_pct_max | integer | 30 | Duplication tolerance in test files |
min_assertions | integer or null | 1 | Minimum assertion calls per test function; null disables |
mock_count_max | integer | 5 | Maximum mocks per test file; 0 disables |
unwrap_max | integer | 5 | Maximum unwrap()/expect() calls per test file; 0 disables |
lazy_cluster_min | integer | 3 | Minimum identical-test-cluster size to flag; 0 disables |
[thresholds.library]
Overrides for files assigned the library role.
| Key | Type | Default | Description |
|---|---|---|---|
exported_params_max | integer | 3 | Parameter limit on exported/public functions |
exported_cyclomatic_max | integer | 8 | Cyclomatic limit on exported/public functions |
exported_lines_max | integer | 30 | Line limit on exported/public functions |
require_docstring | boolean | true | Require a docstring on every exported/public function |
[thresholds.script]
Overrides for files assigned the script role.
| Key | Type | Default | Description |
|---|---|---|---|
function_lines_max | integer | 100 | Line limit per function |
file_lines_max | integer | 300 | Line limit per file |
[bands]
Colour bands used when mode = "tiered" to map raw metric values to severity
levels. Each band specifies thresholds for green (acceptable), yellow (warning),
and red (violation). Values must satisfy green <= yellow <= red.
Each band (cyclomatic, cognitive) is optional. When the [bands]
section is entirely absent from pretender.toml, both bands are active with
the defaults shown below. However, once you add a [bands] section, any band
key you omit is disabled (set to None) — it does not fall back to its
default. Always specify both bands together when overriding either one.
# Inline form
[bands]
cyclomatic = { green = 10, yellow = 15, red = 20 }
cognitive = { green = 15, yellow = 25, red = 40 }
# Block form (equivalent)
[bands.cyclomatic]
green = 10
yellow = 15
red = 20
[bands.cognitive]
green = 15
yellow = 25
red = 40
[bands.cyclomatic]
Default (when [bands] is absent): { green = 10, yellow = 15, red = 20 }
| Key | Type | Description |
|---|---|---|
green | integer | Cyclomatic complexity at or below this is green |
yellow | integer | At or below this is yellow |
red | integer | Above this is red |
[bands.cognitive]
Default (when [bands] is absent): { green = 15, yellow = 25, red = 40 }
| Key | Type | Description |
|---|---|---|
green | integer | Cognitive complexity at or below this is green |
yellow | integer | At or below this is yellow |
red | integer | Above this is red |
[scope]
Controls which files are analysed during pretender check.
| Key | Type | Default | Description |
|---|---|---|---|
diff_only | boolean | true | Written by pretender init to record your project preference. Setting this to true does not automatically enable diff filtering — you must pass --diff-only on the CLI (or CI step) to activate it. When active, only files changed relative to diff_base are checked |
diff_base | string | "origin/main" | Git ref used as the comparison base for --diff-only |
[execute]
Optional shell commands pretender can run to collect coverage and mutation data.
| Key | Type | Default | Description |
|---|---|---|---|
enabled | boolean | false | Run external commands (test, coverage, mutation) during pretender check |
coverage_cmd | string or null | null | Planned: Shell command that produces a coverage report. Not yet executed by pretender check |
mutation_cmd | string or null | null | Planned: Shell command that runs mutation testing. Mutation score is already gateable via pretender mutation --score-min N |
test_cmd | string or null | null | Shell command that runs the test suite and produces a JUnit XML report (used with --execute) |
test_report_path | string or null | null | Path to the JUnit XML report produced by test_cmd (relative to repo root) |
test_timeout_s | integer | 600 | Timeout in seconds for test_cmd; on timeout pretender emits a test-cmd-timeout error |
test_time_unit | string | "seconds" | Unit of the JUnit time attribute: "seconds" (XSD-conformant) or "milliseconds" (non-conformant runners) |
[plugins]
Controls which built-in language and metric plugins are active.
| Key | Type | Default | Description |
|---|---|---|---|
languages | array of strings | ["python","javascript","typescript","go","rust"] | Language plugins to load |
metrics | array of strings | ["eslint","ruff","clippy"] | Built-in metric tool plugins to load |
External metric plugins are always loaded in addition to this list from the first directory found in this order:
$PRETENDER_METRICS_DIR(if set)$XDG_CONFIG_HOME/pretender/metrics/(ifXDG_CONFIG_HOMEis set)~/.config/pretender/metrics/(fallback)
See Writing plugins.
[output]
| Key | Type | Default | Description |
|---|---|---|---|
formats | array of strings | ["human","sarif"] | Output formats to emit. Valid values: "human", "json", "sarif", "junit", "markdown". At least one value is required |
sarif_path | string | "pretender.sarif" | File path for SARIF output when "sarif" is in formats |
[roles.*]
Role matchers assign a role to files based on path globs. The resolved role
determines which [thresholds.*] block applies.
Each role section has a single key:
| Key | Type | Description |
|---|---|---|
paths | array of glob strings | Files matching any glob are assigned this role |
classname_root | string | For [roles.test] only: directory to search when resolving JUnit classname to a source file (default "tests") |
Available roles and their defaults:
| Role | Default paths |
|---|---|
test | ["tests/**", "**/*_test.*", "spec/**"] |
unit-test | ["tests/unit/**"] |
integration-test | ["tests/integration/**"] |
library | ["pkg/**", "lib/**"] |
script | ["scripts/**", "examples/**"] |
generated | ["**/*.pb.go", "**/*_generated.*"] |
vendor | ["vendor/**", "node_modules/**"] |
Example override:
[roles.test]
paths = ["tests/**", "**/*.spec.*", "**/__tests__/**"]
Role detection order
pretender assigns the first role that matches, checked in this priority order:
- Pragma — a comment on any line of the file:
# pretender: role=<name>or// pretender: role=<name> - Configured glob — the first
[roles.*]section whose glob matches the file path - File-name heuristic — built-in patterns (e.g.
_test.suffix → test,_generated.→ generated) - Default —
app
Test-duration check
pretender can analyse per-test timing data from a JUnit XML report and flag tests that exceed role-appropriate duration budgets. This is the first dynamic check in pretender — it consumes a runtime artifact rather than source text.
Activation
The check activates when you pass --test-report <path> to pretender check.
You can also configure [execute] test_cmd and use --execute to have
pretender run the test suite for you:
# Analyse an existing report
pretender check --test-report target/junit-report.xml
# Run tests first, then analyse
pretender check --execute
Thresholds
Set duration limits per test sub-role:
[thresholds.unit-test]
duration_max_ms = 100 # unit tests should be fast
[thresholds.integration-test]
duration_max_ms = 2000 # integration tests can be slower
A finding is emitted when observed_ms > duration_max_ms (strict comparison,
so a test exactly at the threshold does not fail). A threshold of 0
(the default) disables the check.
Sub-role detection
pretender detects unit-test and integration-test sub-roles using the same
resolution order as other roles:
- Pragma —
# pretender: role=unit-testor// pretender: role=unit - Configured glob —
[roles.unit-test]with custompaths - Heuristic —
tests/unit/**andtest/unit/**→unit-test;tests/integration/**andtest/integration/**→integration-test - Default —
test(no duration threshold)
Sub-roles inherit all [thresholds.test] values and overlay only
duration_max_ms.
How timing data is read
pretender parses standard JUnit XML (<testsuite> / <testcase time="...">).
The time attribute is interpreted as seconds by default (XSD-conformant);
set [execute] test_time_unit = "milliseconds" for non-conformant runners.
Rounding uses round-half-up to the nearest millisecond.
JUnit emission incantations per runner
| Runner | Command |
|---|---|
| pytest | pytest --junitxml=report.xml |
| cargo test | cargo2junit > report.xml (requires cargo2junit crate) |
| Maven | mvn surefire-report:report (produces target/surefire-reports/*.xml) |
| Gradle | Built-in: build/reports/tests/test/*.xml |
| Jest | jest --junitOutput=report.xml (requires jest-junit reporter) |
CLI flags
| Flag | Description |
|---|---|
--test-report <path> | Path to a JUnit XML report for duration analysis |
--execute | Run [execute] test_cmd before analysing durations |
Output
Findings appear in all output formats:
- Human:
unit-test test_addition tests/unit/test_math.py: 100ms > 50ms - JSON:
test_findingstop-level array withtest_name,file,role,observed_ms,threshold_ms - SARIF:
pretender/test-durationrule id,Warninglevel
In gate mode, any duration finding causes a non-zero exit code.
pretender maintains a local event log that surfaces recurring problem areas across runs — useful for calibrating thresholds and identifying structural debt before it compounds.
pretender tracks every violation it reports in .pretender/history/events.jsonl
at the root of your repository. Each line is a JSON object (a ViolationEvent)
recording the file fingerprint, rule key, role, area, run ID, and Unix timestamp.
Events older than 90 days are pruned automatically on each run.
From the event log pretender computes two summaries shown at the end of
pretender check:
- Hotspots — the 10 files with the highest total violation count across at least two distinct days. A file that repeatedly triggers is a structural problem, not a fluke.
- Patterns — the 10 (rule, role, area) combinations that recur most often across the most files. Use these to calibrate thresholds or identify conventions your team hasn’t codified yet.
Resolution tracking — every check run (including clean runs) also
persists the current set of finding IDs to
.pretender/history/last-findings.json. IDs are stable across line-shift
edits (path::unit_name::rule_key). The next run reports a delta:
→ resolution: 3 fixed, 5 still open, 2 new (38%)
The rate is fixed / (fixed + still_open) — null on the first tracked run.
The same delta is available to machine consumers under
data.history.resolution in JSON output and in history/summaries.json, so
CI dashboards can track the fixed-vs-flagged ratio over time.
The .pretender/ directory should be committed so the feedback loop survives
across machines and CI runs. Note: events.jsonl records file paths and
fingerprints — review the file before committing if your repository contains
sensitive filenames.
Mutation Testing
Mutation testing measures test-suite effectiveness by injecting small code changes (“mutants”) and checking whether the tests catch them. A high mutation score means your tests fail when the code is wrong — a low score means gaps exist even when line coverage looks healthy.
pretender mutation <paths...> wraps language-specific mutation testing tools
and reports results in a unified format. Each tool must be installed separately
— pretender invokes them as subprocesses.
Quick reference
| Flag | Purpose | Example |
|---|---|---|
| (none) | Run mutation testing and print results | pretender mutation src/ |
--dry-run | List mutation sites without running tests | pretender mutation src/ --dry-run |
--score-min N | Exit non-zero if score < N% | pretender mutation src/ --score-min 80 |
--format json | Emit structured JSON report | pretender mutation src/ --format json |
Tool selection
pretender detects the dominant language from the target paths and selects the appropriate tool automatically:
| Language | Tool | Install |
|---|---|---|
| Python | mutmut | pip install mutmut |
| Rust | cargo-mutants | cargo install cargo-mutants |
| JavaScript / TypeScript | Stryker | npm install --save-dev @stryker-mutator/core |
If a project contains multiple languages, pretender uses the language of the majority of files in the given paths.
Java (PIT) — not yet automated
pretender mutation does not yet invoke PIT directly. Run mutation coverage
manually with Maven or Gradle:
mvn org.pitest:pitest-maven:mutationCoverage
# or
gradle pitest
--dry-run still works for Java files — pretender uses tree-sitter to list
candidate mutation sites without invoking PIT.
Basic usage
# Run mutation testing against a package
pretender mutation src/
# Preview mutation sites without running tests
pretender mutation src/ --dry-run
# Fail if mutation score falls below a threshold
pretender mutation src/ --score-min 80
# Emit results as JSON
pretender mutation src/ --format json
--dry-run: preview mutation sites
Lists every planned mutation without executing the test suite. Useful for understanding coverage before committing to a full run.
pretender mutation src/ --dry-run
Example output:
src/engine.rs:42 replace operator `>`
src/engine.rs:67 replace return value
src/config.rs:15 replace operator `+`
Note: For Rust,
--dry-runqueriescargo mutants --listand reflects the real mutation plan. For all other languages (Python, JavaScript, TypeScript, Java), it uses a built-in tree-sitter analysis that enumerates operator and return-value sites — the count and descriptions are approximate and may differ from what the underlying tool would produce.
--score-min: CI gate
Exits non-zero if the achieved mutation score is below the given percentage. Use this in CI to enforce a minimum quality bar.
pretender mutation src/ --score-min 80
The exit code is 0 when the score meets or exceeds the threshold, 1
otherwise.
--format json: machine-readable output
Emits a MutationReport JSON object to stdout.
pretender mutation src/ --format json
MutationReport fields
| Field | Type | Description |
|---|---|---|
tool | string | Name of the mutation tool used (e.g. "cargo-mutants") |
total | integer | Total number of mutants generated |
killed | integer | Mutants caught by the test suite |
survived | integer | Mutants not caught (test gaps) |
score_pct | float | Mutation score: (killed / total) * 100. Returns 100.0 when no mutants are generated |
survivors | array | List of surviving mutant descriptors (see below) |
Surviving mutant fields
| Field | Type | Description |
|---|---|---|
file | string | Source file containing the mutant |
line | integer | Line number of the mutation |
description | string | Human-readable description of the applied mutation |
missed_tests | array of strings | Test names that should have caught this mutant but did not. Populated by mutmut only; always [] for cargo-mutants and Stryker, which do not report per-mutant test attribution |
Example (mutmut, which populates missed_tests):
{
"tool": "mutmut",
"total": 120,
"killed": 102,
"survived": 18,
"score_pct": 85.0,
"survivors": [
{
"file": "src/engine.py",
"line": 42,
"description": "replace `>` with `>=`",
"missed_tests": ["test_threshold_boundary"]
}
]
}
CI integration
The recommended way to run mutation testing in CI is through the workflow
generated by pretender ci generate github:
pretender ci generate github
This writes .github/workflows/pretender.yml. The generated file includes a
check step and a mutation gate step:
- name: pretender check
run: pretender check .
- name: Mutation score gate
run: pretender mutation . --score-min 60
The --score-min value defaults to 60 and can be set per invocation or via
pretender mutation . --score-min <N> in your CI workflow.
Writing Plugins
pretender supports external metric plugins: small programs that analyse source
files and emit findings in JSON. pretender runs each plugin as a subprocess,
collects its output, and merges the findings into pretender check results
alongside the built-in metrics.
Install location
Place plugin manifests (.toml files) in the metrics directory. pretender
searches the first directory found in this order:
$PRETENDER_METRICS_DIR(if set)$XDG_CONFIG_HOME/pretender/metrics/(ifXDG_CONFIG_HOMEis set)~/.config/pretender/metrics/(fallback)
Each .toml file in that directory is loaded as one plugin. Non-.toml files
and files with parse errors are skipped — a warning is printed to stderr for
each invalid file.
Plugin manifest format
A plugin manifest is a TOML file with the following fields:
| Field | Type | Required | Description |
|---|---|---|---|
name | string | yes | Plugin name shown in output (e.g. "ruff") |
extensions | array of strings | yes | File extensions this plugin applies to (e.g. [".py"]) — must include the leading dot |
command | array of strings | yes | Command and arguments to run. The token {files} is expanded to the list of matching file paths |
parser | string | yes | Output format: "json" (a JSON array) or "json-lines" (one JSON object per line) |
[mapping] | table | yes | Field mapping from the plugin’s JSON output to pretender’s finding schema (see below) |
[mapping] sub-table
Each mapping value is a dot-separated path into the JSON object emitted by
the plugin. For example, "location.row" navigates {"location": {"row": 5}}.
| Field | Type | Required | Description |
|---|---|---|---|
path | string | yes | JSON path to the source file name |
line | string | yes | JSON path to the line number (integer) |
message | string | yes | JSON path to the human-readable finding message |
code | string | no | JSON path to an optional finding code (e.g. "E501") |
Finding schema
Each finding pretender emits from a plugin has these fields:
| Field | Type | Description |
|---|---|---|
source | string | The plugin name |
line | integer | Line number of the finding |
message | string | Human-readable description |
code | string or null | Optional finding code |
Worked example
The metrics/example/ directory in this repository contains a minimal,
runnable plugin — a shell script that emits one JSON finding per violation
and a TOML manifest wiring it to pretender. Copy the files and edit the
path to install it locally.
Manifest — metrics/example/long-lines.toml
name = "long-lines"
extensions = [".py", ".js", ".ts", ".rs"]
command = ["metrics/example/long-lines.sh", "{files}"]
parser = "json-lines"
[mapping]
path = "file"
line = "line"
message = "message"
code = "code"
Script — metrics/example/long-lines.sh
The script checks for lines exceeding 100 characters and emits one JSON object per violation:
#!/usr/bin/env sh
for file in "$@"; do
awk -v file="$file" 'length > 100 {
printf "{\"file\":\"%s\",\"line\":%d,\"message\":\"line exceeds 100 chars (%d)\",\"code\":\"LL001\"}\n",
file, NR, length
}' "$file"
done
Installing the example
Use absolute paths in command — relative paths are resolved from wherever
pretender check is run, which can vary. Copy both files to the metrics
directory:
mkdir -p ~/.config/pretender/metrics
cp metrics/example/long-lines.sh ~/.config/pretender/metrics/
chmod +x ~/.config/pretender/metrics/long-lines.sh
# Update the command path in the manifest before copying
sed 's|metrics/example/long-lines.sh|/home/you/.config/pretender/metrics/long-lines.sh|' \
metrics/example/long-lines.toml \
> ~/.config/pretender/metrics/long-lines.toml
# Verify it appears in check output
pretender check src/
The finding will appear in human output as:
src/lib.rs:87 [long-lines] line exceeds 100 chars (112) LL001
How findings are merged
After each pretender check run, pretender runs every applicable plugin
against the files being checked. Findings from plugins are merged with built-in
metric findings and displayed in the same output stream. The source field
identifies which plugin produced each finding.
Plugins are always loaded from the metrics directory in addition to any
built-in metric tools listed in [plugins].metrics in pretender.toml.
See the Configuration reference for the
[plugins] section.
Real-world examples
ruff (Python linter)
name = "ruff"
extensions = [".py"]
command = ["ruff", "check", "--output-format=json", "--select=E501", "{files}"]
parser = "json"
[mapping]
path = "filename"
line = "location.row"
message = "message"
code = "code"
ESLint (JavaScript / TypeScript)
ESLint’s JSON output nests messages inside per-file objects — one array entry per file, not per finding. pretender’s dot-path mapping does not support array indexing, so a thin wrapper script is required to flatten the output.
Requires: jq — install with your system
package manager (brew install jq, apt install jq, etc.).
#!/usr/bin/env sh
# eslint-wrapper.sh
# Requires jq. Flattens ESLint JSON output to one JSON object per finding.
npx eslint --format=json "$@" | jq -c '
.[] | .filePath as $f | .messages[] |
{file: $f, line: .line, message: .message, code: .ruleId}
'
name = "eslint"
extensions = [".js", ".jsx", ".ts", ".tsx"]
command = ["/path/to/eslint-wrapper.sh", "{files}"]
parser = "json-lines"
[mapping]
path = "file"
line = "line"
message = "message"
code = "code"
Replace /path/to/eslint-wrapper.sh with the absolute path where you install
the wrapper script.
Implementation Status
Current build status for every command and feature. Stubbed items exit with
code 2 and a “not yet implemented” message. Partial items are functional
but have noted gaps.
Commands
| Command | Status | Notes |
|---|---|---|
pretender init | ✅ Implemented | Interactive and --non-interactive modes |
pretender check | ✅ Implemented | human, json, sarif output; --staged and --diff-only filters |
pretender complexity | ✅ Implemented | Single-file, worst-first sort |
pretender report | ✅ Implemented | human, markdown, html |
pretender duplication | ✅ Implemented | Cross-file and single-file |
pretender mutation | ✅ Implemented | Python, Rust, JS, TS — see caveats |
pretender hooks install [hook] | ✅ Implemented | Writes git hook shim (pre-commit, pre-push) |
pretender hooks uninstall | ✅ Implemented | Removes Pretender-managed shim |
pretender ci generate github | ✅ Implemented | Writes .github/workflows/pretender.yml |
pretender explain | ✅ Implemented | All built-in metrics |
pretender plugins | ❌ Stub | Tracked: pretender-07m |
Partial features
| Feature | Status | Detail |
|---|---|---|
check --format junit | ❌ Stub | Tracked: pretender-t2m |
check --format markdown | ❌ Stub | Tracked: pretender-t2m |
ci generate <non-github> | ❌ Stub | Only github is implemented |
| Mutation testing — Java | ⚠️ Partial | --dry-run works via tree-sitter; PIT is not invoked automatically |
Language support matrix
| Language | Complexity | Mutation |
|---|---|---|
| Python | ✅ | ✅ (mutmut) |
| Rust | ✅ | ✅ (cargo-mutants) |
| JavaScript | ✅ | ✅ (Stryker) |
| TypeScript | ✅ | ✅ (Stryker) |
| Go | ✅ | — |
| Java | ✅ | ⚠️ dry-run only |
| Ruby | ✅ | — |
| C | ✅ | — |
| C++ | ✅ | — |
Status
beta — core works and is dogfooded in anger; surface may shift before stable.
Implemented
| Command | Status | Notes |
|---|---|---|
pretender init | stable | project config bootstrap |
pretender report | stable | complexity report (cyclomatic, cognitive, abc, params) |
pretender ci generate github | stable | emit CI quality-check steps |
pretender lint | beta | complexity/lint gate over changed code |
In progress
- Theme/docs conformance round (DDL-u8x epic); docs/src restructure.
Mapped to specs
- Complexity model definitions in
docs/(mutation.md, plugins.md); openspec proposals in-repo.
Dogfooding
- wai, testaruda, dont (planned pins) install pretender per
versions.ddl.toml; testaruda carries apretender.toml - pretender’s own CI runs
just ci
C
Reference for which tree-sitter nodes pretender tracks for C files, how
each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .c and .h files using a tree-sitter grammar. Tracks standard
C function definitions (not declarations). Header files are included so
complexity in inline or static functions defined in headers is measured.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
function_definition | @function.definition | Defines a metric scope |
if_statement | @branch.if | +1 cyclomatic, +1 cognitive |
for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
while_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
do_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
case_statement | @branch.case | +1 cyclomatic, +1 cognitive |
binary_expression "&&" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary_expression `“ | “` | |
call_expression | @call | +1 ABC C-count |
assignment_expression | @assign | +1 ABC A-count |
init_declarator (with value) | @assign | +1 ABC A-count |
Assertion patterns
| Pattern | Matches |
|---|---|
^assert | assert(...) from <assert.h> |
^ASSERT | Custom assertion macros |
^TEST_ASSERT | Unity / CUnit style macros |
Quirks and limitations
- Function pointers and macro-defined functions are not tracked as function scopes.
gotois not captured as a branch — complexity ingoto-heavy code is understated. The smell-weight system flagsgotoseparately.default:in switch is captured as acase_statementand counted as one branch.- Header files (
.h) are analysed like.cfiles. Forward declarations (without a body) are not captured; only full definitions are tracked. - Preprocessor conditionals (
#ifdef,#if) are not parsed by the tree-sitter grammar and do not contribute branch counts.
Known unsupported metrics
min_assertions— Not implemented yet:metrics.scmhas no@assert.*capture, so unit assertion totals are always 0 (the[assertions]patterns serve rule scopes only). No ticket filed yet.- Nesting depth — Not implemented yet: the engine increments nesting
only inside
block-kind nodes, but tree-sitter-c wraps bodies incompound_statement, sonesting_maxstays 0. No ticket filed yet. - Unwrap density — Not implemented yet: the engine’s risky error-handling detector covers Rust, Python, JavaScript/TypeScript, Java, and Go only; C has no matcher. No ticket filed yet.
Example output
src/parser.c cyclomatic=11 cognitive=14 function_lines=52 params=3
↳ parse_token() cyclomatic=11 [threshold: 10]
include/utils.h cyclomatic=2 cognitive=2 function_lines=8 params=1
C++
Reference for which tree-sitter nodes pretender tracks for C++ files, how
each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .cpp, .cc, .cxx, .hpp, and .hxx files using a tree-sitter
grammar. Tracks both free functions and out-of-class method definitions
(qualified identifiers). Range-based for loops and catch clauses each
count as branches.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
function_definition (simple identifier) | @function.definition | Defines a metric scope |
function_definition (qualified identifier) | @function.definition | Defines a metric scope |
if_statement | @branch.if | +1 cyclomatic, +1 cognitive |
for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
for_range_loop | @branch.loop | +1 cyclomatic, +1 cognitive |
while_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
do_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
catch_clause | @branch.catch | +1 cyclomatic, +1 cognitive |
case_statement | @branch.case | +1 cyclomatic, +1 cognitive |
binary_expression "&&" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary_expression `“ | “` | |
call_expression | @call | +1 ABC C-count |
assignment_expression | @assign | +1 ABC A-count |
init_declarator (with value) | @assign | +1 ABC A-count |
Assertion patterns
| Pattern | Matches |
|---|---|
^assert | assert(...) from <cassert> |
^ASSERT | Custom assertion macros |
^EXPECT | Google Test EXPECT_EQ(...), etc. |
^CHECK | CHECK(...) (Abseil, glog) |
Quirks and limitations
- Template functions produce one definition entry per instantiation in some grammar revisions; complexity may be overcounted in heavily templated code.
- Lambda expressions are not tracked as function scopes — their branches count toward the enclosing function’s complexity.
- Operator overloads (
operator+,operator==) are captured as function definitions and metriced like regular functions. ternary_expression(condition ? a : b) is not currently tracked and does not contribute cyclomatic complexity.- In-class method definitions (defined inside a class body in a header) use
the simple-identifier form and are tracked correctly. Out-of-class definitions
(e.g.,
Foo::bar()in a.cppfile) use the qualified-identifier form and are also tracked. - Preprocessor conditionals (
#ifdef,#if) are not parsed by the tree-sitter grammar and do not contribute branch counts.
Known unsupported metrics
min_assertions— Not implemented yet:metrics.scmhas no@assert.*capture, so unit assertion totals are always 0 (the[assertions]patterns serve rule scopes only). No ticket filed yet.- Nesting depth — Not implemented yet: the engine increments nesting
only inside
block-kind nodes, but tree-sitter-cpp wraps bodies incompound_statement, sonesting_maxstays 0. No ticket filed yet. - Unwrap density — Not implemented yet: the engine’s risky error-handling detector covers Rust, Python, JavaScript/TypeScript, Java, and Go only; C++ has no matcher. No ticket filed yet.
Example output
src/engine.cpp cyclomatic=10 cognitive=13 function_lines=49 params=3
include/parser.hpp cyclomatic=5 cognitive=6 function_lines=24 params=2
Go
Reference for which tree-sitter nodes pretender tracks for Go files, how
each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .go files using a tree-sitter grammar. Tracks both top-level
functions and method declarations. Go’s select/case and type-switch
cases each count as a branch, matching Go’s concurrency and type-dispatch
idioms.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
function_declaration | @function.definition | Defines a metric scope |
method_declaration | @function.definition | Defines a metric scope |
if_statement | @branch.if | +1 cyclomatic, +1 cognitive |
for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
expression_case (in switch) | @branch.case | +1 cyclomatic, +1 cognitive |
type_case (in type switch) | @branch.case | +1 cyclomatic, +1 cognitive |
communication_case (in select) | @branch.case | +1 cyclomatic, +1 cognitive |
binary_expression "&&" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary_expression `“ | “` | |
call_expression | @call | +1 ABC C-count |
assignment_statement | @assign | +1 ABC A-count |
short_var_declaration | @assign | +1 ABC A-count |
var_declaration | @assign | +1 ABC A-count |
Assertion patterns
| Pattern | Matches |
|---|---|
^assert | assert* (testify-style) |
^require | require.* (testify require package) |
^t\.Error | t.Error(...), t.Errorf(...) |
^t\.Fatal | t.Fatal(...), t.Fatalf(...) |
^t\.Fail | t.Fail(), t.FailNow() |
Quirks and limitations
- Go has no
else ifnode —else ifchains are parsed as nestedif_statementnodes, so each branch is counted independently (which is the intended behaviour). - No ternary operator — Go does not have
?:, so no ternary branches are ever counted. defaultcase in a switch is not captured as a branch — only explicitcaselabels contribute.selectblocks used for concurrency can produce high branch counts in functions that multiplex many channels.
Known unsupported metrics
min_assertions— Not implemented yet:metrics.scmhas no@assert.*capture, so unit assertion totals are always 0 (the[assertions]patterns serve rule scopes only). No ticket filed yet.
Example output
pkg/handler.go cyclomatic=7 cognitive=9 function_lines=42 params=2
internal/router.go cyclomatic=11 cognitive=15 function_lines=48 params=3
↳ Route() cyclomatic=11 [threshold: 10]
Java
Reference for which tree-sitter nodes pretender tracks for Java files, how
each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .java files using a tree-sitter grammar. Tracks both method
declarations and constructors as function scopes. Enhanced for loops and
switch statement groups each count as separate branches.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
method_declaration | @function.definition | Defines a metric scope |
constructor_declaration | @function.definition | Defines a metric scope |
if_statement | @branch.if | +1 cyclomatic, +1 cognitive |
for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
enhanced_for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
while_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
do_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
catch_clause | @branch.catch | +1 cyclomatic, +1 cognitive |
ternary_expression | @branch.ternary | +1 cyclomatic, +1 cognitive |
switch_block_statement_group / switch_label | @branch.case | +1 cyclomatic, +1 cognitive |
binary_expression "&&" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary_expression `“ | “` | |
method_invocation | @call | +1 ABC C-count |
object_creation_expression | @call | +1 ABC C-count |
assignment_expression | @assign | +1 ABC A-count |
variable_declarator (with value) | @assign | +1 ABC A-count |
Assertion patterns
| Pattern | Matches |
|---|---|
^assert | JUnit assertNotNull(...), etc. |
^Assert | Assert.assertEquals(...) (static import) |
^verify | Mockito verify(...) |
^Verify | Verify.that(...) |
^expect | expectedException.expect(...) |
^fail | fail("message") |
Quirks and limitations
instanceofchecks insideifconditions are counted as regularif_statementbranches — no special handling for pattern-matchinginstanceof(Java 16+).- Lambda expressions are not tracked as function scopes; their branches count toward the enclosing method’s complexity.
switchexpressions (Java 14+) may not be fully parsed by the current grammar revision — verify with a test file if you rely on switch-expression branch counts.object_creation_expression(new Foo(...)) counts as a call for ABC C-count, which may inflate scores in builder-heavy code.- Mutation testing (
pretender mutation) does not yet run PIT automatically. See Mutation testing for the manual workflow.
Known unsupported metrics
min_assertions— Not implemented yet:metrics.scmhas no@assert.*capture, so unit assertion totals are always 0 (the[assertions]patterns serve rule scopes only). No ticket filed yet.
Example output
src/main/java/Service.java cyclomatic=9 cognitive=13 function_lines=47 params=3
src/main/java/Parser.java cyclomatic=15 cognitive=21 function_lines=68 params=4
↳ parse() cyclomatic=15 [threshold: 10]
JavaScript
Reference for which tree-sitter nodes pretender tracks for JavaScript files,
how each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .js, .jsx, .mjs, and .cjs files using a tree-sitter grammar.
Tracks named functions, arrow functions assigned to variables, and class
methods. switch_case nodes each count as a branch.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
function_declaration | @function.definition | Defines a metric scope |
variable_declarator with arrow_function | @function.definition | Defines a metric scope |
method_definition | @function.definition | Defines a metric scope |
if_statement | @branch.if | +1 cyclomatic, +1 cognitive |
switch_case | @branch.if | +1 cyclomatic, +1 cognitive |
for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
for_in_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
while_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
do_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
catch_clause | @branch.catch | +1 cyclomatic, +1 cognitive |
ternary_expression | @branch.ternary | +1 cyclomatic, +1 cognitive |
binary_expression "&&" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary_expression `“ | “` | |
call_expression | @call | +1 ABC C-count |
assignment_expression | @assign | +1 ABC A-count |
augmented_assignment_expression | @assign | +1 ABC A-count |
variable_declarator (with value) | @assign | +1 ABC A-count |
Assertion patterns
| Pattern | Matches |
|---|---|
^assert$ | Node.js assert(...) |
^assert[A-Z] | assertEqual(...), etc. |
^expect$ | Jest / Vitest expect(...) |
^it$ | it('...', ...) test blocks |
^test$ | test('...', ...) blocks |
^describe$ | describe('...', ...) blocks |
Quirks and limitations
- Anonymous arrow functions not assigned to a named variable are not tracked as function scopes; their branches count toward the enclosing scope.
??(nullish coalescing) is not currently captured as a branch and does not contribute to cyclomatic complexity.- Optional chaining (
?.) is not tracked. switch_casenodes include bothcase X:anddefault:labels —defaultis counted as one branch.- Shebangs (
#!/usr/bin/env node) are stripped by the grammar and do not affect parsing.
Known unsupported metrics
min_assertions— Not implemented yet:metrics.scmhas no@assert.*capture, so unit assertion totals are always 0 (the[assertions]patterns serve rule scopes only). No ticket filed yet.- Nesting depth — Not implemented yet: the engine increments nesting
only inside
block-kind nodes, but tree-sitter-javascript wraps bodies instatement_block, sonesting_maxstays 0. No ticket filed yet.
Example output
src/router.js cyclomatic=8 cognitive=12 function_lines=44 params=3
src/utils.js cyclomatic=3 cognitive=4 function_lines=18 params=1
Python
Reference for which tree-sitter nodes pretender tracks for Python files, how
each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .py files using a tree-sitter grammar. Tracks all function forms
(top-level, methods, nested, decorated) and Python-specific branch constructs
including elif, except, and ternary expressions.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
function_definition | @function.definition | Defines a metric scope |
if_statement | @branch.if | +1 cyclomatic, +1 cognitive |
elif_clause | @branch.elif | +1 cyclomatic, +1 cognitive |
for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
while_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
except_clause | @branch.catch | +1 cyclomatic, +1 cognitive |
except_group_clause | @branch.catch | +1 cyclomatic, +1 cognitive |
conditional_expression | @branch.ternary | +1 cyclomatic, +1 cognitive |
boolean_operator "and" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
boolean_operator "or" | @branch.logical.or | +1 cyclomatic, +1 cognitive |
case_clause | @branch.match_case | +1 cyclomatic, +1 cognitive |
for_in_clause (comprehension) | @branch.loop | +1 cyclomatic, +1 cognitive |
if_clause (comprehension filter) | @branch.comprehension_filter | +1 cyclomatic, +1 cognitive |
call | @call | +1 ABC C-count |
assignment | @assign | +1 ABC A-count |
augmented_assignment | @assign | +1 ABC A-count |
Assertion patterns
The following call patterns are recognised as assertions for the min_assertions
metric (test role):
| Pattern | Matches |
|---|---|
^assert$ | assert(expr) call form; the keyword statement assert expr is captured separately by the assert_statement tree-sitter node |
^assert[A-Z] | assertEqual, assertRaises, assertIn, etc. |
^self\.assert | self.assertEqual(...), etc. |
^pytest\.raises$ | pytest.raises(...) |
^pytest\.warns$ | pytest.warns(...) |
Quirks and limitations
- Decorators do not contribute to complexity — only the function body does.
- Comprehensions (
[x for x in y if cond]) contain implicit branches but are not currently tracked; complexity may be understated for comprehension-heavy code. match/case(Python 3.10+) structural pattern matching arms are not yet captured; each arm contributes no cyclomatic count.except*(except_group_clause) is captured and contributes the same as a plainexcept.
Known unsupported metrics
None known. Every metric the page describes — cyclomatic (including
match/case arms and comprehension filters), cognitive, function_lines,
parameters, unit-level assertions, nesting_max via grammar-level block
nodes, ABC counts, and type definitions and fields — has a capture today;
unwrap density ships a Python detector too.
Example output
src/parser.py cyclomatic=12 cognitive=18 function_lines=55 params=3
↳ parse_token() cyclomatic=12 [threshold: 10]
src/parser.py:42 min_assertions=0 [threshold: 1] (test role)
Ruby
Reference for which tree-sitter nodes pretender tracks for Ruby files, how
each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .rb files using a tree-sitter grammar. Tracks both instance methods
and singleton methods (class-level self. methods). Ruby’s unless, until,
and rescue each count as branches alongside the more common if and while.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
method | @function.definition | Defines a metric scope |
singleton_method | @function.definition | Defines a metric scope |
if | @branch.if | +1 cyclomatic, +1 cognitive |
unless | @branch.if | +1 cyclomatic, +1 cognitive |
elsif | @branch.if | +1 cyclomatic, +1 cognitive |
for | @branch.loop | +1 cyclomatic, +1 cognitive |
while | @branch.loop | +1 cyclomatic, +1 cognitive |
until | @branch.loop | +1 cyclomatic, +1 cognitive |
rescue | @branch.rescue | +1 cyclomatic, +1 cognitive |
when (in case) | @branch.case | +1 cyclomatic, +1 cognitive |
binary "&&" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary `“ | “` | |
binary "and" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary "or" | @branch.logical.or | +1 cyclomatic, +1 cognitive |
call | @call | +1 ABC C-count |
assignment | @assign | +1 ABC A-count |
operator_assignment | @assign | +1 ABC A-count |
Assertion patterns
| Pattern | Matches |
|---|---|
^assert | Minitest assert(...), assert_equal(...), etc. |
^expect | RSpec expect(...) |
^should | RSpec legacy should syntax |
^raise_error | RSpec raise_error matcher |
Quirks and limitations
- Modifier forms (
do_something if condition,value unless flag) are parsed asif/unlessnodes and count as branches. - Both
&&/||andand/orare tracked — each contributes one cyclomatic point. Code mixing both keyword and operator forms may count more than expected. - Blocks (
do...end,{...}) are not tracked as function scopes. procandlambdaexpressions are not tracked as function scopes.case/inpattern matching (Ruby 3.0+) may not be fully parsed by the current grammar revision.
Known unsupported metrics
- Type definitions and fields — Not implemented yet (deliberate): the
archived data-model design (D2/D3) ships Ruby with zero
@type.*captures —attr_*are method calls in the grammar and classes were left uncaptured — but tree-sitter-ruby 0.23 exposesclassnodes, so captures could exist. No ticket filed yet. min_assertions— Not implemented yet:metrics.scmhas no@assert.*capture, so unit assertion totals are always 0 (the[assertions]patterns serve rule scopes only). No ticket filed yet.- Nesting depth for
if/whilebodies — Not supported by the grammar: tree-sitter-ruby 0.23 wraps them inthen/donodes and the engine nests onlyblock-kind containers (iterator blocks do nest). - Unwrap density — Not implemented yet: the engine’s risky error-handling detector covers Rust, Python, JavaScript/TypeScript, Java, and Go only; Ruby has no matcher. No ticket filed yet.
Example output
lib/parser.rb cyclomatic=8 cognitive=11 function_lines=39 params=2
spec/parser_spec.rb min_assertions=0 [threshold: 1] (test role)
Rust
Reference for which tree-sitter nodes pretender tracks for Rust files, how
each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .rs files using a tree-sitter grammar. Tracks fn items (free
functions and methods). match arms each count as one branch, reflecting
Rust’s exhaustive pattern matching.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
function_item | @function.definition | Defines a metric scope |
if_expression | @branch.if | +1 cyclomatic, +1 cognitive |
for_expression | @branch.loop | +1 cyclomatic, +1 cognitive |
while_expression | @branch.loop | +1 cyclomatic, +1 cognitive |
loop_expression | @branch.loop | +1 cyclomatic, +1 cognitive |
match_arm | @branch.match_arm | +1 cyclomatic, +1 cognitive |
call_expression | @call | +1 ABC C-count |
assignment_expression | @assign | +1 ABC A-count |
compound_assignment_expr | @assign | +1 ABC A-count |
let_declaration (with value) | @assign | +1 ABC A-count |
Assertion patterns
| Pattern | Matches |
|---|---|
^assert$ | assert!(...) |
^assert_eq$ | assert_eq!(...) |
^assert_ne$ | assert_ne!(...) |
^panic$ | panic!(...) |
Method calls in the assert_cmd / predicates vocabulary also count, one per
chain link (pretender-jg9y): .assert(), .success(), .failure(),
.code(...), .stdout(...), .stderr(...), .predicate(...) — so
cmd.assert().success().stdout(p) counts 3.
Quirks and limitations
&&and||operators are not tracked — logical operators do not contribute to cyclomatic or cognitive complexity for Rust. This reflects Rust’s idiom of chaining results and options rather than using boolean guards.- Closures are not tracked as separate function scopes; their branches count toward the enclosing function’s complexity.
if letandwhile letare captured asif_expressionandwhile_expressionrespectively, contributing one branch each.- Wildcard
_arms inmatchare counted as branches like any other arm.
Known unsupported metrics
- Logical-operator branches (
&&/||) — Not implemented yet (deliberate; see Quirks above): tree-sitter-rust exposesbinary_expressionfor both operators, but no capture exists. No ticket filed yet.
Example output
src/engine.rs cyclomatic=9 cognitive=11 function_lines=38 params=2
src/config.rs cyclomatic=14 cognitive=22 function_lines=61 params=4
↳ parse_config() cyclomatic=14 [threshold: 10]
TypeScript
Reference for which tree-sitter nodes pretender tracks for TypeScript files,
how each contributes to pretender check metrics, and known measurement gaps.
Consult this page when tuning thresholds or diagnosing unexpected scores.
Overview
Analyses .ts, .tsx, .mts, and .cts files using a tree-sitter grammar.
Identical branch and call tracking to the JavaScript adapter; type annotations
and generic type arguments are captured but carry no metric weight.
Tracked nodes
| Tree-sitter node | Capture | Metric impact |
|---|---|---|
function_declaration | @function.definition | Defines a metric scope |
variable_declarator with arrow_function | @function.definition | Defines a metric scope |
method_definition | @function.definition | Defines a metric scope |
if_statement | @branch.if | +1 cyclomatic, +1 cognitive |
switch_case | @branch.if | +1 cyclomatic, +1 cognitive |
for_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
for_in_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
while_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
do_statement | @branch.loop | +1 cyclomatic, +1 cognitive |
catch_clause | @branch.catch | +1 cyclomatic, +1 cognitive |
ternary_expression | @branch.ternary | +1 cyclomatic, +1 cognitive |
binary_expression "&&" | @branch.logical.and | +1 cyclomatic, +1 cognitive |
binary_expression `“ | “` | |
call_expression | @call | +1 ABC C-count |
assignment_expression | @assign | +1 ABC A-count |
augmented_assignment_expression | @assign | +1 ABC A-count |
variable_declarator (with value) | @assign | +1 ABC A-count |
type_annotation | @type.annotation | None |
type_arguments | @type.generic | None |
Assertion patterns
Same as JavaScript:
| Pattern | Matches |
|---|---|
^assert$ | assert(...) |
^assert[A-Z] | assertEqual(...), etc. |
^expect$ | Jest / Vitest expect(...) |
^it$ | it('...', ...) test blocks |
^test$ | test('...', ...) blocks |
^describe$ | describe('...', ...) blocks |
Quirks and limitations
- Type-only constructs (
interface,typealiases,enumdeclarations) are not tracked as function scopes. - Type guards (
if (x instanceof Y)) are counted as regularif_statementbranches — no special handling. ??(nullish coalescing) and?.(optional chaining) are not tracked as branches.- Decorators on classes and methods do not contribute to complexity.
- TypeScript-specific syntax uses the same tree-sitter grammar revision as
JavaScript (
.tsxfiles are parsed as TSX).
Known unsupported metrics
min_assertions— Not implemented yet:metrics.scmhas no@assert.*capture, so unit assertion totals are always 0 (the[assertions]patterns serve rule scopes only). No ticket filed yet.- Nesting depth — Not implemented yet: the engine increments nesting
only inside
block-kind nodes, but tree-sitter-typescript wraps bodies instatement_block, sonesting_maxstays 0. No ticket filed yet.
Example output
src/api.ts cyclomatic=6 cognitive=8 function_lines=31 params=2
src/components/Form.tsx cyclomatic=4 cognitive=5 function_lines=22 params=1
CLI and Configuration
Purpose
Defines Pretender’s command-line interface, configuration file schema, output formats, role detection, and plugin manifest contracts.
Requirements
Requirement: Init Command
The system SHALL provide pretender init to create pretender.toml, optionally install a pre-commit hook, and optionally generate GitHub Actions configuration. The command SHALL support --non-interactive and --mode <mode>.
In the current MVP, hook installation writes a repository-wide fallback shim that runs pretender check . --staged.
Scenario: Non-interactive creates config
- WHEN
pretender init --non-interactiveis run in a repository withoutpretender.toml - THEN the system writes a default
pretender.tomland exits with code 0
Scenario: Interactive init can install hook and workflow
- WHEN
pretender initis run interactively and the user opts into hook and CI setup - THEN the system writes
pretender.toml,.git/hooks/pre-commit, and.github/workflows/pretender.yml
Requirement: Check Command
The system SHALL provide pretender check [paths...] as the implemented MVP scan command for explicit file and directory inputs. The command SHALL require at least one path and SHALL recursively scan directories. It SHALL support --format human|json|sarif and --output <path>.
Every successful pretender check run SHALL persist the report cache used by pretender report, regardless of output format.
Scenario: Human check succeeds on clean file
- WHEN
pretender check path/to/file.pyruns on a file with no threshold violations - THEN the command exits with code
0
Scenario: SARIF output is emitted
- WHEN
pretender check path/to/file.py --format sarifis run - THEN stdout contains valid SARIF 2.1.0 JSON for the analysed findings
Requirement: Check Modes
pretender check SHALL support --mode guidance|tiered|gate. In guidance the command always exits 0. In tiered it always exits 0 after annotating yellow/red findings. In gate it exits non-zero when any file or unit threshold is violated.
Scenario: Guidance mode does not fail violating file
- WHEN
pretender check path/to/file.py --mode guidanceruns on a file with threshold violations - THEN the command exits with code
0after reporting the violations
Requirement: Staged Scan
--staged SHALL filter the scan to files staged in git, diffing the git index against the repository’s HEAD (or against the empty tree on a repository with no prior commit, so staged files are still detected; untracked unstaged files are never scanned). It SHALL exit 0 with a success message when the staging area is empty.
Scenario: Reserved staged flag is rejected
- WHEN
pretender check . --stagedis run in a repository with one staged file and one unstaged file - THEN the command exits with code
0and reports only the staged file
Requirement: Diff-Scoped Scan
--diff-only SHALL restrict the scan to files changed relative to the base ref given by --diff-base <ref> (default: origin/main). The diff scope SHALL include unstaged worktree edits and newly staged files, including files staged for the first time.
Scenario: Diff-only filters to changed files
- WHEN
pretender check . --diff-only --diff-base=HEAD~1runs with one file added sinceHEAD~1 - THEN only that file is scanned
Scenario: Diff-only includes unstaged worktree edits
- WHEN
pretender check . --diff-only --diff-base=HEADruns with an unstaged edit in the worktree - THEN the edited file is scanned
Scenario: Diff-only includes newly staged untracked file
- WHEN
pretender check . --diff-only --diff-base=HEADruns with a new file staged for commit - THEN the staged file is scanned
Requirement: Complexity Command
The system SHALL provide pretender complexity <path> for the current MVP. The command SHALL accept exactly one path and SHALL report cyclomatic complexity per discovered code unit, sorted worst-first.
The current MVP does NOT implement --top <n> or --threshold <n>.
Scenario: Complexity reports worst units first
- WHEN multiple code units have different cyclomatic scores
- THEN
pretender complexity <path>lists the highest scoring units before lower scoring units
Requirement: Report Command
The system SHALL provide pretender report to render cached results from the last successful pretender check. The command SHALL support --format human|markdown|html and --output <path>.
Scenario: Report reads cached human check results
- WHEN
pretender report --format markdownis run after a successful human-formatpretender check - THEN the command renders a Markdown report from the cached results
Requirement: Hooks Commands
The system SHALL provide pretender hooks install to install a native pre-commit shim and pretender hooks uninstall to remove a shim previously installed by Pretender.
In the current MVP, the installed shim SHALL run pretender check . --staged.
Scenario: Hook install writes fallback shim
- WHEN
pretender hooks installis run - THEN
.git/hooks/pre-commitcontains a Pretender-managed shim that executespretender check . --staged
Scenario: Hook uninstall removes Pretender shim
- WHEN
pretender hooks uninstallis run after Pretender installed the hook - THEN the Pretender-managed
.git/hooks/pre-commitfile is removed
Requirement: CI Generate Command
The system SHALL provide pretender ci generate github in the current MVP. The generated workflow SHALL install Pretender, run pretender check . --format=sarif --output=pretender.sarif, upload SARIF, append a Markdown report on failure, and fail the job when findings are present.
Providers other than github remain reserved and SHALL exit with code 2 and a not yet implemented message.
Scenario: GitHub workflow includes SARIF upload
- WHEN
pretender ci generate githubis run - THEN the generated workflow uploads Pretender SARIF through GitHub Code Scanning
Requirement: Configuration Schema
The system SHALL read pretender.toml with tables for [pretender], [thresholds], role-specific threshold tables such as [thresholds.test], [bands], [scope], [execute], [plugins], [output], and [roles]. The mode value SHALL be one of guidance, tiered, or gate. The implicit default role SHALL be app. Unknown config keys SHALL be ignored.
Scenario: Role-specific thresholds override app defaults
- WHEN a file is assigned role
test - THEN values under
[thresholds.test]override app threshold defaults for that file
Requirement: Role Detection
The system SHALL assign each file a role from app, library, test, script, generated, or vendor using the current MVP resolution order:
- explicit pragma found in the first 8 lines
- configured
[roles]path globs, with the most specific matching glob winning - built-in path heuristics
- default
app
The current pragma scanner SHALL accept line comments beginning with # or //, and block-comment openings beginning with /*.
Scenario: Pragma wins over path glob
- WHEN a file declares an explicit Pretender role pragma and also matches a configured role glob
- THEN the pragma role is assigned
Scenario: Most specific glob wins
- WHEN a file matches both
tests/**andtests/manual/** - THEN the more specific glob is assigned
Scenario: Heuristic role is used when no pragma or glob applies
- WHEN a file path contains
/vendor/and no pragma or configured glob applies - THEN the file is assigned role
vendor
Requirement: Schema Versioning
The system SHALL not require a config version key. Unknown config keys SHALL be ignored for forward compatibility.
Scenario: Unknown key is ignored
- WHEN
pretender.tomlcontains an unknown key - THEN parsing succeeds and the unknown key has no effect
Requirement: Output Formats
The current MVP SHALL emit human, json, and sarif output for pretender check, and human, markdown, and html output for pretender report. The junit and markdown formats for check are not implemented and are not accepted by the CLI (tracked under pretender-t2m).
Scenario: JSON report is emitted
- WHEN
pretender check path/to/file.py --format jsonis run - THEN stdout contains valid JSON describing file reports and unit metrics
Scenario: SARIF validates
- WHEN Pretender emits SARIF output from
pretender check - THEN the output conforms to the SARIF 2.1.0 schema
Requirement: Plugin Manifests
The system SHALL parse data-only plugin manifests made of .scm query files and plugin.toml metadata. In the current MVP, manifest parsing is implemented as a library capability and test fixture, but plugin installation, discovery, and runtime loading are not yet implemented by the CLI.
Scenario: Python plugin manifest parses
- WHEN the built-in Python
plugin.tomlis loaded by the manifest parser - THEN the manifest is parsed successfully and exposes its query and assertion metadata
Requirement: Reserved Commands
The current MVP CLI SHALL expose plugins as the reserved command, which exits with code 2 and a not yet implemented message. The duplication <file>, mutation, and explain <metric> commands are implemented: duplication and explain exit 0, and mutation exits 0 or 1.
Scenario: Reserved command reports not implemented
- WHEN
pretender plugins listis run - THEN the command exits with code
2and reports that the feature is not yet implemented
Requirement: Language Support
The current MVP SHALL register built-in parsers for C, C++, Go, Java, JavaScript, Python, Ruby, Rust, and TypeScript-family source files. Files with unsupported extensions SHALL be skipped by pretender check, and pretender complexity <path> on an unsupported extension SHALL fail.
Scenario: Rust file is analysed
- WHEN
pretender check example.rsis run - THEN Pretender analyses the file with the Rust parser
Scenario: Unsupported complexity input fails
- WHEN
pretender complexity example.txtis run - THEN the command exits non-zero because no parser is registered for
.txt
cli-core Specification
Purpose
Defines how pretender’s CLI entrypoint adopts the shared genesis guide
scaffold: main.rs builds its command parser with Guide::builder(), command
handlers return typed Output<T> or report through the ErrorSink, which
prints errors with suggestion footers and writes the error scratch that powers
--from-last-error.
Requirements
Requirement: CLI scaffold uses Guide
The tool’s main.rs CLI setup SHALL use genesis::guide::Guide::builder()
when the tool adopts genesis::guide. Adoption is determined by the tool’s
maintainer — this spec defines the contract for how to do it.
Scenario: Guide builder replaces ad-hoc setup
- GIVEN the tool adopts
genesis::guide - WHEN
main.rsis updated to useGuide::builder(...) - THEN command handlers SHOULD return
Output<T>or useErrorSink - AND
cargo testSHALL pass
Scenario: ErrorSink for self-healing errors
- GIVEN the tool adopts
genesis::guide - WHEN a command returns an error
- THEN
ErrorSinkSHOULD print the error with a suggestion footer - AND it SHOULD write to the error scratch (for
--from-last-error)
config Specification
Purpose
Defines how pretender adopts the shared genesis config stack: the tool’s
config struct implements genesis::config::ConfigFile, all config file I/O
(read, write, parse) delegates to genesis, the config registers with the
ConfigRegistry at startup, and superseded in-repo config code is removed.
Requirements
Requirement: Shared config management
The tool SHALL adopt genesis::config for shared config management.
Scenario: config struct implements ConfigFile
- GIVEN the tool needs config management
- WHEN the tool adopts
genesis::config - THEN the tool’s config SHALL implement
genesis::config::ConfigFile - AND all config file I/O (read, write, parse) SHALL delegate to genesis
- AND
cargo testSHALL pass
Scenario: config registered at startup
- GIVEN the tool starts up
- WHEN it initializes
- THEN it SHALL register its config struct with
ConfigRegistry - AND it SHOULD use
ConfigStorefor config discovery and validation
Scenario: dead config code removed
- GIVEN the tool has adopted genesis::config
- WHEN the old config parsing code is removed
- THEN
cargo clippySHALL introduce no new warnings - AND
cargo testSHALL pass
Universal Code Model
Purpose
Defines the language-neutral model that all Pretender metrics operate on, plus the tree-sitter query contract, model invariants, metric formulas, and compatibility rules.
Requirements
Requirement: Supporting Types
The system SHALL represent source spans, parameters, call sites, and languages in a language-neutral form. Span.lines() SHALL be inclusive and SHALL require end_line >= start_line. CallSite SHALL include a callee name, span, and default ABC smell weight of 1.0.
Scenario: Span line count is inclusive
- WHEN a span has
start_line = 3andend_line = 5 - THEN
Span.lines()returns 3
Requirement: Module Model
The system SHALL represent each successfully parsed source file as one Module containing path, language, whole-file span, total/code/comment line counts, code units, and imports. In the current MVP, imports are emitted as an empty list by the built-in query engine adapters.
Scenario: One file maps to one module
- WHEN a supported source file is parsed successfully
- THEN the engine emits one
Modulefor that file
Requirement: Code Unit Model
The system SHALL represent each parsed function-like definition as a CodeUnit with name, kind, span, parameters, body block, and metrics. Kinds SHALL include Function, Method, Ctor, and Test where the language expresses them. Kind resolution SHALL follow each language’s scoping rules, as pinned by the scenarios below.
Scenario: Clojure multi-arity defn produces one unit per arity
- WHEN a Clojure file defines
(defn f ([x] x) ([x y] (+ x y))) - THEN two units named
fare captured, with 1 and 2 parameters respectively
Scenario: Clojure deftest is a Test unit
- WHEN a Clojure file defines
(deftest arith-test (is (= 4 (+ 2 2)))) - THEN a unit named
arith-testof kindTestis captured with assertions count 1
Scenario: Python method resolves kind
- WHEN a
defappears inside a Pythonclassbody - THEN the unit kind is Method (Ctor for
__init__)
Scenario: Function maps to code unit
- WHEN a query captures
@function.definition,@function.name,@function.parameters, and@function.body - THEN the adapter creates the corresponding
CodeUnitwith name, kind, span, parameters, and body
Requirement: Block and Node Model
The system SHALL represent nested scopes as Block values with zero-based nesting depth from the enclosing CodeUnit body root. Node SHALL represent statements, branches, nested blocks, and calls.
Scenario: Root body nesting is zero
- WHEN a
CodeUnitbody is created - THEN its root block has
nesting = 0
Requirement: Branch Model
The system SHALL represent control-flow points as Branch values with kind, span, nesting depth at capture time, and optional logical sequence ID. Branch kinds SHALL include if, else-if, switch case, loop, catch, ternary, logical-and, logical-or, comprehension-filter, match-case, cond-clause, and recur. Per-language clause granularity SHALL follow the scenarios below.
Scenario: Python match arms are branches
- WHEN a Python function contains a
matchwith 3caseclauses and no other branching - THEN the unit’s cyclomatic complexity is 4 (1 + 3 match-case branches)
Scenario: Python comprehension filters are branches
- WHEN a Python comprehension has one
forclause and twoiffilters - THEN the unit captures one loop branch and two comprehension-filter branches
Scenario: Clojure cond counts per clause
- WHEN a Clojure function contains a 3-clause
condand no other branching - THEN the unit’s cyclomatic complexity is 4 (1 + 3 cond-clause branches)
Scenario: Clojure try is not a branch
- WHEN a Clojure form is
(try body (catch E e handler) (finally cleanup)) - THEN exactly one catch branch is captured and cyclomatic complexity of the enclosing unit increases by 1
Scenario: Logical sequence IDs are scoped to code unit
- WHEN logical operators are captured in two different code units
- THEN their sequence IDs are unique only within each enclosing code unit
Requirement: Tree-Sitter Query Contract
Each implemented language adapter SHALL provide a .scm query file whose required captures @function.definition, @function.name, @function.parameters, and @function.body populate the universal model’s code units.
Scenario: Function captures populate code unit
- WHEN a query captures
@function.definition,@function.name,@function.parameters, and@function.body - THEN the adapter creates the corresponding
CodeUnit
Requirement: Optional Captures and Assertions
The query engine SHALL consume optional branch, @call, @call.callee, @assign, and @assert.* captures. Assertion captures SHALL contribute to the per-code-unit assertion count used by role-specific threshold checks, and capture precedence SHALL follow the scenario below.
Scenario: Clojure control form is not a call
- WHEN a Clojure unit body contains
(if (pos? x) x (- x)) - THEN
pos?and-are calls (C-count) andifcontributes only a branch (B-count)
Requirement: Type-Definition Captures
The query engine SHALL additionally consume optional type-definition captures: @type.definition, @type.name, @type.field, @type.field.name, and @type.field.type. Type captures SHALL populate the type_definitions list of the containing Module; when absent, the list SHALL be empty and parsing SHALL still succeed.
Scenario: Type captures populate type definition
- WHEN a query captures
@type.definition,@type.name, and@type.fieldwith@type.field.namecaptures - THEN the adapter creates the corresponding
TypeDefinitionwith its captured fields
Requirement: Model Invariants
The system SHALL preserve these invariants: code-unit body nesting starts at 0; nested blocks increment nesting by 1; branches carry nesting depth at capture time; files with tree-sitter parse errors emit a warning diagnostic and return an otherwise-empty Module; identical logical operator sequences at the same nesting level count once for cognitive complexity.
Scenario: Parse error returns empty module with warning
- WHEN tree-sitter reports a parse error for a source file
- THEN the system emits a warning diagnostic and returns a
Modulewith noCodeUnitvalues
Requirement: Export Heuristic
In the current MVP query-engine-backed adapters, the system SHALL treat code units whose names begin with _ as not exported and all other named units as exported.
Scenario: Underscore-prefixed unit is not exported
- WHEN a query-engine-backed adapter parses a code unit named
_helper - THEN the unit is treated as not exported, while a unit named
helperis treated as exported
Requirement: Metric Functions
The system SHALL compute metrics as pure functions over the universal model. Cyclomatic complexity SHALL be 1 + branch count. Cognitive complexity SHALL sum branch cognitive weight multiplied by 1 + nesting_at. Function lines SHALL use inclusive span lines. Parameter count SHALL be parameter length. Maximum nesting SHALL be the maximum block nesting value. ABC SHALL compute sqrt(A^2 + B^2 + C^2) using counted assignments, weighted branches, and weighted calls.
Scenario: Cyclomatic adds one to branches
- WHEN a code unit has 4 branch nodes
- THEN cyclomatic complexity is 5
Requirement: Call Site Weighting
In the current MVP, the parser SHALL assign every parsed CallSite a default smell_weight of 1.0, with smell-specific weighting applied later during metric evaluation. The application of [smell_weights] from plugin.toml to the ABC C-count versus smell detection SHALL be pinned by an adapter unit test so the semantics are explicit and regression-guarded.
Scenario: Parsed call site gets default weight
- WHEN the parser extracts a
CallSitefrom source - THEN it carries the default
smell_weightof1.0until smell-specific weighting applies during metric evaluation
Scenario: Clojure smell weight semantics are pinned
- WHEN the Clojure adapter round-trip test runs on the standard fixture
- THEN the expected ABC values in the test document whether
[smell_weights]entries (e.g.swap!at 1.5) contribute to the C-count
Requirement: Current Adapter Surface
The current MVP SHALL register built-in adapters for C, C++, Go, Java, JavaScript, Python, Ruby, Rust, and TypeScript-family source files.
Scenario: TypeScript adapter is available
- WHEN a
.tsfile is analysed - THEN the parser registry resolves the TypeScript adapter for that file extension
Requirement: Type Definition Model
The system SHALL represent each struct, class, or record definition captured by a language adapter as a TypeDefinition on the containing Module’s type_definitions list, with name, kind (struct, class, or record), span, ordered fields, and language. Each captured field SHALL carry a name, declared type when present in the source, and span. TypeDefinition SHALL be distinct from CodeUnit; function-like members of a type remain CodeUnit entries and SHALL NOT be duplicated as fields.
Scenario: Struct maps to type definition
- WHEN a language adapter captures a struct definition with two fields
- THEN the universal model contains one
TypeDefinitionon that file’sModulewith kind struct and two ordered fields
Scenario: Members are not duplicated
- WHEN a class definition contains both fields and methods
- THEN the model contains one
TypeDefinition(fields only) plus separateCodeUnitentries for each method
Requirement: Type Captures Are Optional
Language adapters SHALL NOT be required to provide type captures. A query file without type captures SHALL yield an empty type_definitions list for that language’s modules, and the model SHALL treat empty as valid rather than as a parse failure.
Scenario: Adapter without type captures stays valid
- WHEN a language’s query file provides function captures but no type captures
- THEN its modules parse successfully with an empty
type_definitionslist
Requirement: Parameter Extraction
The system SHALL extract unit parameters from the language’s parameter capture: Python from the parameters node (including self/cls), Clojure from the arity vector’s direct symbol bindings. Destructuring bindings SHALL count as one parameter per binding form.
Scenario: Clojure parameters extracted
- WHEN a Clojure unit is
(defn complex-func [a b items] ...) - THEN the unit’s parameter count is 3 with names
a,b,items
Scenario: Destructured binding counts once
- WHEN a Clojure arity vector is
[x {:keys [a b]}] - THEN the unit’s parameter count is 2 (
xand the map binding)
Requirement: Clojure Nesting Model
Clojure adapters SHALL increment block nesting for forms nested inside branch, loop, or recur bodies within the same unit, matching the shared engine’s nesting model. let, binding, do, testing, and function-body-adjacent binding forms SHALL NOT increment nesting.
Scenario: Clojure nesting is no longer flat
- WHEN the
complex-funcfixture (nestedifinsideif,doseqcontainingif) is parsed - THEN the unit’s nesting_max is 2
Scenario: Let does not nest
- WHEN a Clojure unit body is a single
(let [x 1] x) - THEN the unit’s nesting_max is 0
Requirement: Branch Weight Table Completeness
Every branch capture kind in a language adapter’s metrics.scm SHALL have a corresponding weight row in that adapter’s plugin.toml [branches] table, and a test SHALL guard the invariant by diffing capture kinds against table rows.
Scenario: Capture without weight row fails the guard test
- WHEN a
metrics.scmintroduces a new@branch.<kind>capture with no[branches]entry inplugin.toml - THEN the weight-table guard test fails naming the missing kind
Requirement: Declared Unsupported Metrics
Each language adapter’s README SHALL list the metrics the language cannot support, so absence is intentional rather than accidental. For Clojure: type definitions (no nominal type system), per-element destructured parameter counts, and constructor unit kinds. For Python: none beyond the already-documented surface.
Scenario: Clojure README declares unsupported metrics
- WHEN a user reads
languages/clojure/README.md - THEN the unsupported-metrics section names type definitions, destructured-parameter granularity, and constructor kinds
Research Map
Relationships
- pretender/Hypothesis/H-001 (CI-gated structural rules keep undetected complexity increases below 5% of PRs within 3 months of adoption) -[predicts]-> pretender/Experiment/dogfood-structural-gates (dogfood-structural-gates)
- pretender/Model/M-001 (pretender CLI: language-agnostic structural quality analysis) -[realizes]-> pretender/Hypothesis/H-001 (CI-gated structural rules keep undetected complexity increases below 5% of PRs within 3 months of adoption)
- pretender/Question/ci-detects-structural-regressions (ci-detects-structural-regressions) -[investigates]-> pretender/Experiment/dogfood-structural-gates (dogfood-structural-gates)
Artifacts
- csharp-plugin/Artifact/handoffs-2026-10-01-session-end — .wai/projects/csharp-plugin/handoffs/2026-10-01-session-end.md
- csharp-plugin/Artifact/research-2026-07-31-exploring-pretender-codebase-to-plan-genesis-v0-4 — .wai/projects/csharp-plugin/research/2026-07-31-exploring-pretender-codebase-to-plan-genesis-v0-4.md
- language-registry/Artifact/handoffs-2026-11-25-session-end — .wai/projects/language-registry/handoffs/2026-11-25-session-end.md
- language-registry/Artifact/research-2026-11-25-dispatch-surface — .wai/projects/language-registry/research/2026-11-25-dispatch-surface.md
- pretender/Artifact/0b6b2db — 0b6b2dbb3b45ac64b11a3872810998a7446efb71
- pretender/Artifact/0dafc0e — 0dafc0e6d41daaa8a2b7f91f3939e3f014434df7
- pretender/Artifact/0f0e526 — 0f0e5261e9ffc1b4694118eb9041ab8a0fbd3981
- pretender/Artifact/0f3c156 — 0f3c156d17c569e64934a6492246f2a1d8dd32c6
- pretender/Artifact/13e3e72 — 13e3e722079f6d4103bc8b3f41e3b6c7b6ba990d
- pretender/Artifact/165023c — 165023cf4ab6413de2567e5fd26a310c95e807cb
- pretender/Artifact/1671c3f — 1671c3f60d753599cc215b86c17d327ceaad2806
- pretender/Artifact/1c1863e — 1c1863e00ef5eebe58d5931554cf14d68b886f16
- pretender/Artifact/1ea9c70 — 1ea9c7066e41ac683e3719c5b0674325599bbb0f
- pretender/Artifact/2025e00 — 2025e003c81a75146b97868594219b7997a3810a
- pretender/Artifact/224b744 — 224b74413d3ae63f232a8ff07021ff8b1a483477
- pretender/Artifact/2343c0d — 2343c0dbce8b26e688be909190fea8f2764ee0c4
- pretender/Artifact/25d7372 — 25d737280fe086ec9d1792e7eb7c5fb05715458f
- pretender/Artifact/27d7bf6 — 27d7bf60c132be52073ca5f010988945c0f69a8f
- pretender/Artifact/28443c6 — 28443c699113e15c3c6ebb1e22dbb8913f24f350
- pretender/Artifact/290e6e4 — 290e6e4be6f566d30b071d8aa62c889c1fe70472
- pretender/Artifact/29726c4 — 29726c4680d079108d4e60e8c8c1be7fa8646f72
- pretender/Artifact/2bd732f — 2bd732fbb4f74e3939ba6a2dff068abf54132eb7
- pretender/Artifact/2d3c3fb — 2d3c3fb47172d6f47607fa660b32ba40718aad3b
- pretender/Artifact/2e35b20 — 2e35b2014f1fec837a036d4dc88c930265e5293d
- pretender/Artifact/2f345d4 — 2f345d4af87a131acf918af128549d6502785472
- pretender/Artifact/3279ba5 — 3279ba57adc0784a1c3b8b534434af3be3cc5ddc
- pretender/Artifact/33d9036 — 33d9036cfbd221c4201f370989eb7ff9a0b5b86c
- pretender/Artifact/373d933 — 373d933665ec6d13a210938ba32630f9176b2a15
- pretender/Artifact/3b52c1d — 3b52c1d73bbd94a38249471a9d663a829d3ac59d
- pretender/Artifact/3fbd9dc — 3fbd9dc2499cc9e384dbd3f08e206af73f841484
- pretender/Artifact/40f29e9 — 40f29e94ddf2b7a236ffeb2f8565bb0643166cd4
- pretender/Artifact/42bb520 — 42bb520f0fe051b5a0b9f7cfa34073c7ad6ed952
- pretender/Artifact/46c0611 — 46c061151c9e8e2e68bcb3e7705013993827224e
- pretender/Artifact/4e41137 — 4e41137198c00bc30ddba4ffbcd31b010af4d4e2
- pretender/Artifact/5b848e9 — 5b848e9b496d1df40827b28481f0f1522f54f3bf
- pretender/Artifact/5fb6987 — 5fb698719804fd0687ebeb7c2f54d747825c6280
- pretender/Artifact/62264b8 — 62264b8d5942ceb2f15e11c1dab5ab7d8bdc4978
- pretender/Artifact/6324e0e — 6324e0ec456a2c197d9be307ee469b3dac952619
- pretender/Artifact/63dc23e — 63dc23ea8ce075cc26d030996d99c5a56c0c78e7
- pretender/Artifact/6646d9b — 6646d9bfb49f3a9ad525324c426472b8118d9914
- pretender/Artifact/67a4713 — 67a471310c662b3d121f80573688cc6ca82ee723
- pretender/Artifact/67f244b — 67f244b6d5eb100aba7532ed0f2e91c5d7413167
- pretender/Artifact/6dd57d8 — 6dd57d89db7addc172a507a770af22672111fabd
- pretender/Artifact/6dfa697 — 6dfa697ea5765b82d2cc1286921176cffa0733b2
- pretender/Artifact/71a5ac0 — 71a5ac0edde2ff1f86edf1a89933b19cc4a7a30b
- pretender/Artifact/73a4c5f — 73a4c5fdc9b02b06f9d938f20b2073a6b5c9bd4f
- pretender/Artifact/74c1bb9 — 74c1bb90c9bffed900a20f992073000d1e5c45c0
- pretender/Artifact/7849d24 — 7849d2473ca57c1cc5b437cac08bc19eafd5187b
- pretender/Artifact/78d52a1 — 78d52a1f0d33ea754479e45120a0587cf9354996
- pretender/Artifact/8170060 — 8170060e455f736115a14163697261bc37c52225
- pretender/Artifact/835378a — 835378a5ce6f3a53ba5a825f247766eae0eb267d
- pretender/Artifact/83c12ec — 83c12ec8ac1ef5fd7db9e5bbdfd81ddac587347e
- pretender/Artifact/84e2b0b — 84e2b0b165a02c1f124689e939d30b38cc4b55d2
- pretender/Artifact/859fb55 — 859fb55b955ff60ce2977682932f4dc311384f70
- pretender/Artifact/88b4555 — 88b455520fb070d4bdc55ccfd75562860bb2c508
- pretender/Artifact/8929af6 — 8929af6daaa81ec5897cded24980a3db12c80ed6
- pretender/Artifact/8959f4f — 8959f4f9c11fe189327cbfbf8a791ad0e0ad5b83
- pretender/Artifact/8ee54e5 — 8ee54e5bd6ca99f3d0ae0fc6453925ce655e1bb1
- pretender/Artifact/8f55e5c — 8f55e5cbcdfe62bd0139ea53c1c818850a4ba28c
- pretender/Artifact/9043496 — 90434964f5464503a0053f1c9fb9d71c795d8399
- pretender/Artifact/946049a — 946049aa7b48553f609fbb2d6284c79bf82c7b41
- pretender/Artifact/9944150 — 994415059ee5c698f75b5a59f31042480b34f746
- pretender/Artifact/9a3ec68 — 9a3ec68f69d10056a8f335c76998c1762c3dfb7f
- pretender/Artifact/9ca92b4 — 9ca92b44a2e14dae3e558c15f5e6bfb17ceb4f6f
- pretender/Artifact/a0dfbb8 — a0dfbb8e5341b29f36f18fb79ff4892447f76a9c
- pretender/Artifact/a3318b9 — a3318b9ceb371564d985fa335198d86f961e7a53
- pretender/Artifact/a719929 — a719929340d56ef7f3f9b87c050f024c55b19e7a
- pretender/Artifact/a9b0354 — a9b0354e24308ed0ab063a9892aaf29677b2e4d3
- pretender/Artifact/b09ed24 — b09ed24024a58ebe0b14f014477d9f76b999dd36
- pretender/Artifact/b1f5c00 — b1f5c00a16f3d64b7cb739b373ba565b53afff3a
- pretender/Artifact/b3b7d9f — b3b7d9f8c4f323f7e4941ffab4af71417e223163
- pretender/Artifact/b50b069 — b50b0696c5470fb17a887766021d1c77de58dab9
- pretender/Artifact/b62b4ba — b62b4baf0184cd45e974a155e838a559eed0f61d
- pretender/Artifact/b841e72 — b841e72d98790af30ae08633533004a995f15912
- pretender/Artifact/b9ef852 — b9ef852276c1ad77c508f100a2f8444a6c996bf7
- pretender/Artifact/be13b72 — be13b72ff0dd4ee3432b58e0a80bab06e871f9c0
- pretender/Artifact/bee3add — bee3add15ea9687aaecbba953fabea108e02e08c
- pretender/Artifact/c4b01d7 — c4b01d778d8e90e827e32f79099764bffb27ba50
- pretender/Artifact/c84cb87 — c84cb87649f3e997034fcbc6cfc651c063b68508
- pretender/Artifact/c9e89e0 — c9e89e0e710f4dfeaacb689e84ad0c55209a7996
- pretender/Artifact/cdf1138 — cdf1138881dfbf1f2dbe3a8b051b8ee9a395aebf
- pretender/Artifact/d0b3731 — d0b3731825f028fcc1214b6aea51491eedae22df
- pretender/Artifact/d1daf58 — d1daf58e29e04220d154022d8aabc2a0e2043baa
- pretender/Artifact/d35659b — d35659b0564096acf2e601dad872f4e6de19f557
- pretender/Artifact/d77638c — d77638cfbb9788afaa1d5691bbff45eb34afc928
- pretender/Artifact/d77afe6 — d77afe6b9d71129d32b95bbe64181a7bcac628d8
- pretender/Artifact/d7dbb27 — d7dbb27b93ad1a9a8751020ddfedc1b1721159fa
- pretender/Artifact/d9da0c1 — d9da0c1da762130ed97723068bef0d5e641ea8c3
- pretender/Artifact/de7ca87 — de7ca870c193113889ce85da674c84c3836fd041
- pretender/Artifact/dfa5701 — dfa5701d35cce23ccb7a34a13216d79f010b2808
- pretender/Artifact/e00ff90 — e00ff90765342eaa6cccef9ad4b1d61541a1063d
- pretender/Artifact/e09cad1 — e09cad1f6fff22b91541f4c1380eb543d5481493
- pretender/Artifact/e4cc3a7 — e4cc3a7ec42bb035cc07a7b51c2bad32269ad152
- pretender/Artifact/e8b30dc — e8b30dcffcbe83982c21e2ffb8bcc6eb4de615b0
- pretender/Artifact/e96f2ae — e96f2aef9689051081524e0479156c2ebf7d2abf
- pretender/Artifact/ea132c3 — ea132c3d32e236cf8ac4c1514b15b4e32e517958
- pretender/Artifact/ed7ac6e — ed7ac6e077aa786741ef8f670787ac600a7b020d
- pretender/Artifact/ee5abf6 — ee5abf6bbd71e88dfdbbc83bd3c13dad7874e931
- pretender/Artifact/ef33d55 — ef33d5573e8ebd3ddf2ffef0422967142bbee6ae
- pretender/Artifact/efd33ee — efd33ee68d66a3ebc7cfb6b60efc832c4ad5f81e
- pretender/Artifact/f179c09 — f179c095847f8453a82857bc08f93c9504cfd75d
- pretender/Artifact/f964ed0 — f964ed008595f6c9322dd7eef1b41222fcc051f2
- pretender/Artifact/fb155af — fb155af2b8bb0473d8d5f82d50fcbc8091ff7f03
- pretender/Artifact/fccf61c — fccf61c73e5f1c9ba38770d6cdaf8900e4475f41
- structural-clarity/Artifact/designs-2026-11-24-design-the-enforced-control-surface-ro5u-decis — .wai/projects/structural-clarity/designs/2026-11-24-design-the-enforced-control-surface-ro5u-decis.md
- structural-clarity/Artifact/designs-2026-11-24-green-how-the-gate-is-wired-decisions-1 — .wai/projects/structural-clarity/designs/2026-11-24-green-how-the-gate-is-wired-decisions-1.md
- structural-clarity/Artifact/designs-2026-11-27-green-evidence-recorded-above — .wai/projects/structural-clarity/designs/2026-11-27-green-evidence-recorded-above.md
- structural-clarity/Artifact/designs-2026-11-27-refactor-note-recorded — .wai/projects/structural-clarity/designs/2026-11-27-refactor-note-recorded.md
- structural-clarity/Artifact/handoffs-2026-11-24-session-end — .wai/projects/structural-clarity/handoffs/2026-11-24-session-end.md
- structural-clarity/Artifact/handoffs-2026-11-25-session-end — .wai/projects/structural-clarity/handoffs/2026-11-25-session-end.md
- structural-clarity/Artifact/handoffs-2026-11-27-session-end — .wai/projects/structural-clarity/handoffs/2026-11-27-session-end.md
- structural-clarity/Artifact/plans-2026-11-24-epic-plan-structural-clarity-for-pretender-s-ow — .wai/projects/structural-clarity/plans/2026-11-24-epic-plan-structural-clarity-for-pretender-s-ow.md
- structural-clarity/Artifact/plans-2026-11-24-plan-dogfood-pretender-s-structural-gate-in-thi — .wai/projects/structural-clarity/plans/2026-11-24-plan-dogfood-pretender-s-structural-gate-in-thi.md
- structural-clarity/Artifact/plans-2026-11-27-pretender-jg9y-four-heuristic-gaps-tdd-plan — .wai/projects/structural-clarity/plans/2026-11-27-pretender-jg9y-four-heuristic-gaps-tdd-plan.md
- structural-clarity/Artifact/research-2026-11-24-issue-review-tracer-bullet-rule-of-5-struct — .wai/projects/structural-clarity/research/2026-11-24-issue-review-tracer-bullet-rule-of-5-struct.md
- structural-clarity/Artifact/research-2026-11-24-red-dogfood-gate-wiring-is-missing-added-pret — .wai/projects/structural-clarity/research/2026-11-24-red-dogfood-gate-wiring-is-missing-added-pret.md
- structural-clarity/Artifact/research-2026-11-24-ro5u-review-of-the-dogfood-gate-in-ci-change — .wai/projects/structural-clarity/research/2026-11-24-ro5u-review-of-the-dogfood-gate-in-ci-change.md
- structural-clarity/Artifact/research-2026-11-24-ro5u-review-the-structural-clarity-investigatio — .wai/projects/structural-clarity/research/2026-11-24-ro5u-review-the-structural-clarity-investigatio.md
- structural-clarity/Artifact/research-2026-11-27-fixes-recorded — .wai/projects/structural-clarity/research/2026-11-27-fixes-recorded.md
- structural-clarity/Artifact/research-2026-11-27-ledger-recorded — .wai/projects/structural-clarity/research/2026-11-27-ledger-recorded.md
- structural-clarity/Artifact/research-2026-11-27-orient-pretender-jg9y-four-heuristic-gaps-1-r — .wai/projects/structural-clarity/research/2026-11-27-orient-pretender-jg9y-four-heuristic-gaps-1-r.md
- structural-clarity/Artifact/research-2026-11-27-red-evidence-recorded-above — .wai/projects/structural-clarity/research/2026-11-27-red-evidence-recorded-above.md
- structural-clarity/Artifact/research-2026-11-27-ship-note-recorded — .wai/projects/structural-clarity/research/2026-11-27-ship-note-recorded.md
127 nodes from 147 events.
Research Brief
Question
- pretender/Question/ci-detects-structural-regressions — ci-detects-structural-regressions
Hypothesis
- pretender/Hypothesis/H-001 — CI-gated structural rules keep undetected complexity increases below 5% of PRs within 3 months of adoption
Research Handoff
Handoffs
- csharp-plugin/Artifact/handoffs-2026-10-01-session-end — .wai/projects/csharp-plugin/handoffs/2026-10-01-session-end.md
- language-registry/Artifact/handoffs-2026-11-25-session-end — .wai/projects/language-registry/handoffs/2026-11-25-session-end.md
- structural-clarity/Artifact/handoffs-2026-11-24-session-end — .wai/projects/structural-clarity/handoffs/2026-11-24-session-end.md
- structural-clarity/Artifact/handoffs-2026-11-25-session-end — .wai/projects/structural-clarity/handoffs/2026-11-25-session-end.md
- structural-clarity/Artifact/handoffs-2026-11-27-session-end — .wai/projects/structural-clarity/handoffs/2026-11-27-session-end.md
Experiments
Question
- pretender/Question/ci-detects-structural-regressions
Hypothesis
- pretender/Hypothesis/H-001
Topic Map
Topic map
Topics
- pretender/Experiment/dogfood-structural-gates — Experiment — investigates, predicts
- pretender/Hypothesis/H-001 — Hypothesis — predicts, realizes
- pretender/Model/M-001 — Model — realizes
- pretender/Question/ci-detects-structural-regressions — Question — investigates
Relationships
See architecture-design.
Project Overview
Overview
Reader question: what is this and why does it matter
orientation.project-overview
See getting-started.
Glossary
Glossary
The closed vocabulary this build’s research graph and publications use.
Entities
- Project
- Question
- Idea
- Hypothesis
- Model
- Experiment
- Run
- Artifact
- Observation
- Claim
- Finding
- Decision
- Source
Relationships
A relationship links two entities from the closed set {Project, Question, Idea, Hypothesis, Model, Experiment, Run, Artifact, Observation, Claim, Finding, Decision, Source}:
- investigates
- predicts
- executes
- observes
- supports
- challenges
- influences
- realizes
- derives
- cites
Document kinds
- orientation.project-overview
- orientation.research-map
- exploration.exploration-brief
- exploration.experiment-specification
- exploration.experiment-record
- understanding.findings-and-analysis
- understanding.decision-record
- reuse-handoff.technical-reference
- reuse-handoff.reproduction-package
- reuse-handoff.knowledge-brief
- reuse-handoff.handoff
Getting Started
Getting-started
Reader question: how do I reach a first result
orientation.project-overview
Questions
- pretender/Question/ci-detects-structural-regressions — ci-detects-structural-regressions
Developer Guide
Developer-guide
- getting-started
- how-to — unavailable
- concept — unavailable
- example — unavailable
- troubleshooting — unavailable
- faq — unavailable
Reference
Reference
Reader question: what exactly is this
orientation.research-map
See architecture-design.
Architecture Design
Architecture-design
Reader question: how is it structured and why
orientation.research-map
Relationships
- pretender/Hypothesis/H-001 (CI-gated structural rules keep undetected complexity increases below 5% of PRs within 3 months of adoption) -[predicts]-> pretender/Experiment/dogfood-structural-gates (dogfood-structural-gates)
- pretender/Model/M-001 (pretender CLI: language-agnostic structural quality analysis) -[realizes]-> pretender/Hypothesis/H-001 (CI-gated structural rules keep undetected complexity increases below 5% of PRs within 3 months of adoption)
- pretender/Question/ci-detects-structural-regressions (ci-detects-structural-regressions) -[investigates]-> pretender/Experiment/dogfood-structural-gates (dogfood-structural-gates)
Artifacts
- csharp-plugin/Artifact/handoffs-2026-10-01-session-end — .wai/projects/csharp-plugin/handoffs/2026-10-01-session-end.md
- csharp-plugin/Artifact/research-2026-07-31-exploring-pretender-codebase-to-plan-genesis-v0-4 — .wai/projects/csharp-plugin/research/2026-07-31-exploring-pretender-codebase-to-plan-genesis-v0-4.md
- language-registry/Artifact/handoffs-2026-11-25-session-end — .wai/projects/language-registry/handoffs/2026-11-25-session-end.md
- language-registry/Artifact/research-2026-11-25-dispatch-surface — .wai/projects/language-registry/research/2026-11-25-dispatch-surface.md
- pretender/Artifact/0b6b2db — 0b6b2dbb3b45ac64b11a3872810998a7446efb71
- pretender/Artifact/0dafc0e — 0dafc0e6d41daaa8a2b7f91f3939e3f014434df7
- pretender/Artifact/0f0e526 — 0f0e5261e9ffc1b4694118eb9041ab8a0fbd3981
- pretender/Artifact/0f3c156 — 0f3c156d17c569e64934a6492246f2a1d8dd32c6
- pretender/Artifact/13e3e72 — 13e3e722079f6d4103bc8b3f41e3b6c7b6ba990d
- pretender/Artifact/165023c — 165023cf4ab6413de2567e5fd26a310c95e807cb
- pretender/Artifact/1671c3f — 1671c3f60d753599cc215b86c17d327ceaad2806
- pretender/Artifact/1c1863e — 1c1863e00ef5eebe58d5931554cf14d68b886f16
- pretender/Artifact/1ea9c70 — 1ea9c7066e41ac683e3719c5b0674325599bbb0f
- pretender/Artifact/2025e00 — 2025e003c81a75146b97868594219b7997a3810a
- pretender/Artifact/224b744 — 224b74413d3ae63f232a8ff07021ff8b1a483477
- pretender/Artifact/2343c0d — 2343c0dbce8b26e688be909190fea8f2764ee0c4
- pretender/Artifact/25d7372 — 25d737280fe086ec9d1792e7eb7c5fb05715458f
- pretender/Artifact/27d7bf6 — 27d7bf60c132be52073ca5f010988945c0f69a8f
- pretender/Artifact/28443c6 — 28443c699113e15c3c6ebb1e22dbb8913f24f350
- pretender/Artifact/290e6e4 — 290e6e4be6f566d30b071d8aa62c889c1fe70472
- pretender/Artifact/29726c4 — 29726c4680d079108d4e60e8c8c1be7fa8646f72
- pretender/Artifact/2bd732f — 2bd732fbb4f74e3939ba6a2dff068abf54132eb7
- pretender/Artifact/2d3c3fb — 2d3c3fb47172d6f47607fa660b32ba40718aad3b
- pretender/Artifact/2e35b20 — 2e35b2014f1fec837a036d4dc88c930265e5293d
- pretender/Artifact/2f345d4 — 2f345d4af87a131acf918af128549d6502785472
- pretender/Artifact/3279ba5 — 3279ba57adc0784a1c3b8b534434af3be3cc5ddc
- pretender/Artifact/33d9036 — 33d9036cfbd221c4201f370989eb7ff9a0b5b86c
- pretender/Artifact/373d933 — 373d933665ec6d13a210938ba32630f9176b2a15
- pretender/Artifact/3b52c1d — 3b52c1d73bbd94a38249471a9d663a829d3ac59d
- pretender/Artifact/3fbd9dc — 3fbd9dc2499cc9e384dbd3f08e206af73f841484
- pretender/Artifact/40f29e9 — 40f29e94ddf2b7a236ffeb2f8565bb0643166cd4
- pretender/Artifact/42bb520 — 42bb520f0fe051b5a0b9f7cfa34073c7ad6ed952
- pretender/Artifact/46c0611 — 46c061151c9e8e2e68bcb3e7705013993827224e
- pretender/Artifact/4e41137 — 4e41137198c00bc30ddba4ffbcd31b010af4d4e2
- pretender/Artifact/5b848e9 — 5b848e9b496d1df40827b28481f0f1522f54f3bf
- pretender/Artifact/5fb6987 — 5fb698719804fd0687ebeb7c2f54d747825c6280
- pretender/Artifact/62264b8 — 62264b8d5942ceb2f15e11c1dab5ab7d8bdc4978
- pretender/Artifact/6324e0e — 6324e0ec456a2c197d9be307ee469b3dac952619
- pretender/Artifact/63dc23e — 63dc23ea8ce075cc26d030996d99c5a56c0c78e7
- pretender/Artifact/6646d9b — 6646d9bfb49f3a9ad525324c426472b8118d9914
- pretender/Artifact/67a4713 — 67a471310c662b3d121f80573688cc6ca82ee723
- pretender/Artifact/67f244b — 67f244b6d5eb100aba7532ed0f2e91c5d7413167
- pretender/Artifact/6dd57d8 — 6dd57d89db7addc172a507a770af22672111fabd
- pretender/Artifact/6dfa697 — 6dfa697ea5765b82d2cc1286921176cffa0733b2
- pretender/Artifact/71a5ac0 — 71a5ac0edde2ff1f86edf1a89933b19cc4a7a30b
- pretender/Artifact/73a4c5f — 73a4c5fdc9b02b06f9d938f20b2073a6b5c9bd4f
- pretender/Artifact/74c1bb9 — 74c1bb90c9bffed900a20f992073000d1e5c45c0
- pretender/Artifact/7849d24 — 7849d2473ca57c1cc5b437cac08bc19eafd5187b
- pretender/Artifact/78d52a1 — 78d52a1f0d33ea754479e45120a0587cf9354996
- pretender/Artifact/8170060 — 8170060e455f736115a14163697261bc37c52225
- pretender/Artifact/835378a — 835378a5ce6f3a53ba5a825f247766eae0eb267d
- pretender/Artifact/83c12ec — 83c12ec8ac1ef5fd7db9e5bbdfd81ddac587347e
- pretender/Artifact/84e2b0b — 84e2b0b165a02c1f124689e939d30b38cc4b55d2
- pretender/Artifact/859fb55 — 859fb55b955ff60ce2977682932f4dc311384f70
- pretender/Artifact/88b4555 — 88b455520fb070d4bdc55ccfd75562860bb2c508
- pretender/Artifact/8929af6 — 8929af6daaa81ec5897cded24980a3db12c80ed6
- pretender/Artifact/8959f4f — 8959f4f9c11fe189327cbfbf8a791ad0e0ad5b83
- pretender/Artifact/8ee54e5 — 8ee54e5bd6ca99f3d0ae0fc6453925ce655e1bb1
- pretender/Artifact/8f55e5c — 8f55e5cbcdfe62bd0139ea53c1c818850a4ba28c
- pretender/Artifact/9043496 — 90434964f5464503a0053f1c9fb9d71c795d8399
- pretender/Artifact/946049a — 946049aa7b48553f609fbb2d6284c79bf82c7b41
- pretender/Artifact/9944150 — 994415059ee5c698f75b5a59f31042480b34f746
- pretender/Artifact/9a3ec68 — 9a3ec68f69d10056a8f335c76998c1762c3dfb7f
- pretender/Artifact/9ca92b4 — 9ca92b44a2e14dae3e558c15f5e6bfb17ceb4f6f
- pretender/Artifact/a0dfbb8 — a0dfbb8e5341b29f36f18fb79ff4892447f76a9c
- pretender/Artifact/a3318b9 — a3318b9ceb371564d985fa335198d86f961e7a53
- pretender/Artifact/a719929 — a719929340d56ef7f3f9b87c050f024c55b19e7a
- pretender/Artifact/a9b0354 — a9b0354e24308ed0ab063a9892aaf29677b2e4d3
- pretender/Artifact/b09ed24 — b09ed24024a58ebe0b14f014477d9f76b999dd36
- pretender/Artifact/b1f5c00 — b1f5c00a16f3d64b7cb739b373ba565b53afff3a
- pretender/Artifact/b3b7d9f — b3b7d9f8c4f323f7e4941ffab4af71417e223163
- pretender/Artifact/b50b069 — b50b0696c5470fb17a887766021d1c77de58dab9
- pretender/Artifact/b62b4ba — b62b4baf0184cd45e974a155e838a559eed0f61d
- pretender/Artifact/b841e72 — b841e72d98790af30ae08633533004a995f15912
- pretender/Artifact/b9ef852 — b9ef852276c1ad77c508f100a2f8444a6c996bf7
- pretender/Artifact/be13b72 — be13b72ff0dd4ee3432b58e0a80bab06e871f9c0
- pretender/Artifact/bee3add — bee3add15ea9687aaecbba953fabea108e02e08c
- pretender/Artifact/c4b01d7 — c4b01d778d8e90e827e32f79099764bffb27ba50
- pretender/Artifact/c84cb87 — c84cb87649f3e997034fcbc6cfc651c063b68508
- pretender/Artifact/c9e89e0 — c9e89e0e710f4dfeaacb689e84ad0c55209a7996
- pretender/Artifact/cdf1138 — cdf1138881dfbf1f2dbe3a8b051b8ee9a395aebf
- pretender/Artifact/d0b3731 — d0b3731825f028fcc1214b6aea51491eedae22df
- pretender/Artifact/d1daf58 — d1daf58e29e04220d154022d8aabc2a0e2043baa
- pretender/Artifact/d35659b — d35659b0564096acf2e601dad872f4e6de19f557
- pretender/Artifact/d77638c — d77638cfbb9788afaa1d5691bbff45eb34afc928
- pretender/Artifact/d77afe6 — d77afe6b9d71129d32b95bbe64181a7bcac628d8
- pretender/Artifact/d7dbb27 — d7dbb27b93ad1a9a8751020ddfedc1b1721159fa
- pretender/Artifact/d9da0c1 — d9da0c1da762130ed97723068bef0d5e641ea8c3
- pretender/Artifact/de7ca87 — de7ca870c193113889ce85da674c84c3836fd041
- pretender/Artifact/dfa5701 — dfa5701d35cce23ccb7a34a13216d79f010b2808
- pretender/Artifact/e00ff90 — e00ff90765342eaa6cccef9ad4b1d61541a1063d
- pretender/Artifact/e09cad1 — e09cad1f6fff22b91541f4c1380eb543d5481493
- pretender/Artifact/e4cc3a7 — e4cc3a7ec42bb035cc07a7b51c2bad32269ad152
- pretender/Artifact/e8b30dc — e8b30dcffcbe83982c21e2ffb8bcc6eb4de615b0
- pretender/Artifact/e96f2ae — e96f2aef9689051081524e0479156c2ebf7d2abf
- pretender/Artifact/ea132c3 — ea132c3d32e236cf8ac4c1514b15b4e32e517958
- pretender/Artifact/ed7ac6e — ed7ac6e077aa786741ef8f670787ac600a7b020d
- pretender/Artifact/ee5abf6 — ee5abf6bbd71e88dfdbbc83bd3c13dad7874e931
- pretender/Artifact/ef33d55 — ef33d5573e8ebd3ddf2ffef0422967142bbee6ae
- pretender/Artifact/efd33ee — efd33ee68d66a3ebc7cfb6b60efc832c4ad5f81e
- pretender/Artifact/f179c09 — f179c095847f8453a82857bc08f93c9504cfd75d
- pretender/Artifact/f964ed0 — f964ed008595f6c9322dd7eef1b41222fcc051f2
- pretender/Artifact/fb155af — fb155af2b8bb0473d8d5f82d50fcbc8091ff7f03
- pretender/Artifact/fccf61c — fccf61c73e5f1c9ba38770d6cdaf8900e4475f41
- structural-clarity/Artifact/designs-2026-11-24-design-the-enforced-control-surface-ro5u-decis — .wai/projects/structural-clarity/designs/2026-11-24-design-the-enforced-control-surface-ro5u-decis.md
- structural-clarity/Artifact/designs-2026-11-24-green-how-the-gate-is-wired-decisions-1 — .wai/projects/structural-clarity/designs/2026-11-24-green-how-the-gate-is-wired-decisions-1.md
- structural-clarity/Artifact/designs-2026-11-27-green-evidence-recorded-above — .wai/projects/structural-clarity/designs/2026-11-27-green-evidence-recorded-above.md
- structural-clarity/Artifact/designs-2026-11-27-refactor-note-recorded — .wai/projects/structural-clarity/designs/2026-11-27-refactor-note-recorded.md
- structural-clarity/Artifact/handoffs-2026-11-24-session-end — .wai/projects/structural-clarity/handoffs/2026-11-24-session-end.md
- structural-clarity/Artifact/handoffs-2026-11-25-session-end — .wai/projects/structural-clarity/handoffs/2026-11-25-session-end.md
- structural-clarity/Artifact/handoffs-2026-11-27-session-end — .wai/projects/structural-clarity/handoffs/2026-11-27-session-end.md
- structural-clarity/Artifact/plans-2026-11-24-epic-plan-structural-clarity-for-pretender-s-ow — .wai/projects/structural-clarity/plans/2026-11-24-epic-plan-structural-clarity-for-pretender-s-ow.md
- structural-clarity/Artifact/plans-2026-11-24-plan-dogfood-pretender-s-structural-gate-in-thi — .wai/projects/structural-clarity/plans/2026-11-24-plan-dogfood-pretender-s-structural-gate-in-thi.md
- structural-clarity/Artifact/plans-2026-11-27-pretender-jg9y-four-heuristic-gaps-tdd-plan — .wai/projects/structural-clarity/plans/2026-11-27-pretender-jg9y-four-heuristic-gaps-tdd-plan.md
- structural-clarity/Artifact/research-2026-11-24-issue-review-tracer-bullet-rule-of-5-struct — .wai/projects/structural-clarity/research/2026-11-24-issue-review-tracer-bullet-rule-of-5-struct.md
- structural-clarity/Artifact/research-2026-11-24-red-dogfood-gate-wiring-is-missing-added-pret — .wai/projects/structural-clarity/research/2026-11-24-red-dogfood-gate-wiring-is-missing-added-pret.md
- structural-clarity/Artifact/research-2026-11-24-ro5u-review-of-the-dogfood-gate-in-ci-change — .wai/projects/structural-clarity/research/2026-11-24-ro5u-review-of-the-dogfood-gate-in-ci-change.md
- structural-clarity/Artifact/research-2026-11-24-ro5u-review-the-structural-clarity-investigatio — .wai/projects/structural-clarity/research/2026-11-24-ro5u-review-the-structural-clarity-investigatio.md
- structural-clarity/Artifact/research-2026-11-27-fixes-recorded — .wai/projects/structural-clarity/research/2026-11-27-fixes-recorded.md
- structural-clarity/Artifact/research-2026-11-27-ledger-recorded — .wai/projects/structural-clarity/research/2026-11-27-ledger-recorded.md
- structural-clarity/Artifact/research-2026-11-27-orient-pretender-jg9y-four-heuristic-gaps-1-r — .wai/projects/structural-clarity/research/2026-11-27-orient-pretender-jg9y-four-heuristic-gaps-1-r.md
- structural-clarity/Artifact/research-2026-11-27-red-evidence-recorded-above — .wai/projects/structural-clarity/research/2026-11-27-red-evidence-recorded-above.md
- structural-clarity/Artifact/research-2026-11-27-ship-note-recorded — .wai/projects/structural-clarity/research/2026-11-27-ship-note-recorded.md
127 nodes from 147 events.
Tutorial
Tutorial
Reader question: can you teach me through a guided outcome
exploration.exploration-brief
Question
- pretender/Question/ci-detects-structural-regressions — ci-detects-structural-regressions
Hypothesis
- pretender/Hypothesis/H-001 — CI-gated structural rules keep undetected complexity increases below 5% of PRs within 3 months of adoption
Status & Compatibility
Status-compatibility
Reader question: what can I rely on
orientation.project-overview
See getting-started.
Release Migration
Release-migration
Reader question: what changed and what must I do
orientation.project-overview
See getting-started.