Repository navigation
Reliability and correctness fixes from TECHNICAL-REVIEW (P0/P1) - #15
Conversation
Bundles eight items from sections 1-3 of TECHNICAL-REVIEW.md. The
common theme: surface failures loudly instead of silently degrading,
and don't trust the LLM's quoted text for blind string replacement.
fix_applier.py (§1.5, §3.1):
Replace the str.replace()-based fix application with slice-based
substitution at the position found by str.find(). The old code
tracked positions but then ignored them (always replacing the first
occurrence), and its whitespace-tolerant fallback computed an index
into a normalized string but tried to replace against the original,
so it silently failed every time. New code uses the captured
position, verifies the anchor still matches before slicing (defends
against overlapping fixes from sequential rule processing), and
surfaces a clear "current_text not found verbatim" warning when the
LLM paraphrased whitespace. Added two regression tests:
test_descending_position_preserves_earlier_positions (multi-fix with
length-changing replacements) and test_overlapping_fixes_second_skipped.
action.py (§1.6, §3.5):
review_bulk_lectures now actually computes lectures_with_issues and
errors_count (the bulk summary previously printed
"Lectures with issues: 0" unconditionally because the key was never
set). When >25% of lectures error out, the function now raises so
the GitHub Action fails loudly instead of reporting "0 issues found"
for a broken run.
reviewer.py (§2.2, §2.3):
AnthropicProvider configures the SDK client with timeout=300s and
max_retries=3, so a hung connection no longer holds the action
hostage until the 6h job-level timeout. The bare `except Exception`
in the per-rule loop is narrowed to `except anthropic.APIError`;
programmer bugs (AttributeError, KeyError, …) now bubble up so the
action fails loudly — the same failure mode that hid the v0.7.2
temperature=0 regression silently behind "0 issues found".
github_handler.py (§3.2, §3.6, §3.7):
- Deleted the two unreachable `lectures/`-prefixed regex patterns
from extract_lecture_from_comment; the generic `\S+` alternative
already accepted those paths and the body strip handled the
prefix removal.
- create_branch now appends a 6-char random suffix on collision
and retries instead of silently committing onto whatever branch
already existed under that name.
- base_branch is resolved from repo.default_branch at startup so
repos using master/develop/etc. work without hardcoding "main"
everywhere.
There was a problem hiding this comment.
Pull request overview
This PR bundles multiple P0/P1 reliability and correctness fixes across the GitHub Action and core engine to ensure failures are surfaced loudly (instead of silently degrading) and that programmatic fix application is anchored correctly.
Changes:
- Reworked
apply_fixesto apply slice-based substitutions in descending position order with clear warnings when anchors don’t match / overlap. - Improved bulk review reporting and failure behavior (track lectures-with-issues and error counts; abort bulk runs when too many lectures error).
- Hardened GitHub integration (remove dead comment-regex paths; resolve default branch dynamically; avoid branch-name collisions) and Anthropic client configuration (timeout + retry; narrower exception handling).
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
style_checker/fix_applier.py |
Switches from str.replace to position-based slice edits with overlap/anchor checks and clearer “current_text not found” warnings. |
tests/test_fix_applier.py |
Updates warning assertions and adds regression tests for descending-order application and overlap skipping. |
style_checker/action.py |
Computes lectures_with_issues / errors_count and adds a bulk-run abort threshold when too many lectures error. |
style_checker/reviewer.py |
Configures Anthropic client timeouts/retries and narrows exception handling to API-level errors. |
style_checker/github_handler.py |
Uses repo default branch instead of hardcoded main, removes dead comment patterns, and retries branch creation with collision-avoidance suffixes. |
- action.py: capture returned branch name from create_branch at both call sites. Previously the collision-avoidance suffix was silently discarded — on collision the suffixed branch was created but commits and the PR still targeted the (colliding) original name, the exact failure mode the collision handling was meant to prevent. - action.py: replace ad-hoc `max(2, len(lectures) // 4)` threshold with `max(2, math.ceil(len(lectures) / 4))` and a comment that accurately documents the small-batch floor behavior. Includes the threshold value in the abort message. - reviewer.py: drop dead `try/except ImportError` in AnthropicProvider — anthropic is now a hard dep imported at module top, so a missing install fails on module import before the class is ever instantiated. - tests/test_fix_applier.py: tighten test_overlapping_fixes_second_skipped to assert the exact deterministic result (descending order applies inner first, outer is skipped) and remove the chatty inline reasoning.
|
Addressed all 4 Copilot review comments in 8327259:
All 93 tests still pass. |
Summary
Eight P0/P1 fixes from sections 1–3 of TECHNICAL-REVIEW.md, bundled into a single squashed commit for easy revert. Common theme: surface failures loudly instead of degrading silently, and don't trust the LLM's quoted text for blind string replacement.
What changed
fix_applier.pyfix_applier.pyaction.pylectures_with_issuesanderrors_count(the bulk summary previously printed"Lectures with issues: 0"unconditionally because the key was never set)action.pyreviewer.pyAnthropic(timeout=300, max_retries=3)— a hung connection no longer holds the action hostage until the 6h job-level timeoutreviewer.pyexcept Exceptiontoexcept anthropic.APIError; programmer bugs (AttributeError, KeyError, …) now bubble up — same failure mode that hid v0.7.2'stemperature=0regression behind "0 issues found"github_handler.pylectures/-prefixed regex patternsgithub_handler.pycreate_branchappends a 6-char random suffix on collision and retries, instead of silently committing onto whatever pre-existing branch shared the namegithub_handler.pybase_branchis resolved fromrepo.default_branchat startup — repos usingmaster/develop/etc. work without the hardcoded'main'fallbackDiff: 5 files, +213 / −108. Two new regression tests added in
tests/test_fix_applier.py:test_descending_position_preserves_earlier_positions— multi-fix with length-changing replacementstest_overlapping_fixes_second_skipped— anchor re-check catches the overlapOut of scope
This PR covers only P0/P1 correctness/security items from sections 1–3. Larger architectural items (§4: delete
prompt_loader.py, consolidateVALID_CATEGORIES, structural guardrails) and packaging/test improvements (§5–§8) are tracked inTECHNICAL-REVIEW.mdfor follow-up.Test plan
uv run pytest tests/ -v --no-cov -m "not integration"→ 93 passedqestyleafter merge (requiresANTHROPIC_API_KEY)test-action-style-guiderepoRevert plan
Single squashed commit —
git revert <merge-sha>if anything regresses in production.🤖 Generated with Claude Code