Skip to content

fix(sleep): stage only documents changed by an accepted cycle - #277

Open
Bogdan (Dan) Baciu (bogdanbaciu21) wants to merge 1 commit into
microsoft:mainfrom
bogdanbaciu21:fix-57-unchanged-staging
Open

fix(sleep): stage only documents changed by an accepted cycle#277
Bogdan (Dan) Baciu (bogdanbaciu21) wants to merge 1 commit into
microsoft:mainfrom
bogdanbaciu21:fix-57-unchanged-staging

Conversation

@bogdanbaciu21

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where a cycle with one accepted document change would also stage enabled documents that were unchanged. For example, a memory-only edit produced a proposed_SKILL.md identical to the live skill and marked that skill as present in the manifest, adding an unrelated artifact to review and adoption.

Why This Change Was Made

The cycle already retains the exact skill and memory text read before consolidation. It now compares each accepted result with that baseline and passes only changed documents to staging. The comparison is exact, so visible whitespace or text changes still stage normally.

Project Fit

  • Improves SkillOpt-Sleep's review-first staging contract by making each proposal correspond to a real document change.
  • Preserves the existing gate, report, and adoption behavior while removing no-op artifacts.

User Impact

Memory-only nights stage only the memory proposal, and skill-only nights stage only the skill proposal. Users no longer need to inspect or adopt a second document that the optimizer did not change.

Proof

The regression supplies an accepted memory-only consolidation result through the real cycle and staging path. With only that regression applied to upstream 79124b37e9a6371e13b753f8bcd7adb1e493ade1, it fails because has_managed_skill is true. With this change, the manifest reports has_managed_skill: false and has_managed_memory: true, proposed_SKILL.md is absent, and proposed_CLAUDE.md remains present.

Local pre-publication receipt at d115799aa7e627b702ee955f74d86993dcf1a0ee, based on that upstream commit:

$ git rev-parse HEAD
d115799aa7e627b702ee955f74d86993dcf1a0ee
$ python3 -m pytest -q tests/test_sleep_engine.py -k 'cycle_stages_only_documents_that_changed or cycle_pins_the_exact_managed_skill_and_memory_bytes_it_read or cycle_stage_then_adopt_with_backup'
3 passed, 118 deselected in 0.19s

Academic Support

  • Issue #57 records the original memory-only staging reproduction and identifies an unchanged-document diff check as the intended follow-up.
  • The existing staging manifest remains the source of truth for proposal presence, so this fix uses its established booleans and artifact layout rather than adding another state model.

Testing

  • New regression: test_cycle_stages_only_documents_that_changed exercises the full cycle-to-staging boundary and checks the manifest plus both artifact paths.
  • Existing guards: test_cycle_pins_the_exact_managed_skill_and_memory_bytes_it_read protects byte fidelity, and test_cycle_stage_then_adopt_with_backup protects the surrounding adoption path.
  • Baseline reproduction at 79124b37e9a6: failed at assertFalse(manifest["has_managed_skill"]) because the value was true.
  • Focused cycle and staging slice: passed with the receipt quoted above.
  • Complete Linux suite on Python 3.12: passed with the receipt quoted below.
  • git diff --check: passed.
$ python3 -m pytest -q
1497 passed, 12 skipped, 8 warnings, 353 subtests passed in 33.59s

Limitations & Negative Results

This change does not rename staged memory files or alter which edits the gate accepts. It removes only exact no-op document proposals from an otherwise accepted cycle.

Reproduce It Yourself

Linux or macOS, shell from the SkillOpt repository root:

python3 -m pytest -q tests/test_sleep_engine.py -k 'cycle_stages_only_documents_that_changed or cycle_pins_the_exact_managed_skill_and_memory_bytes_it_read or cycle_stage_then_adopt_with_backup'
python3 -m pytest -q

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.

1 participant