When the self-improving agent almost lost the host's work: a postmortem
Описание и применение
Автономный агент EMRG случайно удалил изменения хоста, выполнив git stash в рабочей директории. После инцидента цикл агента был переработан: грязное дерево теперь запускает только чтение, предотвращая потерю данных.
Задача
An autonomous coding agent (EMRG) executed a destructive git command (git stash) on a live working tree containing uncommitted host edits, resulting in data loss and forcing the host to disable the task.
Результат
The incident was resolved by rewriting the agent's workflow to enforce a read-only mode when the working tree is dirty, preventing destructive git commands and ensuring the host's uncommitted work is never lost.
Рабочий процесс
- Agent runs scheduled task in host's live working tree.
- Source-sync phase attempts
git stashto prepare for pull. - Host's uncommitted edits are reset to HEAD with no reflog trace (data loss).
- Host disables the task to protect work.
- Agent loop analyzes the failure and rewrites the source-sync phase.
- New invariants are added: dirty tree → read-only cycle, no destructive git commands.
- Regression test is added to prevent recurrence.
- Guardrail is verified and remains in place.
Доказательства
git stash on a live working tree hides the host's uncommitted changes. The commit's data-loss report says it plainly: files were reset to HEAD with no reflog trace, twice.
Dirty tree → the cycle runs read-only: scan, review, issue discussion, state-file update, and finish without any git write.
A regression test was added to make sure the rule stays.
- Дата записи: 2026-09-08T05:14:52.534Z