Skip to content

fix: production hardening — 20 code quality fixes#3

Merged
humancto merged 2 commits into
mainfrom
claude/review-repo-status-SsRxK
Mar 29, 2026
Merged

fix: production hardening — 20 code quality fixes#3
humancto merged 2 commits into
mainfrom
claude/review-repo-status-SsRxK

Conversation

@humancto
Copy link
Copy Markdown
Owner

Summary

Comprehensive production hardening based on a brutal code review. Fixes 20 identified issues across Rust, Python, and project infrastructure — zero clippy warnings, all 102 tests pass (70 Rust + 32 Python).

Infrastructure (Critical)

  • Add CI/CD: GitHub Actions workflow running Rust tests + clippy + Python tests on every push/PR
  • Add requirements.txt: Pinned Python dependency versions for reproducible builds
  • Fix Makefile: Consistently use python3.11 (was bare python in 3 targets)
  • Fix Cargo.toml: Remove invalid target-cpu = "native" profile key (not a Cargo setting)
  • Fix .gitignore: Exclude generated docs/candidates.json and docs/validation_results.json

Rust (Zero Clippy Warnings)

  • Fix all clippy warnings: &PathBuf&Path, map_oris_some_and, manual range contains, is_multiple_of
  • Introduce SearchConfig and CandidateParams structs to eliminate too-many-arguments warnings
  • Fix double .unwrap() anti-pattern in crossmatch.rs lookup
  • Consolidate chained .replace() calls in normalize_name
  • Add --version flag to CLI
  • Add doc-tests for median, compute_phases, generate_periods

Python (All 32 Tests Pass)

  • Replace blanket warnings.filterwarnings("ignore") with specific filters in all 4 modules
  • Add type hints (from __future__ import annotations) to all Python modules
  • Replace 6 bare except Exception blocks with specific exceptions + warning logs
  • Add named constants for 15+ magic numbers in validate_candidates.py
  • Add CSV column validation (checks for time/flux columns before processing)
  • Fix path traversal risk: use Path.stem / os.path.basename for filenames
  • Remove global mutable findings = {} in deep_analysis.py (now passed as parameter)
  • Sanitize ADQL query inputs in deep_analysis.py Gaia queries
  • Add input file existence check in analyze_candidates.py

Test plan

  • cargo clippy — zero warnings
  • cargo test — 67 unit tests + 3 doc-tests pass
  • python3.11 -m pytest tests/ -v — 32 tests pass
  • CI workflow validates on GitHub Actions
  • Verify make test runs end-to-end on clean checkout

https://claude.ai/code/session_01EWyvEJ6ABSWZxKMrTPBdW8

Infrastructure:
- Add GitHub Actions CI workflow (Rust tests + clippy + Python tests)
- Add requirements.txt with pinned dependency versions
- Fix Makefile to consistently use python3.11 (was bare python)
- Fix Cargo.toml invalid target-cpu profile key (not a valid Cargo setting)
- Add .gitignore entries for generated docs artifacts

Rust (zero clippy warnings, 70 tests):
- Fix all clippy warnings: &PathBuf→&Path, map_or→is_some_and, manual range contains, is_multiple_of
- Introduce SearchConfig and CandidateParams structs to eliminate too-many-arguments
- Fix double unwrap anti-pattern in crossmatch.rs lookup
- Consolidate chained .replace() calls in normalize_name
- Add --version flag to CLI via clap
- Add doc-tests for median, compute_phases, generate_periods

Python (32 tests pass):
- Replace blanket warnings.filterwarnings("ignore") with specific filters
- Add type hints (from __future__ import annotations) to all 4 Python modules
- Replace 6 bare except Exception blocks with specific exceptions + logging
- Add named constants for magic numbers in validate_candidates.py
- Add CSV column validation (checks for time/flux columns)
- Fix path traversal risk: use Path.stem / os.path.basename for filenames
- Remove global mutable state in deep_analysis.py (findings dict now passed as param)
- Sanitize ADQL query inputs in deep_analysis.py Gaia queries
- Add input file existence check in analyze_candidates.py

https://claude.ai/code/session_01EWyvEJ6ABSWZxKMrTPBdW8
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 8208079ec5

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Makefile Outdated
setup:
@echo "📦 Installing dependencies..."
pip install lightkurve astroquery pandas numpy matplotlib tqdm --quiet
pip install -r requirements.txt --quiet
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Install requirements with python3.11 interpreter

The setup target now installs dependencies with bare pip while the rest of the Makefile runs scripts with python3.11; this can install packages into a different interpreter environment and cause ModuleNotFoundError when make download/make analyze run under Python 3.11. Using python3.11 -m pip here keeps dependency installation aligned with the runtime commands.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9d4df19pip installpython3.11 -m pip install in the setup target.


Generated by Claude Code

Comment thread python/download_lightcurves.py Outdated

except Exception:
except (OSError, ConnectionError, ValueError, RuntimeError) as e:
print(f" Warning: skipping TIC {int(row.get('TIC ID', 0))}: {e}")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Avoid re-parsing invalid TIC ID in exception path

This handler catches ValueError, but the warning message calls int(row.get('TIC ID', 0)) again; if the original error came from a malformed or missing TIC ID, the same conversion raises a second ValueError inside the except block and terminates the download loop instead of skipping that row. Log the raw value (or guard conversion) in the handler.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 9d4df19 — now uses row.get('TIC ID', 'unknown') directly instead of re-calling int() in the except handler.


Generated by Claude Code

- Makefile: use python3.11 -m pip for setup target to match runtime interpreter
- download_lightcurves.py: avoid re-parsing TIC ID in except handler to prevent
  secondary ValueError from crashing the download loop

https://claude.ai/code/session_01EWyvEJ6ABSWZxKMrTPBdW8
@humancto humancto merged commit 59cc9f6 into main Mar 29, 2026
3 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