Skip to content

Comments

fix: properly remove instructions when AGENTS.md is deleted#26

Merged
mrbrandao merged 1 commit intoRedHatProductSecurity:mainfrom
SecKatie:fix/instructions-removal-cleanup
Jan 29, 2026
Merged

fix: properly remove instructions when AGENTS.md is deleted#26
mrbrandao merged 1 commit intoRedHatProductSecurity:mainfrom
SecKatie:fix/instructions-removal-cleanup

Conversation

@SecKatie
Copy link
Contributor

Summary

  • Fixes remove_instructions() to completely remove the managed section when there are no more module blocks (instead of leaving empty markers)
  • Fixes _update_instructions() to always attempt removal when a module no longer has instructions, handling stale installation records

Related Issues

Test Plan

  • Added regression test for empty section cleanup (test_remove_last_module_cleans_up_markers)
  • Added regression test for stale installation record removal (test_update_removes_instructions_with_stale_registry)
  • All 508 tests pass

Checklist

  • Tests pass (pytest)
  • Linting passes (ruff check src tests)
  • Type checking passes (ty check)

AI Disclosure

AI-assisted with Claude Code (Claude Opus 4.5)

Two issues fixed:

1. remove_instructions() now completely removes the managed section
   when there are no more module blocks, instead of leaving empty
   <!-- lola:instructions:start/end --> markers behind.

2. _update_instructions() now always attempts removal when a module
   no longer has instructions, regardless of what the installation
   record says. This handles the case where a user reinstalls after
   deleting AGENTS.md (the old installation record wouldn't have
   has_instructions=True so removal was never triggered).

Includes regression tests for both issues.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@mrbrandao mrbrandao merged commit af0e716 into RedHatProductSecurity:main Jan 29, 2026
4 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