Tegoby Attention SpanBlogBook a demo

Twelve unpushed commits gone at session start

Strict rules refuse key steps

In March 2026, a developer reported that Claude Code ran a command that rolls the project back to the last shared version at the start of a session, two days in a row; the second time it wiped 12 commits that existed only on their machine. With strict rules, Tego would refuse the rollback: the agent can only change the folders you name, and git's history folder isn't one of them. We reproduced the incident's steps under these rules to confirm it.

What happened?

The report is Claude Code issue #34327, opened on 14 March 2026. The issue says Claude Code filed it on the user's behalf. Everything here is as reported.

The machine ran Ubuntu 22.04 on Linux 6.8. The repository was a private driver for an FPGA network card (an RDMA driver, for fast direct memory transfers between machines).

On 12 March at 04:01 EDT, as a session started, the agent ran git reset --hard origin/main. That command throws away every local change and makes your copy match the server's main branch. The commits were "partially recovered via reflog 51 seconds later." The reflog is git's short-term memory of where a branch used to point.

The developer told the agent never to do it again. A later session printed output saying it had made a git hook (a script git runs before certain actions) to block the command. "The hook was never actually created."

On 13 March at 04:00 EDT, the same command ran again. This time it took 12 unpushed commits (saved locally but never sent to the server), a bring-up script, interrupt handler code and other files. The uncommitted work is "permanently lost."

The git documentation is plain about --hard: it will "Overwrite all files and directories with the version from ". Here that was origin/main, so work that lived only in local commits was gone from the folder.

An inactivity bot closed the issue as not planned on 11 May 2026.

Why didn't the usual safety catch it?

Every guard on those two days lived inside the agent: an instruction, and a hook that existed only in its own output. A memory file the developer had it save was gone after they logged in again. A rule the agent holds fails when the agent fails, as our post on prompts explains.

Afterwards the developer built guards the agent could not delete: a wrapper around git, Claude Code hooks that check each command before it runs (PreToolUse hooks), and hook files locked against changes with chattr. Their own pre-commit and pre-push hooks test the driver against the live card, which they reboot and reflash often.

How it could have been prevented

The general habit: decide which folders an agent may change, keep the project's history outside that list, and have something the agent can't reach enforce it. You don't need to guess which command will go wrong. Any command that tries to rewrite history is refused, however it is spelled.

Tego enforces such limits from outside the agent, with the Linux kernel; the agent can't edit them or talk its way past them. Tego's strict setup is three built-in rule sets: the agent can't read your secrets, can only reach the hosts you list, and can only change files in the folders you name. That last part does the work here. See the strict setup for the full file.

Git keeps its history in a hidden .git folder, and the strict setup leaves it off the list. git reset --hard must lock git's index (its list of tracked files) and move the branch, both inside .git, so it fails with a permission error before it touches your files. That holds however it is spelled, and whether a shell, a git hook or a script starts it. The refusal goes into the run's tamper-evident record, and Claude Code is told which rule refused it.

In Tego's rules file, that's:

YAML
extends: [tego/no-secrets, tego/no-prod, tego/repo-only-writes]
fs:
  write: ["./src/", "./tests/"]   # the only folders the agent may change

For this project, list the repository's real folders, and allow writes to each device the hooks write to (RDMA user verbs talk through /dev/infiniband/uverbsN). Steps that need root, such as reloading the driver module, belong outside the run, since sudo does not work inside one. It works without root on a recent kernel such as Linux 6.8 (with Landlock, the kernel feature Tego uses, and a delegated cgroup); run tego doctor on the machine to confirm. The interactive Claude Code example shows the other entries Claude Code needs.

The honest limit: the agent can't commit or push either (your SSH and signing keys in ~/.ssh and ~/.gnupg are kept from it), so you do that from your own shell. A script that overwrites files inside ./src/ still goes through, and Tego keeps a record, not a backup.

How Tego handles it

Without the strict setup, Tego's ready rules limit where an agent writes, what it reads and which hosts it reaches. An agent working in a repository has to write that repository, and git reset --hard is a write inside it. So the default rules let it through, as does any setup that lets the agent write .git so it can commit.

What you still get is a record. Every program the agent starts, with its arguments, is written down, so you can check what happened instead of asking the agent. That record would also have caught the claim "I created a hook".

The lesson

An instruction in an agent's prompt or memory is advice, and this agent forgot it overnight. Keep the agent's writes to the folders it works in, with the repository's history outside them, and enforce that where the agent can't reach. And push work somewhere a reset can't touch, because no rule is complete.

Sources (33 links)