Repository navigation
fix(sleep): normalize newlines when comparing live baseline documents - #463
Open
warminer21-glitch wants to merge 2 commits into
Open
warminer21-glitch wants to merge 2 commits into
warminer21-glitch wants to merge 2 commits into
Conversation
_read_live_baseline() decoded the live SKILL.md/CLAUDE.md bytes without normalizing line endings before comparing them against the optimizer's candidate text. On a checkout with core.autocrlf=true (the Windows default), the live file is CRLF while candidate text (model output, scaffolds) is LF, so the "did this document actually change" comparison always evaluated true and documents were staged as changed even when they weren't. Normalize the decoded text to \n right after decoding, while still hashing the original unmodified raw bytes for live-file drift detection elsewhere in staging. Fixes 5 failing subtests in tests/test_sleep_engine.py::TestFullCycleAndAdopt::test_cycle_stages_only_documents_that_changed on Windows. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…_REPO need The runner's Python-interpreter autodetect only tried python3.12, python3.11, python3.10 and python3, never plain `python`. On Windows (and any setup where `python3` is absent or a broken stub, e.g. the Microsoft Store alias), this failed with "need Python >= 3.10 (found none)" even though a perfectly good interpreter was on PATH as `python`. Add it as a last candidate in both run-sleep.sh copies (plugins/run-sleep.sh and plugins/claude-code/scripts/run-sleep.sh); it is still version-checked like every other candidate, so a Python 2 `python` is correctly skipped. Also clarify the README: a `/plugin install` caches the plugin under ~/.claude/plugins/cache/, separate from the cloned repo, so once that cache is in use (or the clone is removed) the runner can no longer find skillopt_sleep/ next to itself or via CLAUDE_PLUGIN_ROOT. Document the two actual remedies (SKILLOPT_SLEEP_REPO, or installing the engine so the PATH/ import fallbacks apply) instead of leaving users to reverse-engineer the runner's fallback chain from its error message. Verified by running the patched plugins/run-sleep.sh directly: it now resolves `python` and completes `status` against this repo. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Contributor
|
warminer21-glitch please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
This branch has not been deployed
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
core.autocrlf=true, the default),_read_live_baselineinskillopt_sleep/cycle.pydecoded the liveSKILL.md/CLAUDE.mdbytes without normalizing line endings before comparing them against the optimizer's candidate text.result.new_skill != skill,result.new_memory != memory) always evaluated true, and the cycle staged documents as changed even when nothing meaningfully changed.\nright after decoding in_read_live_baseline, while still hashing the original unmodified raw bytes (hashlib.sha256(raw)) for live-file drift detection used elsewhere in staging — so integrity checks remain exact-byte while the text comparisons used in consolidation become newline-insensitive.Also in this PR: two issues found testing the Claude Code plugin live
While verifying
skillopt-sleepas an actually-installed Claude Code plugin (not just via the raw Python CLI), found and fixed:python.scripts/run-sleep.sh's candidate list waspython3.12 python3.11 python3.10 python3only. On Windows (and anywherepython3is missing or a broken stub, e.g. the Microsoft Store alias), this fails withneed Python >= 3.10 (found none)even though a good interpreter is onPATHaspython. Addedpythonas a last candidate in both copies of the script (plugins/run-sleep.sh,plugins/claude-code/scripts/run-sleep.sh); it's still version-checked like every other candidate, so a Python 2pythonis correctly skipped.SKILLOPT_SLEEP_REPO. A real/plugin installcaches the plugin under~/.claude/plugins/cache/, separate from the cloned repo, so the runner's co-located andCLAUDE_PLUGIN_ROOT-relative lookups forskillopt_sleep/stop working once the cache is in use (or the clone is removed) — the install flow's step 3 ("verify") can then fail withcould not locate the skillopt_sleep package. Documented the two actual remedies (SKILLOPT_SLEEP_REPO=<clone path>, orpip install skillopt/uv tool install skilloptso the PATH/import fallbacks apply) in the README instead of leaving users to reverse-engineer the runner's fallback chain from its error message.Test plan
pytest tests/test_sleep_engine.py—TestFullCycleAndAdopt::test_cycle_stages_only_documents_that_changedhad 5 of 6 subtests failing before the CRLF fix (neither_changed,skill_only,memory_only,whitespace_only_skill,whitespace_only_memory), allAssertionError: True != Falseonmanifest["has_managed_skill"]/manifest["has_managed_memory"]. All 6 subtests pass after the fix; 146 passed, 2 skipped overall, no regressions.pytest) on Windows: failures dropped from 22 to 17, the exact same 17 pre-existing, unrelated failures remaining (Windows path/encoding edge cases unrelated to this fix), with no new regressions introduced./plugin marketplace add ./plugins/claude-code,/plugin install skillopt-sleep@skillopt-sleep) in a fresh Claude Code session and confirmed/skillopt-sleeploads; ran a full dry-run + status cycle against an isolated scratch project (synthetic transcripts,--claude-homepointed away from any real data) with themockbackend — harvest/mine/replay/consolidate/gate all behaved as documented onceSKILLOPT_SLEEP_PYTHON/SKILLOPT_SLEEP_REPO(nowpythonauto-detected without needing the env var) and the install gap were accounted for.plugins/run-sleep.sh statusdirectly after the fix: it now resolvespythonand completes successfully (previously failed with "need Python >= 3.10 (found none)" when onlypythonwas onPATH).🤖 Generated with Claude Code