Skip to content
2 changes: 1 addition & 1 deletion autofix_report_enriched.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"changed": true, "classification": {"total": 0, "new": 0, "allowed": 0}, "timestamp": "2025-12-27T15:30:30Z", "files": [".github/scripts/decode_raw_input.py", ".github/scripts/parse_chatgpt_topics.py"]}
{"changed": true, "classification": {"total": 0, "new": 0, "allowed": 0}, "timestamp": "2025-12-29T06:50:54Z", "files": ["tests/test_autofix_validation.py"]}
164 changes: 49 additions & 115 deletions tests/test_autofix_validation.py
Original file line number Diff line number Diff line change
@@ -1,136 +1,70 @@
"""Test coverage for adapter utilities and error handling paths."""
"""Test file with intentional errors to validate the full autofix pipeline.

import os
This file contains:
1. Formatting issues (ruff/black can fix) - cosmetic
2. Type errors (mypy will catch) - non-cosmetic, needs Codex
3. Test failures (pytest will catch) - non-cosmetic, needs Codex

import pytest
The autofix system should:
1. First run basic autofix (ruff/black) to fix formatting
2. Gate should still fail due to mypy/pytest errors
3. Auto-escalate to Codex to fix the remaining issues
"""

from adapters.base import connect_db, get_adapter
# Formatting issue 1: missing spaces around operators

Copilot AI Dec 29, 2025

Copy link

Choose a reason for hiding this comment

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

The Optional type is imported but never used in the file. This appears to be an unintentional unused import that was not mentioned in the PR description's list of intentional errors.

Copilot uses AI. Check for mistakes.
x = 1 + 2 + 3

Copilot AI Dec 29, 2025

Copy link

Choose a reason for hiding this comment

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

The imports os and sys appear to be unintentionally unused. These were not mentioned in the PR description's list of intentional errors. If these are meant to test unused import detection, they should be documented in the module docstring or the comment on line 45 should be updated to reflect all unused imports being tested.

Copilot uses AI. Check for mistakes.

# Formatting issue 2: multiple imports on one line (already above)

def formatted_type_annotation(x: int) -> str:
"""Return a string for basic type coverage."""
return str(x)
# Formatting issue 3: trailing whitespace (invisible but present)
y = 42

# Formatting issue 4: inconsistent quotes
message = "hello"
other_message = "world"

def missing_return_type(value: int) -> int:
"""Return a stable numeric output."""
return value * 2

# Type error 1: wrong type assignment
def get_count() -> int:
return "not an int" # mypy error: returning str instead of int

def poorly_formatted_function(arg1: int, arg2: int, arg3: int) -> int:
"""Simple helper to keep formatting coverage."""
result = arg1 + arg2 + arg3
if result > 10:
return result
return result * 2

# Type error 2: incompatible types
def process_items(items: list[str]) -> dict[str, int]:
result: dict[str, int] = {}
for item in items:
result[item] = "count" # mypy error: assigning str to int
return result

class BadlyFormattedClass:
"""Class with formatting issues."""

def __init__(self, name: str, value: int):
self.name = name
self.value = value
# Type error 3: missing return
def calculate_total(values: list[int]) -> int:
total = sum(values)

Check failure on line 42 in tests/test_autofix_validation.py

View workflow job for this annotation

GitHub Actions / Python CI / lint-ruff

Ruff (F841)

tests/test_autofix_validation.py:42:5: F841 Local variable `total` is assigned to but never used

Check failure on line 42 in tests/test_autofix_validation.py

View workflow job for this annotation

GitHub Actions / Python CI / lint-ruff

Ruff (F841)

tests/test_autofix_validation.py:42:5: F841 Local variable `total` is assigned to but never used

Check failure on line 42 in tests/test_autofix_validation.py

View workflow job for this annotation

GitHub Actions / Python CI / lint-ruff

Ruff (F841)

tests/test_autofix_validation.py:42:5: F841 Local variable `total` is assigned to but never used

Check failure on line 42 in tests/test_autofix_validation.py

View workflow job for this annotation

GitHub Actions / Python CI / lint-ruff

Ruff (F841)

tests/test_autofix_validation.py:42:5: F841 Local variable `total` is assigned to but never used
# Missing return statement - mypy should catch this

Copilot AI Dec 29, 2025

Copy link

Choose a reason for hiding this comment

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

