<feed xmlns='http://www.w3.org/2005/Atom'>
<title>claude-plugins-official.git/plugins/security-guidance/tests/test_state_file.py, branch bump/cloud-sql-sqlserver</title>
<subtitle>Official Claude Code plugin directory
</subtitle>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/'/>
<entry>
<title>security-guidance: keep the session state when a save is cut short</title>
<updated>2026-10-14T16:31:17+00:00</updated>
<author>
<name>Mohamed Hegazy</name>
<email>mhegazy@anthropic.com</email>
</author>
<published>2026-10-14T16:31:17+00:00</published>
<link rel='alternate' type='text/html' href='https://git.1991861.xyz/claude-plugins-official.git/commit/?id=acc1870f4c4e2be8b3a27763cc6ad8a716e57e37'/>
<id>acc1870f4c4e2be8b3a27763cc6ad8a716e57e37</id>
<content type='text'>
The state file was rewritten in place, so a hook killed during a save left a truncated file that the next hook read as an empty state: the turn baseline, the touched paths and the shown warnings were gone. Write a temporary file and rename it over the state file. Windows keeps writing in place for now: hooks have no state lock there, and a rename can be refused or make a concurrent read fail.

A state file that cannot be decoded no longer stops the hook. The Stop metrics gain two keys, sent only when nonzero: state_resets (the state file was unreadable and the state started over) and state_overwrites (without a lock, a save replaced one made by another hook since the read).

Refs #1944
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
The state file was rewritten in place, so a hook killed during a save left a truncated file that the next hook read as an empty state: the turn baseline, the touched paths and the shown warnings were gone. Write a temporary file and rename it over the state file. Windows keeps writing in place for now: hooks have no state lock there, and a rename can be refused or make a concurrent read fail.

A state file that cannot be decoded no longer stops the hook. The Stop metrics gain two keys, sent only when nonzero: state_resets (the state file was unreadable and the state started over) and state_overwrites (without a lock, a save replaced one made by another hook since the read).

Refs #1944
</pre>
</div>
</content>
</entry>
</feed>
