Skip to content

fix(badge): recognize path- and interpreter-prefixed okfmem sync as a save - #47

Merged
s-annam merged 1 commit into
mainfrom
fix/save-badge-invocation-shapes-issue-46
Jul 24, 2026
Merged

fix(badge): recognize path- and interpreter-prefixed okfmem sync as a save#47
s-annam merged 1 commit into
mainfrom
fix/save-badge-invocation-shapes-issue-46

Conversation

@s-annam

@s-annam s-annam commented Jul 24, 2026

Copy link
Copy Markdown
Owner

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_RE matched only 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 from #39). runs_command() anchors at a segment start after LEAD_RE strips env assignments and sudo/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_RE allows a path prefix and the Windows wrapper extensions: (?:\S*[/\\])?okfmem(?:\.(?:ps1|cmd))?\s+sync\b.
  • LEAD_RE additionally strips a leading interpreter and its flags (python3/py/pwsh/powershell/bash/sh/zsh, optionally path-qualified or .exe-suffixed), so python3 ~/okfmem/okfmem sync resolves 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-save Writes its memory pages, MEMORY.md and STATE.md after its Skill{skill: okfmem-save} record, so the skill-invocation save signal is always older than the skill's own work. The terminal okfmem sync is the only signal that can legitimately flip the badge green — and it was the one being missed. The tie-to-unsaved policy stays as designed.

Measured

Session 8c03bb18 (the one that shipped #45), by transcript line index:

line event before after
742 Skill{skill: okfmem-save} save save
788–877 Write memory page, Edit MEMORY.md, Write STATE.md, Write note work work
918 python3 ~/okfmem/okfmem sync -m "…" missed save

work_pos=877 > save_pos=742unsaved. After: saved.

Test plan

  • python3 scripts/check-leaks.py exits 0 — Leak gate OK — scanned 62 tracked files, no leaks.
  • python3 -m pytest tests/ -q199 passed, 1 skipped (2 new cases in tests/test_save_state_badge.py, one per direction)
  • Save shapes all register: 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 sync
  • No false green: py build.py --then okfmem sync, grep -o 'okfmem sync' f, echo "run okfmem sync" still classify unsaved
  • git commit variants 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.txt still not work
  • Replayed 8 real transcripts — sane spread (6 saved, 1 unsaved, 1 None), no blanket flip to green
  • ruff check .not run, ruff is 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

… 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Save-state badge stuck 'unsaved': SAVE_BASH_RE misses path- and interpreter-prefixed okfmem sync

1 participant