Critical discrepancy: The PR description states that mypy errors should cause the Gate to fail and trigger Codex escalation. However, the Gate workflow (.github/workflows/pr-00-gate.yml line 47) has typecheck: false, meaning mypy is not run as part of the Gate check. While mypy runs in the separate CI workflow, it doesn't block PR merging through the Gate. This means the intentional type errors in this test file (lines 30-43) will not cause Gate failure and won't test the auto-escalation behavior as intended. Either the Gate workflow needs to enable typechecking, or the PR description needs to be updated to reflect what's actually being tested.

Copilot uses AI. Check for mistakes.

Copilot AI Dec 29, 2025

Copy link

Choose a reason for hiding this comment

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

Variable total is not used.

Suggested change
# Missing return statement - mypy should catch this
return total

Copilot uses AI. Check for mistakes.

def compute(self, multiplier: int) -> int:
return self.value * multiplier

# Unused import (ruff will catch this)

Copilot AI Dec 29, 2025

Copy link

Choose a reason for hiding this comment

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

Import of 'json' is not used.

Copilot uses AI. Check for mistakes.

# --- ACTUAL USEFUL COVERAGE TESTS ---


def test_connect_db_sqlite_default():
"""Test connect_db returns valid SQLite connection."""
# Clear env vars to force SQLite path
old_url = os.environ.pop("DB_URL", None)
old_path = os.environ.pop("DB_PATH", None)

try:
conn = connect_db(":memory:")
assert conn is not None
# Verify it's a working connection
cursor = conn.cursor()
cursor.execute("SELECT 1")
result = cursor.fetchone()
assert result == (1,)
conn.close()
finally:
if old_url:
os.environ["DB_URL"] = old_url
if old_path:
os.environ["DB_PATH"] = old_path


def test_connect_db_with_timeout():
"""Test connect_db accepts timeout parameter."""
conn = connect_db(":memory:", connect_timeout=5.0)
assert conn is not None
conn.close()


def test_get_adapter_edgar():
"""Test that edgar adapter can be loaded."""
try:
adapter = get_adapter("edgar")
assert adapter is not None
# Ensure the adapter exposes the expected coroutine entry point.
assert callable(getattr(adapter, "list_new_filings", None))
except ModuleNotFoundError:
# Adapter module may not exist yet
pass


def test_get_adapter_invalid():
"""Test get_adapter raises for unknown adapter."""
# Validate the import error path for unknown adapters.
with pytest.raises((ModuleNotFoundError, ImportError)):
get_adapter("nonexistent_adapter_xyz")


def test_intentional_failure_assertion():
"""Exercise assertion error paths without failing the suite."""
# Test that will fail
def test_intentional_failure():
"""This test intentionally fails to trigger Codex escalation."""
expected = 42
actual = 41
# Confirm mismatched values raise AssertionError.
with pytest.raises(AssertionError):
assert actual == expected, f"Expected {expected} but got {actual}"


def test_intentional_failure_exception():
"""Exercise KeyError handling without failing the suite."""
data = {"key": "value"}
# Accessing a missing key should raise KeyError.
with pytest.raises(KeyError):
_ = data["nonexistent_key"]


def test_intentional_failure_type_error():
"""Exercise TypeError handling without failing the suite."""
value = "not a number"
# Mixing string and int should raise TypeError.
with pytest.raises(TypeError):
_ = value + 5


def function_with_trailing_whitespace():
"""Has trailing whitespace."""
x = 1
y = 2
return x + y


def bad_none_comparison(value):
# Use explicit None checks to avoid truthiness surprises.
if value is None:
return "empty"
return "full"
actual = 41 # Wrong value
assert actual == expected, f"Expected {expected}, got {actual}"
Comment on lines +36 to +39

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 Fix hardcoded failing assertion in test_intentional_failure

test_intentional_failure sets expected = 42 but actual = 41, making the assertion fail unconditionally whenever the test suite runs, independent of any underlying functionality; align the expected and actual values so the test can pass when behavior is correct.

Useful? React with 👍 / 👎.



def bad_bool_comparison(flag):
# Prefer direct boolean checks for readability.
if flag:
return "yes"
return "no"
# Another failing test
def test_type_mismatch():
"""Test type handling with intentional failure."""
result = get_count()
assert isinstance(result, int), f"Expected int, got {type(result)}"


# Autofix retest - 2025-12-29T05:30:11Z
# Test with assertion error
def test_list_processing():
"""Test list processing with intentional failure."""
items = ["a", "b", "c"]
result = process_items(items)
# This will fail because process_items has a bug
assert all(isinstance(v, int) for v in result.values())
Loading