Skip to content

Conversation

@blalterman
Copy link
Owner

Summary

  • Add Development Copilot slash commands (/swp:dev:implement, /swp:dev:fix-tests, /swp:dev:dataframe-audit, /swp:dev:refactor-class)
  • Add ast-grep pattern rules for DataFrame and class usage (advisory mode)
  • Add contract tests as executable documentation (82 tests)
  • Add hook integration tests for automated validation
  • Update dependencies: pre-commit, urllib3 security fix (CVE-2026-21441)

Changes

Category Files Description
Commands 4 new /swp:dev:* slash commands for guided workflows
ast-grep 2 new Pattern rules for DataFrame and class usage
Tests 3 new 82 contract tests + hook integration tests
Deps 4 modified conda env, pyproject.toml, requirements

Test plan

  • All 82 contract tests pass
  • Hook integration tests pass
  • ast-grep rules validate without errors
  • Manual test: /swp:dev:implement on a feature
  • Manual test: /swp:dev:dataframe-audit on codebase

🤖 Generated with Claude Code

blalterman and others added 10 commits January 4, 2026 03:18
Add hook integration tests validating:
- Hook chain execution order (SessionStart → Stop)
- settings.json configuration for all lifecycle events
- Hook script existence and functionality
- Definition of Done pattern enforcement
- Test-runner modes for physics and coverage validation

Tests verify existing hook infrastructure without requiring
actual file edits or git operations.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Core Dev Loop slash commands:
- /swp:dev:implement - Guided feature/fix implementation
  - Analysis, planning, and execution phases
  - Physics validation for core/instabilities modules
  - Hook-based Definition of Done pattern

- /swp:dev:fix-tests - Guided test failure recovery
  - 6 failure categories with targeted fixes
  - DataFrame pattern recovery guide
  - Physics constraint validation

Both commands leverage existing hooks as validation layer.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add DataFrame patterns tooling:
- /swp:dev:dataframe-audit - Audit command for M/C/S patterns
- dataframe-patterns.yml - ast-grep rules (advisory mode)
  - swp-df-001: Prefer .xs() over boolean indexing
  - swp-df-002: Chain reorder_levels with sort_index
  - swp-df-003: Use transpose-groupby pattern
  - swp-df-004: Validate MultiIndex names
  - swp-df-005: Check duplicate columns
  - swp-df-006: Level parameter usage

- test_contracts_dataframe.py - 23 contract tests covering:
  - MultiIndex structure validation (M/C/S names, 3 levels)
  - Ion data requirements (M/C names, required columns)
  - Cross-section patterns (.xs() usage)
  - Reorder levels + sort_index chain
  - Groupby transpose pattern
  - Column duplication prevention
  - Level-specific operations

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Add Class Usage slice:
- /swp:dev:refactor-class - Analyze and refactor class patterns
  - Class hierarchy documentation (Core → Base → Plasma/Ion/etc)
  - Constructor validation patterns
  - Species handling rules

- class-patterns.yml - ast-grep rules (advisory mode)
  - swp-class-001: Plasma constructor requires species
  - swp-class-002: Ion constructor requires species
  - swp-class-003: Spacecraft requires name and frame
  - swp-class-004: xs() should specify axis and level
  - swp-class-005: super().__init__() pattern
  - swp-class-006: Plasma attribute access via __getattr__

- test_contracts_class.py - 35 contract tests covering:
  - Class hierarchy inheritance
  - Core/Base class initialization (logger, units, constants)
  - Ion class requirements and data extraction
  - Plasma class species handling and Ion creation
  - Vector and Tensor class structure
  - Constructor validation contracts

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
…ction

- Update /swp:dev:dataframe-audit to use `sg scan --config` as primary method
- Update /swp:dev:refactor-class with ast-grep validation section
- Fix ast-grep YAML rules to use `rule:` block with `$$$args` syntax
- Add installation instructions for ast-grep (brew/pip/cargo)
- Document grep fallback for patterns ast-grep can't handle
- Change rule severity from warning to info (advisory mode)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- ast-grep-py>=0.35: Structural code pattern matching for /swp:dev:* commands
- pre-commit>=3.5: Git hook framework (was missing from dev deps)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Regenerate docs/requirements.txt with urllib3 security fix
- Regenerate requirements-dev.lock with security fix + new deps
- Adds ast-grep-py and pre-commit to dev lockfile

Resolves dependabot alert #71 (decompression bomb vulnerability)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add translations: blosc2→python-blosc2, msgpack→msgpack-python,
  mypy-extensions→mypy_extensions, restructuredtext-lint→restructuredtext_lint
- Add PIP_ONLY_PACKAGES set for packages not on conda-forge (ast-grep-py)
- Regenerate solarwindpy.yml from requirements-dev.lock with all dev deps
- Update header to mention pip-only packages and recommend pip install -e ".[dev]"

This fixes conda env creation failures when packages have different names
on PyPI vs conda-forge, or are pip-only.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Instead of excluding pip-only packages (like ast-grep-py), add them to
a `pip:` subsection in the generated solarwindpy.yml. This allows
single-step environment creation:

    conda env create -f solarwindpy.yml  # Installs everything
    pip install -e .                     # Just editable install

The pip: subsection is automatically populated from PIP_ONLY_PACKAGES
and installed by conda during env creation.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Remove ast-grep-py from dev dependencies in pyproject.toml
- ast-grep functionality now provided via MCP server (@ast-grep/ast-grep-mcp)
- Clear PIP_ONLY_PACKAGES set (no pip-only packages currently needed)
- Regenerate requirements-dev.lock and solarwindpy.yml

The MCP server provides Claude-native ast-grep access, eliminating the
need for Python bindings. Install MCP server with:
  claude mcp add ast-grep -- npx -y @ast-grep/ast-grep-mcp

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@claude
Copy link

claude bot commented Jan 9, 2026

Claude finished @blalterman's task —— View job


Code Review: Development Copilot Implementation

Review Checklist

  • Analyze slash command implementations
  • Review ast-grep pattern rules
  • Examine contract tests quality and coverage
  • Check hook integration tests
  • Review dependency updates and security fixes
  • Assess overall architecture and best practices
  • Provide final recommendations

Final Assessment ✅

This is a high-quality implementation that significantly enhances the SolarWindPy development workflow. The PR demonstrates excellent software engineering practices across multiple dimensions.

Strengths

1. Comprehensive Development Workflow

  • Guided implementation: Slash commands provide step-by-step workflows for common development tasks
  • Physics-aware validation: Commands understand domain-specific requirements (SI units, thermal speed convention, MultiIndex structure)
  • Hook integration: Seamless connection to automated testing and validation pipelines
  • Self-documenting: Contract tests serve as executable documentation (82 tests total)

2. Excellent Code Quality

  • Advisory tooling: ast-grep patterns provide helpful guidance without blocking workflows
  • Domain-specific patterns: Rules understand SolarWindPy's MultiIndex M/C/S structure and physics class hierarchy
  • Clear remediation: Each pattern violation includes concrete fix examples
  • Comprehensive testing: 3 test suites covering DataFrame patterns, class contracts, and hook integration

3. Security and Dependency Management

  • Timely security fix: urllib3 updated to 2.6.3 addressing CVE-2026-21441 (decompression bomb vulnerability)
  • Proper dependency segregation: Development tools properly separated in pyproject.toml
  • Conda/pip coordination: Smart handling of pip-only packages mentioned in conda environment comments

4. Robust Test Coverage

  • DataFrame contracts (23 tests): Validate MultiIndex structure, access patterns, domain conventions
  • Class contracts (35 tests): Verify constructor patterns, property types, inheritance hierarchy
  • Hook integration (24 tests): Test automation pipeline, error handling, lifecycle management

Areas for Enhancement

Minor Issues

  1. Missing pip subsection: solarwindpy.yml comments mention pip-only packages in a pip: subsection, but the actual subsection isn't present in the file
  2. Potential dependency duplication: Some packages appear in both conda and pip dependency lists
  3. ast-grep dependency: The tool is referenced in code but may not be universally available

Recommendations

  1. Add pip subsection to solarwindpy.yml as mentioned in comments, or update comments to reflect current structure
  2. Verify ast-grep availability in CI pipeline or provide fallback patterns
  3. Consider timing estimates for slash commands to set user expectations

Performance Considerations

  • Memory efficiency: DataFrame patterns correctly favor .xs() views over .copy() operations
  • Test isolation: Hook integration tests use proper mocking to avoid expensive git operations
  • Lazy evaluation: Contract tests validate behavior without triggering expensive computations

Security Assessment

  • No security concerns identified
  • Proper CVE remediation: urllib3 vulnerability addressed promptly
  • Safe patterns: ast-grep rules are advisory-only and don't execute code

Overall Recommendation: APPROVE

This PR represents a significant step forward in development tooling for SolarWindPy. The implementation is well-architected, thoroughly tested, and addresses real workflow needs. The minor issues noted above are non-blocking and can be addressed in follow-up work.

The Development Copilot pattern established here could serve as a model for other scientific Python projects requiring domain-specific development guidance.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 9, 2026

SolarWindPy Documentation Validation - Python 3.11

Status: PASSED

Essential Metrics:

  • Files: 40
  • Tests: 14
  • Failed: 0
  • Success Rate: 100.0%
  • Approach: Targeted validation (core physics modules)

🎉 All essential documentation examples working!

@blalterman blalterman merged commit bf7b9c1 into master Jan 9, 2026
34 of 35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants