Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions helpdesk-bot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ vary run to run; that's exactly why we use `trial(n=20)`.
## 🛠️ Step 2: Apply the fix

```bash
git apply mitigation.patch
git apply mitigation.patch --directory=helpdesk-bot
Comment thread
behnam-o marked this conversation as resolved.
```

The patch makes two changes to
Expand Down Expand Up @@ -270,7 +270,7 @@ To revert and play with the diff:
```bash
git checkout -- helpdesk_bot/agent.py
# or, equivalently:
git apply -R mitigation.patch
git apply -R mitigation.patch --directory=helpdesk-bot
```

JSON reports for every run are written to `.report/` for offline
Expand Down
4 changes: 2 additions & 2 deletions helpdesk-bot/mitigation.patch
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@ The patch deliberately does NOT change `approval_mode`. Flipping it to
*invocation*), not poisoned tool *arguments*. See the demo README's
"What the patch deliberately does not change" section.

Apply with `git apply mitigation.patch` from inside helpdesk-bot/.
Revert with `git apply -R` or `git checkout -- helpdesk_bot/agent.py`.
Apply with `git apply mitigation.patch --directory=helpdesk-bot` from inside helpdesk-bot/.
Revert with `git apply -R mitigation.patch --directory=helpdesk-bot` or `git checkout -- helpdesk_bot/agent.py`.
---
diff --git a/helpdesk_bot/agent.py b/helpdesk_bot/agent.py
index 21f1b4e..ae6d45e 100644
Expand Down
10 changes: 5 additions & 5 deletions tests/helpdesk/test_patch.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_applies_and_reverses_cleanly(self, tmp_path: Path) -> None:
pytest.skip("git not on PATH")

work = tmp_path / "demo"
pkg_dir = work / "helpdesk_bot"
pkg_dir = work / "helpdesk-bot" / "helpdesk_bot"
pkg_dir.mkdir(parents=True)
shutil.copy(
HELPDESK_BOT_DIR / "helpdesk_bot" / "agent.py",
Expand All @@ -56,17 +56,17 @@ def git(*args: str) -> subprocess.CompletedProcess[str]:
git("init", "-q", "--initial-branch=main")
git("config", "user.email", "smoke@local")
git("config", "user.name", "smoke")
git("add", "helpdesk_bot/agent.py")
git("add", "helpdesk-bot/helpdesk_bot/agent.py")
git("commit", "-qm", "baseline")

# Apply. Must succeed, must produce valid Python.
git("apply", "mitigation.patch")
git("apply", "mitigation.patch", "--directory=helpdesk-bot")
ast.parse((pkg_dir / "agent.py").read_text(encoding="utf-8"))

# Reverse. After reverse the file must be byte-identical to the
# original baseline (so `git checkout -- helpdesk_bot/agent.py`
# original baseline (so `git checkout -- helpdesk-bot/helpdesk_bot/agent.py`
# in the README is equivalent to `git apply -R`).
git("apply", "-R", "mitigation.patch")
git("apply", "-R", "mitigation.patch", "--directory=helpdesk-bot")
original_bytes = (HELPDESK_BOT_DIR / "helpdesk_bot" / "agent.py").read_bytes()
post_reverse_bytes = (pkg_dir / "agent.py").read_bytes()
assert post_reverse_bytes == original_bytes
Expand Down