Multi-File Refactor Safety Check
说明与用途
CI 依赖检查捕获 AI 代理执行的多文件重构中遗漏的导入,防止无声失败。
问题
AI coding agents often miss updating imports in files outside their context window, causing silent failures that surface only during CI or production.
结果
The CI pipeline now fails early when an AI agent misses an import, ensuring that all renamed symbols are consistently updated across the codebase.
工作流
- 1. Identify the set of files the agent will edit and the mapping of old to new symbols.
- 2. Run the Python dependency‑graph script to build an import map for the project.
- 3. Execute the Bash wrapper, passing the project root, edited‑files CSV, and renames CSV.
- 4. If the script reports stale references, abort the CI and review the missed files.
- 5. Optionally split large refactors into smaller passes and repeat the check after each pass.
证据
This function walks every Python file under root, builds a mapping from each file to the (module, name) pairs it imports, and then checks any file that was not edited for imports of renamed symbols.
Adding this step to your CI ensures that a missed import fails the build before it reaches production.
- 记录日期: 2026-09-16T14:30:35.173Z