Skip to content

fix: prevent agent from overwriting notepad files in .sisyphus/notepads/#3688

Open
javimarttinn wants to merge 3 commits into
code-yeongyu:devfrom
javimarttinn:dev
Open

fix: prevent agent from overwriting notepad files in .sisyphus/notepads/#3688
javimarttinn wants to merge 3 commits into
code-yeongyu:devfrom
javimarttinn:dev

Conversation

@javimarttinn
Copy link
Copy Markdown

@javimarttinn javimarttinn commented Apr 27, 2026

Summary

  • Blocks the Write tool on .sisyphus/notepads/*.md paths to prevent irreversible overwrites of append-only decision logs.
  • Strengthens the Edit error recovery reminder with explicit CRITICAL RULES for notepad files.

Changes

  • src/hooks/write-existing-file-guard/tool-execute-before-handler.ts
    • Added isNotepadPath check that throws a descriptive error before the existing isSisyphusPath guard allows the write.
    • Prevents agents from falling back to Write when Edit fails on notepad files.
  • src/hooks/edit-error-recovery/hook.ts
    • Added a CRITICAL RULES for notepad files block to the recovery reminder.
    • Explicitly instructs the agent to use Edit with append mode and to ask the user before any destructive action on .sisyphus/notepads/.

Testing

Verified that attempting to Write a file under .sisyphus/notepads/ now raises:
Error: Notepad files (.sisyphus/notepads/*) are APPEND-ONLY. Use the Edit tool with append mode instead of Write.

Related Issues

Closes #2149


View in Codesmith
Need help on this PR? Tag @codesmith with what you need.

  • Let Codesmith autofix CI failures and bot reviews

Summary by cubic

Prevents overwriting append‑only notepad files under .sisyphus/notepads/ by blocking the Write tool and updating Edit recovery rules. Closes #2149 by enforcing append-only behavior for decision logs.

  • Bug Fixes
    • Block Write for .sisyphus/notepads/* and throw a clear error: “Notepad files are APPEND‑ONLY. Use Edit to append. Never use Write.”
    • Add CRITICAL RULES to Edit error recovery: never use Write on notepads, always append with Edit, and if Edit fails again, stop and ask the user.

Written for commit f2bb07a. Summary will update on new commits. Review in cubic

Added critical rules for handling NOTEPAD files and editing actions.
Add check to block overwriting notepad files in the write guard.
fix: block Write tool on notepad files to prevent data loss
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

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

1 issue found across 2 files

Confidence score: 2/5

  • There is a high-confidence, user-impacting bug in src/hooks/write-existing-file-guard/tool-execute-before-handler.ts: the append-only guard can be bypassed on Windows due to POSIX-only substring matching against normalized paths.
  • I’m scoring this as high risk because the issue affects a protection check directly, and the severity/confidence (7/10, 8/10) suggests a likely regression in real Windows environments.
  • Pay close attention to src/hooks/write-existing-file-guard/tool-execute-before-handler.ts - path handling needs platform-aware matching so the guard cannot be skipped on Windows.
Prompt for AI agents (unresolved issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/hooks/write-existing-file-guard/tool-execute-before-handler.ts">

<violation number="1" location="src/hooks/write-existing-file-guard/tool-execute-before-handler.ts:141">
P1: Notepad append-only guard is bypassable on Windows because path detection uses a POSIX-only substring against platform-normalized paths.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

}

const isSisyphusPath = canonicalPath.includes("/.sisyphus/")
const isNotepadPath = canonicalPath.includes("/.sisyphus/notepads/")
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot Apr 27, 2026

Choose a reason for hiding this comment

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

P1: Notepad append-only guard is bypassable on Windows because path detection uses a POSIX-only substring against platform-normalized paths.

Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At src/hooks/write-existing-file-guard/tool-execute-before-handler.ts, line 141:

<comment>Notepad append-only guard is bypassable on Windows because path detection uses a POSIX-only substring against platform-normalized paths.</comment>

<file context>
@@ -138,6 +138,18 @@ export async function handleWriteExistingFileGuardToolExecuteBefore(params: {
   }
 
   const isSisyphusPath = canonicalPath.includes("/.sisyphus/")
+  const isNotepadPath = canonicalPath.includes("/.sisyphus/notepads/")
+  if (isNotepadPath) {
+    log("[write-existing-file-guard] Blocking notepad overwrite", {
</file context>
Suggested change
const isNotepadPath = canonicalPath.includes("/.sisyphus/notepads/")
const isNotepadPath = canonicalPath.replace(/\\/g, "/").includes("/.sisyphus/notepads/")
Fix with Cubic

VoidChecksum added a commit to VoidChecksum/oh-my-openagent that referenced this pull request Apr 30, 2026
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