Skip to content

fix(edit): make the test-weakening guard opt-in - #42

Merged
wongk merged 1 commit into
mainfrom
fix/test-contract-guard-opt-in
Oct 22, 2026
Merged

wongk merged 1 commit into
mainfrom
fix/test-contract-guard-opt-in

Conversation

@wongk

@wongk wongk commented Oct 22, 2026

Copy link
Copy Markdown

Summary

The edit tool's test-weakening guard rolled back any test-only edit that net-removed assertion lines or added skip/xfail markers. In practice it mostly blocked legitimate work: pruning obsolete tests (/prune-tests), moving tests between files (each file is judged alone), consolidating several asserts into one, and edits to comments or helpers that merely contain the word assert (\bassert also matches assert_called_once_with, assertEqual, ...).

This flips _test_contract_guard_enabled() from default-on (opt-out) to default-off (opt-in):

  • Before: on unless LEMONCROW_TEST_CONTRACT_GUARD is 0/false/no/off.
  • After: off unless LEMONCROW_TEST_CONTRACT_GUARD is 1/true/yes/on.

The detector itself is unchanged, so turning it back on is just the env var.

Tests

  • The existing guard tests (test_smart_edit_* in tests/gateway/test_mcp_tool_handlers.py, test_owned_edit_blocks_test_weakening in tests/gateway/cli/test_runtime.py) now set LEMONCROW_TEST_CONTRACT_GUARD=1 so they still exercise the detector.
  • New test_smart_edit_test_contract_guard_off_by_default: with the env var unset, a test-only assertion removal applies and is not rolled back.
  • uv run pytest -q tests/gateway/test_mcp_tool_handlers.py tests/gateway/cli/test_runtime.py -k "smart_edit or owned_edit" -> 18 passed.
  • Verified live after make dev: a test-only assertion removal through the MCP edit tool now applies.

…ACT_GUARD=1)

Co-Authored-By: lemoncrow <302591943+lemoncrow-agent[bot]@users.noreply.github.com>
LemonCrow-Session: 92cb5b4c-3e6f-4a9d-943c-7ce1c04bdb28
LemonCrow-Model: claude-opus-5-5
@wongk
wongk merged commit 8c3c991 into main Oct 22, 2026
8 of 9 checks passed
@wongk
wongk deleted the fix/test-contract-guard-opt-in branch October 22, 2026 14:58
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.

1 participant