Repository navigation
fix(state): one store per project; hooks never create one; bounded touch trail - #42
Merged
Merged
Conversation
…uch trail baseDir() honored CLAUDE_PLUGIN_DATA. Claude Code sets it for hooks and the MCP server but never for the model's own shell, so hook writes went to a shadow store that the CLI never read. The stop-check nag read the shadow too, so /ratchet:compile could never clear it. The base is now RATCHET_DATA_DIR, else ~/.ratchet, for every caller. Hooks now act only on a store that already exists. session-start and stop-check used to create a store in every directory a session opened in: one machine had 992 empty stores. touchedFiles keeps only the newest touch of each path, newest last, up to TOUCHED_FILES_MAX (500). The cap covers the hook, ratchet touch and state append. One store had reached 22,761 rows (4.4 MB), and every edit rewrote all of it. On a copy of that store, the first touch shrinks it to 96 KB. Three new tests in test/cli.test.js went red on the unpatched tree. npm test passes all 16 suites on an export of this commit's index. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Megaprompting
pushed a commit
that referenced
this pull request
Oct 27, 2026
CHANGELOG [Unreleased] -> Fixed conflict only: keep both entries (discover probe first, #42 store split second); no other text changed. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was wrong
One project was getting two stores.
baseDir()honored$CLAUDE_PLUGIN_DATA. Claude Code sets that variable for hooks and the MCP server, but never for the model's own shell. As a result:stop-checknag also read the shadow store, so/ratchet:compilecould never clear it.Two more problems came from the same hooks.
touchedFileshad no bound. It only ever grew, and every edit rewrote the whole list.Readback from one live install, 2026-10-27:
touchedFilesWhat this changes
$RATCHET_DATA_DIR, else~/.ratchet, and$CLAUDE_PLUGIN_DATAis ignored (src/state.js). Stores already under it are no longer read, and nothing moves or deletes them.session-start,post-editandstop-checkact only on a store that already exists, so a project gets a store only where someone ran ratchet (src/cli.js).verbs.recordTouchkeeps only the newest touch of each path, newest last, up toTOUCHED_FILES_MAX(500) (src/verbs.js).ratchet touchandstate append touchedFiles.SECURITY.mdand a CHANGELOG entry under Unreleased → Fixed.Proof
test/cli.test.jsadds three, and each went red on the unpatched tree:touchedFilesstays bounded and keeps one row per path.npm testpasses all 16 suites on this branch's tree, with exit 0.Trade-offs
$CLAUDE_PLUGIN_DATAmust setRATCHET_DATA_DIRto that path to read them.🤖 Generated with Claude Code