Repository navigation
fix: keep a user's lesson when a consolidation rewording overlaps it - #30833
Conversation
UX Review (Opus 5.5) — ⏭️ skippedRevision |
GPT 6.1 Review — ✅ no blocking findingsGPT 6.1 completed its review of This comment is updated in place on each push. Review detailsNo findings. False positive or not applicable? A repository writer can comment: |
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS Nothing blocks: the fix applies the cosine branch's existing authority rule to all three delete sites through one shared helper, and the old test pin was recorded as a pending decision, not a settled one. Notes
[DESIGN-REVIEWED] 9427adf Description read[DESCRIPTION-READ] 180e0b5863484133d2d50babb92d42402cd65c2151b8763c5777883cfe696c16 That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with |
First Principles Review (Opus 5.5) — ✅ PASSPremise-level review of First-Principles-Verdict: PASS Fixes a reported defect at its cause. Issue #9163 is linked, and the comment this PR deletes had already marked scan-wide authority ordering as a "tracked follow-up decision". What this change shipsInventory (6 items) — 6 justifiedIntent: stop background consolidation from silently deleting lessons the user saved (FIX).
[FIRST-PRINCIPLES-REVIEWED] 9427adf Description read[DESCRIPTION-READ] f7fc7b183ff31ddcd1d114ad5afc63863a5318a0d4861378ab99717b28bf3104 That sha256 names the PR description this verdict read. Recompute it with |
b95424c to
153f595
Compare
Opus 5.5 Review — ✅ no blocking findingsReviewed Verdict parsed from the review's SHA-scoped output markers for commit False positive or not applicable? A repository writer can comment: |
153f595 to
630e47e
Compare
|
Rebased: main moved in [operator: bolichen97] |
630e47e to
81b7a1d
Compare
|
Rebased: main moved in [operator: bolichen97] |
81b7a1d to
be92931
Compare
|
The red |
be92931 to
1bee9da
Compare
|
The red |
The substring and topic-overlap dedup branches of write_lesson retired a stored lesson on text alone, so a consolidation rewording that shared half its keywords with a user_explicit lesson replaced it and dropped the user's specifics. Only the semantic branch weighed authority. Every dedup delete site now applies the same authority rule the semantic branch uses (user_explicit over another source, or strictly higher stored confidence): an outranking row is kept and the submission is stored beside it. A user_explicit write is unaffected. Closes #9163
1bee9da to
9427adf
Compare
KiroCrewCaptain
left a comment
There was a problem hiding this comment.
Approved for the on-call. Review lanes pass on 9427adf, no conflict, no open change request.
…30833) The substring and topic-overlap dedup branches of write_lesson retired a stored lesson on text alone, so a consolidation rewording that shared half its keywords with a user_explicit lesson replaced it and dropped the user's specifics. Only the semantic branch weighed authority. Every dedup delete site now applies the same authority rule the semantic branch uses (user_explicit over another source, or strictly higher stored confidence): an outranking row is kept and the submission is stored beside it. A user_explicit write is unaffected. Closes #9163 (cherry picked from commit f54bb35) Originally authored on main by Bolin Chen (bolichen97); authored here with the public identity because the commit guard refuses the original address.
…30833) The substring and topic-overlap dedup branches of write_lesson retired a stored lesson on text alone, so a consolidation rewording that shared half its keywords with a user_explicit lesson replaced it and dropped the user's specifics. Only the semantic branch weighed authority. Every dedup delete site now applies the same authority rule the semantic branch uses (user_explicit over another source, or strictly higher stored confidence): an outranking row is kept and the submission is stored beside it. A user_explicit write is unaffected. Closes #9163 (cherry picked from commit f54bb35) Originally authored on main by Bolin Chen (bolichen97); authored here with the public identity because the commit guard refuses the original address.
Problem / Motivation
Goal: A lesson the user saved is never deleted by a lower-authority lesson write, such as a consolidation rewording, at any of the three dedup delete sites.
A user's store showed three of their own
user_explicitlessons replaced by consolidation rewordings. Each replacement lost a detail the user had written: the named pipelines in one, the mechanism clause in another, the trigger condition in the third. The replacements carrysource=consolidationat confidence 0.9, so the user's corrections were demoted with no visible event.Why it matters
Lessons are how a user corrects the agent. When background consolidation silently rewrites them, the correction the user made is gone, and the agent falls back to a vaguer rule. Nothing in the UI shows that it happened, so the user cannot notice or restore it.
Not a goal
appliestier rule (tier_permissions), the exact-rule pass, or thesubstring_covereddecline.rfc-memory-hygiene.md, whose sweep holds off retiring lessons until this ordering is settled.What changed (motivation → approach → change)
The dedup scan in
write_lessonhas three rules that can delete a stored lesson: substring containment, topic overlap (half the keywords shared), and cosine similarity. Only the cosine rule checked who wrote the stored row. The two text rules run first and are the likelier match for a rewording, so they retireduser_explicitlessons on text alone.The decision this PR records, for the maintainer to approve with the code:
user_explicitand the write is not, or when its stored confidence is strictly higherappliestier rule already does; the cosine branch still declines the writeA
user_explicitwrite is outranked by nothing, so a user correcting their own lesson still replaces it, and equal-authority writes keep newest-wins. The cost: a consolidation correction of a user rule ("use light mode" over a user's "use dark mode") leaves both rules in effect until the user replaces or deletes the old one. The owning spec (memory-skills-hooks.md) records the rule and that cost, and theonboarding_import.pycomment and its spec (onboarding-import.md) no longer saywrite_lessoncan delete a lesson the user taught.Backwards compatibility
Compatible: every write that was accepted is still accepted with the same outcome (
inserted); only the set of rows it deletes shrinks.Removes nothing: the change deletes fewer stored lessons and removes no field, route, key or function.
Tests
test_the_authority_pre_pass_skips_rows_the_lexical_branches_claim: a consolidation write that contains auser_explicitrule is stored, reports no supersede, and both rows stay. It pinned the old deletion before.test_a_topic_overlap_write_keeps_an_outranking_row(user_explicitandimportat 1.0): a consolidation write sharing half its keywords keeps the higher row, by source and by confidence.test_a_semantic_match_the_pre_pass_skips_keeps_an_outranking_row: the scan's cosine branch keeps a user'son_topicrow that the pre-pass left to the scan.test_a_committed_write_still_executes_its_lexical_supersedes) and the cosine branch's decline.-n0, 10/10 at-n 4 --dist loadgroup --max-worker-restart=2besidetest_lesson_write_outcome.pyandtest_lesson_write_outcome_supersede.py, and the whole file green in a shuffled order (seed 12183).Proof: PROVEN test/test_vector_memory_coverage_vector_space.py::TestLessonDedupPaths::test_the_authority_pre_pass_skips_rows_the_lexical_branches_claim, test/test_vector_memory_coverage_vector_space.py::TestLessonDedupPaths::test_a_topic_overlap_write_keeps_an_outranking_row[user_explicit], test/test_vector_memory_coverage_vector_space.py::TestLessonDedupPaths::test_a_topic_overlap_write_keeps_an_outranking_row[import], test/test_vector_memory_coverage_vector_space.py::TestLessonDedupPaths::test_a_semantic_match_the_pre_pass_skips_keeps_an_outranking_row (head 81b7a1d)
Manual verification
N/A — unit coverage sufficient: the change is one store method's delete decision, exercised end to end on a real SQLite store in the tests above.
Related Issues
Closes #9163
Sibling sweep
Swept: git grep -nE "lesson_keywords(|tier_permissions(|delete_semantic(" -- src/
Sibling: src/kiro_crew/vector_memory_runtime/lesson_write.py -- changed here
Sibling: src/kiro_crew/learn.py:256 -- not affected -- a JSONL row records no source or confidence, so there is no authority to compare
Sibling: src/kiro_crew/dashboard/handlers/cron_lesson_supersede.py -- not affected -- the contradiction sweep retires only on_topic findings
Sibling: src/kiro_crew/history_consolidation_memory.py -- not affected -- a consolidation delete is refused unless the row is on_topic
Pattern harvest
Not generalizable: the authority rule existed and was applied at one of three delete sites; the sites now share one gate, so there is no second shape left to catch.
Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)