Skip to content

fix(platform-integrations): skip copy when src and dst are same file#104

Merged
visahak merged 2 commits into
AgentToolkit:mainfrom
vinodmut:bob-integration
Mar 23, 2026
Merged

fix(platform-integrations): skip copy when src and dst are same file#104
visahak merged 2 commits into
AgentToolkit:mainfrom
vinodmut:bob-integration

Conversation

@vinodmut

@vinodmut vinodmut commented Mar 23, 2026

Copy link
Copy Markdown
Contributor

Add _safe_copy2 helper to avoid errors on hardlink/APFS clone scenarios. Also remove .bob symlink and add it to .gitignore.

For #103

Summary by CodeRabbit

  • Bug Fixes

    • Installation now avoids redundant file copy operations when source and destination are the same, improving install speed and reliability.
  • Chores

    • Removed an obsolete local configuration entry and updated ignore settings to keep repository housekeeping current.

Add _safe_copy2 helper to avoid errors on hardlink/APFS clone
scenarios. Also remove .bob symlink and add it to .gitignore.
@coderabbitai

coderabbitai Bot commented Mar 23, 2026

Copy link
Copy Markdown

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d5cd84ab-411a-45a3-9088-870042e0a2a5

📥 Commits

Reviewing files that changed from the base of the PR and between a60e1a8 and 89b0a7e.

📒 Files selected for processing (1)
  • platform-integrations/install.sh
🚧 Files skipped from review as they are similar to previous changes (1)
  • platform-integrations/install.sh

📝 Walkthrough

Walkthrough

Removed a bob-related file/entry, added .bob to .gitignore, and enhanced the installer script with a _safe_copy2() helper that skips copying when source and destination are the same file.

Changes

Cohort / File(s) Summary
Configuration Cleanup
platform-integrations/bob/kaizen-lite, .bob
Removed bob configuration/file entry from the repo.
Ignore Patterns
.gitignore
Added .bob to ignore patterns and ensured newline at end of file for event.json entry.
Installation Script Enhancement
platform-integrations/install.sh
Added _safe_copy2(src, dst) to detect identical source/destination (and catch shutil.SameFileError), and wired it into copy_tree() via copy_function=_safe_copy2 to avoid redundant copies while preserving idempotent and dry-run behavior.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Poem

🐰 The bob hopped out, a quiet little tweak,
.gitignore learned to hush what it won't seek.
install.sh now skips twins with gentle cheer—
No needless copying, the path grows clear. 🥕✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: adding logic to skip copying when source and destination are the same file, which is the primary purpose of the _safe_copy2 helper function introduced in platform-integrations/install.sh.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
platform-integrations/install.sh (1)

226-227: Add a regression test for same-inode copies with content assertions.

Given this behavior change, please add a platform integration test that creates a samefile scenario (e.g., hardlink) and validates file contents after reinstall, not just path existence.

Based on learnings: Tests for platform-integrations/install.sh must NEVER overwrite or corrupt existing user skills, commands, modes, or configurations - detect existing user content, preserve it completely during installation, and add Kaizen content alongside (not replacing) user content.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@platform-integrations/install.sh` around lines 226 - 227, Add a regression
test that simulates the same-inode copy case (create a hardlink/duplicate inode
for a source file), runs the install flow that triggers shutil.copytree(...,
copy_function=_safe_copy2) and then asserts not only that target paths exist but
that file contents match originals (both for pre-existing user files and newly
added Kaizen files); ensure the test first creates sentinel user content
(skills/commands/modes/configs), verifies the installer preserves those files
verbatim (no truncation or corruption) and only adds new Kaizen files alongside,
and fail the test if any user file content changes or is overwritten.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@platform-integrations/install.sh`:
- Around line 207-213: The _safe_copy2 helper currently checks os.path.samefile
before calling shutil.copy2 but can still race; wrap the shutil.copy2(src, dst)
call in a try/except that catches shutil.SameFileError and treats it the same as
the pre-check (log via debug like "Skipping (same file): {src} → {dst}" and
return) so any TOCTOU where src and dst become the same inode at copy time is
handled safely; keep the existing pre-check and only add the SameFileError
handling around the call to shutil.copy2 in _safe_copy2.

---

Nitpick comments:
In `@platform-integrations/install.sh`:
- Around line 226-227: Add a regression test that simulates the same-inode copy
case (create a hardlink/duplicate inode for a source file), runs the install
flow that triggers shutil.copytree(..., copy_function=_safe_copy2) and then
asserts not only that target paths exist but that file contents match originals
(both for pre-existing user files and newly added Kaizen files); ensure the test
first creates sentinel user content (skills/commands/modes/configs), verifies
the installer preserves those files verbatim (no truncation or corruption) and
only adds new Kaizen files alongside, and fail the test if any user file content
changes or is overwritten.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4d3936d7-5ba4-400d-9a2d-471d0f666d2c

📥 Commits

Reviewing files that changed from the base of the PR and between 6bfdbbb and a60e1a8.

📒 Files selected for processing (3)
  • .bob
  • .gitignore
  • platform-integrations/install.sh
💤 Files with no reviewable changes (1)
  • .bob

Comment thread platform-integrations/install.sh
Addresses CodeRabbit review finding: Handle same-file races at copy time, not only pre-check time

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@vinodmut vinodmut requested a review from illeatmyhat March 23, 2026 19:53
@visahak visahak merged commit d88baf1 into AgentToolkit:main Mar 23, 2026
15 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