Store commit fix: fit the size budget (put paths are committed without being named twice)

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
This commit is contained in:
swaitsandClaude Fable 5.2 committed 2026-11-28 16:09:59 -07:00
1 parent 6477f22933
commit 6292f5c45e
3 files changed
+11 -20

No files matched your search

+3 -8
View File
@@ -180,12 +180,8 @@ def scope_lines(scope, cwd=None, migrate=True):
def _commit(msg, *paths, snap=None, put=None):
"""Commit `paths` to the store. `put` ({path: text}) and the undo snapshot `snap` are written inside the store lock, with the commit."""
if snap:
p = store.data("rules", "last-project.json")
paths, put = (p,) + paths, {**(put or {}), p: json.dumps(dict(zip(("path", "before", "after"), snap)))}
# written inside the store lock, never under a project's or the user's: another process's `git add` read these
# files as they were replaced ("short read while indexing")
# `put` and the undo snapshot are written inside the store lock: another process's `git add` read them mid-replace ("short read")
put = dict(put or {}, **({store.data("rules", "last-project.json"): json.dumps(dict(zip(("path", "before", "after"), snap)))} if snap else {}))
if not store.commit(msg, *paths, put=put):
raise OSError("store git commit failed (%s)" % store.GIT_ERROR)
@@ -397,11 +393,10 @@ def organize_record(answer_file, cwd):
seen = _organized()
seen.update({_mark_key(USER): len(_retro(got[USER])), _mark_key(PROJECT, cwd): len(_retro(got[PROJECT]))})
seen.pop("rules/projects/%s.md" % store.project_key(cwd), None)
marks = store.data("rules", "organized.json")
dp, ts = store.data(DROPS), time.strftime("%Y-%m-%dT%H:%M:%S")
for r, pn, why in recs:
store.append(dp, json.dumps({"ts": ts, "rule": r, "problem": pn, "reason": why}, sort_keys=True))
_commit("rules organized", marks, up, *([dp] if recs else []), snap=(pp, before, after), put={up: utext, marks: json.dumps(seen)})
_commit("rules organized", *([dp] if recs else []), snap=(pp, before, after), put={up: utext, store.data("rules", "organized.json"): json.dumps(seen)})
except OSError as e:
(wrote_u := store.regular(up, True)[1] == utext.encode()) and build_rulebook()
if not wrote and not wrote_u: