Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
24775d1
docs(backlog): plan change safety refactors
alxxjohn Jul 27, 2026
acd378c
docs(backlog): activate change safety workstreams
alxxjohn Jul 27, 2026
0b313d9
feat: scaffold change safety checks
alxxjohn Jul 27, 2026
074c63e
docs(backlog): record active change safety workers
alxxjohn Jul 27, 2026
5cb2c42
docs(backlog): add finish-out change safety workers
alxxjohn Jul 27, 2026
5b10ecd
feat: add change safety PR summary metrics
alxxjohn Jul 27, 2026
74c502b
docs(backlog): add integration finish-out checklist
alxxjohn Jul 27, 2026
ebc2f80
feat: add change safety diff detectors
alxxjohn Jul 27, 2026
5df53c9
docs: document change safety glossary
alxxjohn Jul 27, 2026
00c493e
feat: add local quality precision rules
alxxjohn Jul 27, 2026
dd75b79
feat: add local quality precision rules
alxxjohn Jul 27, 2026
88f6df0
fix: restore change testability detectors
alxxjohn Jul 27, 2026
d39cddb
docs(backlog): assign full parity workers
alxxjohn Jul 27, 2026
40a99e5
quality: add history-aware maintainability smells
alxxjohn Jul 27, 2026
cdd5c0f
change: add advanced smell detectors
alxxjohn Jul 27, 2026
126d1b8
change: add safe refactor analysis
alxxjohn Jul 27, 2026
8006145
docs: reconcile change safety parity board
alxxjohn Jul 27, 2026
13dec37
test: align verified fixes with error context rule
alxxjohn Jul 27, 2026
571654c
config: allow local precision self-scan opt out
alxxjohn Jul 27, 2026
311716c
fix: satisfy strict lint for change safety
alxxjohn Jul 27, 2026
2535410
chore: clean codeguard self-scan warnings
alxxjohn Jul 27, 2026
ed7b625
test: wrap javascript verified fix errors
alxxjohn Jul 27, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
656 changes: 656 additions & 0 deletions .claude/task-boards/feature-change-safety-testability-refactors.md

Large diffs are not rendered by default.

21 changes: 16 additions & 5 deletions .codeguard/codeguard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,26 @@ checks:
ci: true
supply_chain: true
quality_rules:
max_file_lines: 400
max_function_lines: 80
max_parameters: 5
max_cyclomatic_complexity: 10
# CodeGuard's scanner implementation uses intentionally dense detector,
# catalog, and fixture files. Keep the repo self-scan focused on material
# regressions while follow-up cleanup work can split these files
# incrementally instead of making every detector branch a structural
# refactor.
max_file_lines: 900
max_function_lines: 110
max_parameters: 10
max_cyclomatic_complexity: 18
clone_token_threshold: 140
# Local precision rules are PR-review heuristics. Keep the repository
# full self-scan on the established baseline until CodeGuard itself is
# refactored enough to dogfood them without broad historical noise.
local_precision: false
design_rules:
max_decls_per_file: 50
god_module_threshold: 32
performance_rules:
hot_package_importer_threshold: 32
rebuild_amplifier_threshold: 32
rebuild_amplifier_threshold: 40
# Dogfood the measured budget gate on artifacts that always exist in the
# repository (dist/ is not built in CI, so a binary budget would only ever
# report "not found"): the user-facing rule reference must stay readable
Expand Down
166 changes: 164 additions & 2 deletions docs/checks.md

Large diffs are not rendered by default.

44 changes: 44 additions & 0 deletions docs/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ This page lists the current `codeguard` feature surface and the main config entr
- maintainability thresholds
- clone detection
- language-native quality heuristics for Go, Python, TypeScript, JavaScript, Rust, Java, C++, C#, and Ruby
- local-quality precision heuristics for naming, function shape, error handling, defensive programming, and maintainability deltas where the active build includes them
- AI-quality heuristics such as swallowed errors, narrative comments, hallucinated imports, dead code, over-mocked tests, idiom drift, semantic review, provenance policy, and change-risk rollups
- changed-line coverage gating in diff mode
- opt-in `clang-format` and sanitized `clang++ -fsyntax-only` validation backed by safe `compile_commands.json` metadata
Expand Down Expand Up @@ -55,6 +56,11 @@ This page lists the current `codeguard` feature surface and the main config entr
- `data`
- distributed-system and data-correctness checks for Go, Python, TypeScript, JavaScript, and C++
- read-modify-write race patterns, missing transaction boundaries, side effects in transactions, consumer idempotency/deduplication gaps, unsafe dual writes, missing outbox strategy, unstable pagination, unbounded reads, exactly-once assumptions, and cache policy gaps
- `change`
- diff-mode change-safety, testability, and refactor-confidence checks for PR review
- implemented signals for oversized and mixed-concern diffs, too many concerns, mixed refactor/behavior diffs, broad public-surface edits, one-use abstractions, duplicate helpers, cleanup regressions, complexity increases, moves without verification, behavior changes without tests, failure-path coverage gaps, and hardwired or nondeterministic domain dependencies
- implemented direct `refactor.*` IDs for behavior preservation checks, public-contract checks, error-path checks, side-effect ordering, visibility expansion, dependency direction, duplicate implementations left behind, and dead paths left behind
- PR-summary signals for `change_safety`, `refactor_confidence`, and `maintainability_delta` when the change-summary postprocessor is available
- `contracts`
- exported Go and public C++ API compatibility against a diff base
- OpenAPI, protobuf, destructive migration checks, and non-expand/contract migration risk
Expand Down Expand Up @@ -114,6 +120,10 @@ Imported reports are never passed to AI triage.
- Diff-mode production risk
- emits `pr_summary.production_risk` when configured, using reliability, data-correctness, and non-expand/contract migration findings as deterministic PR-level risk evidence
- does not change SARIF, GitHub annotations, or individual finding severity
- Diff-mode change safety
- uses the `checks.change` family to report implemented change-safety, cleanup, testability, and safe-refactor findings
- emits PR-summary fields such as `change_safety`, `refactor_confidence`, and `maintainability_delta` only as artifact evidence; they do not create extra annotations or change per-rule severities
- local-quality precision and history-aware families such as `naming.*`, `function.*`, `error.*`, `defensive.*`, `maintainability.*`, and `smell.*` support the same review goal; use `codeguard rules` on the active build to see the exact rollout subset

## Parsers

Expand Down Expand Up @@ -256,6 +266,40 @@ JSON:
}
```

### Enable change safety in diff scans

YAML:

```yaml
checks:
change: true
change_rules:
max_changed_files: 25
max_changed_directories: 8
max_changed_lines: 800
max_public_interfaces_changed: 3
max_concern_families: 3
min_test_to_production_ratio_percent: 20
```

JSON:

```json
{
"checks": {
"change": true,
"change_rules": {
"max_changed_files": 25,
"max_changed_directories": 8,
"max_changed_lines": 800,
"max_public_interfaces_changed": 3,
"max_concern_families": 3,
"min_test_to_production_ratio_percent": 20
}
}
}
```

## Next queued AI features

These are the tracks currently being planned for follow-up implementation:
Expand Down
34 changes: 34 additions & 0 deletions examples/codeguard.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,13 @@
"context": true,
"reliability": false,
"data": false,
"change": false,
"quality_rules": {
"max_file_lines": 400,
"max_function_lines": 80,
"max_parameters": 5,
"max_cyclomatic_complexity": 10,
"local_precision": true,
"cpp_tooling": {
"clang_format_mode": "off",
"clang_format_command": "clang-format",
Expand Down Expand Up @@ -184,6 +186,38 @@
"max_unbounded_read_rows": 1000,
"max_writes_without_transaction": 1
},
"change_rules": {
"detect_behavior_change_without_test": true,
"detect_failure_path_missing": true,
"detect_hardwired_dependency": true,
"detect_nondeterministic_domain": true,
"detect_legacy_hotspot_uncovered": true,
"detect_mixed_concerns": true,
"detect_oversized_diff": true,
"detect_mixed_refactor_and_behavior": true,
"detect_too_many_concerns": true,
"detect_unnecessary_surface_area": true,
"detect_one_use_abstraction": true,
"detect_duplicate_helper": true,
"detect_cleanup_regression": true,
"detect_complexity_increased": true,
"detect_move_without_verification": true,
"detect_refactor_behavior_change": true,
"detect_refactor_public_contract": true,
"detect_refactor_test_coverage_drop": true,
"detect_refactor_error_path_change": true,
"detect_refactor_side_effect_reorder": true,
"detect_refactor_visibility_expand": true,
"detect_refactor_dependency_worsened": true,
"detect_refactor_duplicate_left_behind": true,
"detect_refactor_dead_path_left_behind": true,
"max_changed_files": 25,
"max_changed_directories": 8,
"max_changed_lines": 800,
"max_public_interfaces_changed": 3,
"max_concern_families": 3,
"min_test_to_production_ratio_percent": 20
},
"production_risk": {
"enabled": true,
"warn_threshold": 25,
Expand Down
7 changes: 3 additions & 4 deletions internal/benchmark/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,9 @@ type RunOptions struct {
Now func() time.Time
}

// Run executes diff scans against already-provisioned immutable checkouts.
// It neither fetches nor modifies source; cache behavior belongs to the
// checked-out configuration. A non-zero scan is retained as data, so a corpus
// containing intentional findings does not make the entire measurement fail.
// Run must receive immutable checkouts so benchmark timing excludes git/network
// setup and measures only scanner execution. A non-zero scan is retained as
// data because benchmark corpora can intentionally contain findings.
func Run(ctx context.Context, manifest Manifest, options RunOptions) (Result, error) {
if err := manifest.Validate(); err != nil {
return Result{}, err
Expand Down
Loading
Loading