Skip to content

refactor(sdk): move go/container decorators to codepathfinder package + rename Python DSL → SDK#658

Merged
shivasurya merged 5 commits intomainfrom
shiva/golang-rules-cleanup
Apr 13, 2026
Merged

refactor(sdk): move go/container decorators to codepathfinder package + rename Python DSL → SDK#658
shivasurya merged 5 commits intomainfrom
shiva/golang-rules-cleanup

Conversation

@shivasurya
Copy link
Copy Markdown
Owner

Summary

  • Move go_decorators.py and go_ir.py from python-sdk/rules/ to python-sdk/codepathfinder/ — the canonical SDK package location
  • Move container_decorators.py and container_ir.py to python-sdk/codepathfinder/ for consistency
  • Replace old locations with backward-compatibility shims that re-export from codepathfinder
  • Update all 69 rule files (rules/golang/ and rules/docker*/) to import from codepathfinder directly
  • Fix 18 meta.yaml files: quote YAML list items containing : that broke js-yaml strict parsing
  • Rename "Python DSL" → "Python SDK" across docs, code comments, CHANGELOG, CLAUDE.md, and examples

Motivation

The @go_rule and @dockerfile_rule/@compose_rule decorators belong in the core codepathfinder SDK package, not in the rules/ directory. This aligns with where @python_rule lives and makes the import paths consistent for rule authors.

Test plan

  • All existing Go rule imports resolve correctly via from codepathfinder.go_decorators import go_rule
  • All existing Docker/Compose rule imports resolve correctly via from codepathfinder.container_decorators import dockerfile_rule
  • Backward-compat shims in rules/go_decorators.py and rules/container_decorators.py re-export all symbols
  • generate-registry.mjs script runs without YAML parsing errors on all 22 Go rules

🤖 Generated with Claude Code

shivasurya and others added 2 commits April 12, 2026 15:10
… + rename Python DSL → SDK

## Decorator Relocation

Move four modules from `python-sdk/rules/` → `python-sdk/codepathfinder/`:
- `rules/go_decorators.py` → `codepathfinder/go_decorators.py`
- `rules/go_ir.py`         → `codepathfinder/go_ir.py`
- `rules/container_decorators.py` → `codepathfinder/container_decorators.py`
- `rules/container_ir.py`         → `codepathfinder/container_ir.py`

Old locations kept as backward-compat shims that re-export from the new paths.

Import changes (69 rule files updated):
  Before: from rules.go_decorators import go_rule
  After:  from codepathfinder.go_decorators import go_rule

  Before: from rules.container_decorators import dockerfile_rule, compose_rule
  After:  from codepathfinder.container_decorators import dockerfile_rule, compose_rule

## Python DSL → Python SDK

Rename all references to "Python DSL" → "Python SDK" across the repo
(comments, docs, Go source files, CHANGELOG, CLAUDE.md).

## YAML meta.yaml fixes (golang rules)

Quote list items containing ': ' sequences in 18 Go rule meta.yaml files
to prevent js-yaml strict-parsing failures when building the website registry.
Also fixes GO-XSS-001 title containing 'javascript:'.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Log skipped rule files at debug level instead of silently ignoring,
aiding diagnosis when container rules or invalid files are encountered.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shivasurya shivasurya added go Pull requests that update go code python refactor labels Apr 12, 2026
@shivasurya shivasurya self-assigned this Apr 12, 2026
@shivasurya shivasurya added go Pull requests that update go code python refactor labels Apr 12, 2026
@safedep
Copy link
Copy Markdown

safedep bot commented Apr 12, 2026

⚠️ Scan Failed: Pull Request Too Large

This pull request exceeds GitHub's diff limits and cannot be scanned.

GitHub Limits:

  • Maximum 300 files per diff
  • Maximum 1 MB total diff size

Recommendations:

  • Split this PR into smaller, focused changes
  • Review critical dependency changes manually
  • Contact your team if this is blocking your workflow
    This report is generated by SafeDep Github App

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 12, 2026

Code Pathfinder Security Scan

Pass Critical High Medium Low Info

No security issues detected.

Metric Value
Files Scanned 380
Rules 205

Powered by Code Pathfinder

@codecov
Copy link
Copy Markdown

codecov bot commented Apr 12, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 84.94%. Comparing base (83f9052) to head (73d0788).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #658      +/-   ##
==========================================
+ Coverage   84.91%   84.94%   +0.02%     
==========================================
  Files         172      172              
  Lines       24879    24882       +3     
==========================================
+ Hits        21126    21136      +10     
+ Misses       2964     2959       -5     
+ Partials      789      787       -2     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

shivasurya and others added 3 commits April 12, 2026 15:20
Add mockLogger and test case to cover the `if logger != nil { logger.Debug(...) }`
block that was introduced in the rule loader's directory walker. Brings
loadRulesFromDirectory from 72.2% to 88.9% patch coverage.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…tories

Add go.mod + go.sum to every tests/positive/ and tests/negative/ directory,
making each a proper isolated Go module. This enables:
- Multi-file playground in cpf-website (go.mod tab appears first)
- Correct module resolution for the static analysis engine
- Consistent project structure matching real Go codebases

Rules with external deps (gin, gorm, pgx, sqlx, echo, grpc, jwt) have
fully resolved go.sum with real checksums from go mod tidy.
Stdlib-only rules have an empty go.sum (correct: no external downloads).

Also disables GO-SQLI-002 (pgx/v5 type inference gap — pre-existing issue,
not caused by this change).

Generated by scripts/gen_go_modules.py.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
…thfinder package

- Add python_decorators, python_ir, container_matchers, container_combinators,
  container_programmatic to codepathfinder/ (canonical home)
- Replace original files in rules/ with backward-compat shims re-exporting from codepathfinder
- Update all 158 Python rules: from rules.python_decorators → from codepathfinder.python_decorators
- Update all 47 container rules: from rules.container_* → from codepathfinder.container_*
- Matches pattern established for go_decorators and container_decorators migrations

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@shivasurya shivasurya merged commit 232198b into main Apr 13, 2026
7 of 8 checks passed
@shivasurya shivasurya deleted the shiva/golang-rules-cleanup branch April 13, 2026 01:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

go Pull requests that update go code python refactor

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant