fix(badge): recognize path- and interpreter-prefixed okfmem sync as a save - #47
Merged
Merged
Conversation
… a save The save-state badge sat amber over sessions that had saved and pushed — including the save that shipped the badge fix itself. SAVE_BASH_RE only matched the bare `okfmem sync`, but `okfmem` is an extensionless Python script, so the real close-out is `python3 ~/okfmem/okfmem sync` (and on Windows the .ps1/.cmd wrappers). Neither an interpreter wrapper nor a path prefix was stripped or allowed, so every non-bare shape read as no-save. The direction is a false `unsaved`, but a systematic one: it fired on every real save, not on a rare prose coincidence, and an amber badge after a successful save is indistinguishable from one that means you forgot. - SAVE_BASH_RE: allow a path prefix and the Windows wrapper extensions - LEAD_RE: also strip a leading interpreter and its flags (python3/py/pwsh/ powershell/bash/sh/zsh, optionally path-qualified or .exe-suffixed) Command position is still required — the prefix is stripped, the anchor is not moved — so `grep -o 'okfmem sync' f` and the words as plain arguments (`py build.py --then okfmem sync`) still do not count. `bash -c "..."` remains the documented accepted miss. Closes #46
This was referenced Jul 24, 2026
Save-state badge stuck 'unsaved': SAVE_BASH_RE misses path- and interpreter-prefixed
okfmem sync
#46
Closed
6 tasks
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.
Summary
The save-state badge sat amber (
okfmem*, "unsaved") over sessions that had saved and pushed — including the save that shipped the badge fix (#45) itself.SAVE_BASH_REmatched only the bareokfmem sync, butokfmemis an extensionless Python script, so the real close-out ispython3 ~/okfmem/okfmem sync(and on Windows the.ps1/.cmdwrappers from #39).runs_command()anchors at a segment start afterLEAD_REstrips env assignments andsudo/command/nohup— neither an interpreter wrapper nor a path prefix was stripped or allowed, so every non-bare shape of the save was invisible.The direction is a false
unsaved, benign per #44's framing, but systematic rather than incidental: it fired on every real save. An amber badge after a successful save is indistinguishable from one that means you forgot, which is exactly the signal the badge exists to carry.Closes #46
Refs #44
What changed
SAVE_BASH_REallows a path prefix and the Windows wrapper extensions:(?:\S*[/\\])?okfmem(?:\.(?:ps1|cmd))?\s+sync\b.LEAD_REadditionally strips a leading interpreter and its flags (python3/py/pwsh/powershell/bash/sh/zsh, optionally path-qualified or.exe-suffixed), sopython3 ~/okfmem/okfmem syncresolves to~/okfmem/okfmem sync.Command position is still required — the prefix is stripped, the anchor is not moved. Stripping an interpreter cannot manufacture a save, because what follows it must still be the program. Quoted spans are blanked before segmenting as before, so
bash -c "okfmem sync"remains the documented accepted miss from #44.An aggravating factor worth recording, not fixed here:
/okfmem-saveWrites its memory pages,MEMORY.mdandSTATE.mdafter itsSkill{skill: okfmem-save}record, so the skill-invocation save signal is always older than the skill's own work. The terminalokfmem syncis the only signal that can legitimately flip the badge green — and it was the one being missed. The tie-to-unsavedpolicy stays as designed.Measured
Session
8c03bb18(the one that shipped #45), by transcript line index:Skill{skill: okfmem-save}Writememory page,Edit MEMORY.md,Write STATE.md,Writenotepython3 ~/okfmem/okfmem sync -m "…"work_pos=877 > save_pos=742→unsaved. After:saved.Test plan
python3 scripts/check-leaks.pyexits 0 — Leak gate OK — scanned 62 tracked files, no leaks.python3 -m pytest tests/ -q— 199 passed, 1 skipped (2 new cases intests/test_save_state_badge.py, one per direction)okfmem sync,~/okfmem/okfmem sync,/abs/path/okfmem sync,./okfmem sync,python3 ~/okfmem/okfmem sync -m "msg",okfmem.cmd sync,pwsh -File ./okfmem.ps1 sync,cd /r && python3 ~/okfmem/okfmem syncpy build.py --then okfmem sync,grep -o 'okfmem sync' f,echo "run okfmem sync"still classifyunsavedgit commitvariants from Save-state badge false 'saved': compute_save_state regexes raw transcript text, not structure #44 unregressed (git -C /repo commit --amend,cd /r && FOO=1 git commit,sudo git commit);grep -o 'git commit' log.txtstill not worksaved, 1unsaved, 1None), no blanket flip to greenruff check .— not run,ruffis not installed on this machine; CI covers it (advisory)Provenance
Code implementation via: Claude Opus 4.8 (1M context), high effort
Verification: CI
verify— pending