Repository navigation
feat: search and edit lessons in the memory tab - #31438
Conversation
Design Review (Opus 5.5) — ✅ PASSDesign-level review of Design-Verdict: PASS No design-level concerns: an in-place rewrite under the store lock that reuses the add route's guards is the right shape, and nothing is taken away. Notes
[DESIGN-REVIEWED] d3f23ca Description read[DESCRIPTION-READ] b0638a4a522412f199c14c228ecc50324840b93c47da52e811f9351388325b1c 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 Nothing blocks: each item is new capability behind a stated harm (a typo fix loses scope, tier and NOT-clause, and can evict a row at the cap), and no default changes. What this change shipsInventory (8 items) — 8 justifiedIntent: let a user find a lesson by its text and fix a rule's wording in the Memory tab without losing the row's scope, tier or clause — ADDITION.
[FIRST-PRINCIPLES-REVIEWED] d3f23ca Description read[DESCRIPTION-READ] 6868cde0920496a10d36f768aba029122b5cb676c379c83f4daf11938d1ac957 That sha256 names the PR description this verdict read. Recompute it with |
UX Review (Opus 5.5) — ✅ PASSUX-level review of UX-Verdict: PASS Nothing blocks: the blind reader identified search, Edit, Save, Cancel and Clear filter correctly and said they would use each one. The issues left are on the rare refusal and refresh-failure paths. Notes
[UX-REVIEWED] d3f23ca Description read[DESCRIPTION-READ] 5cd910e39fdc276773b5513278354ec2593825f35755f99e53c5e94a79d94ab4 That sha256 names everything this verdict read: the PR description, plus the 11 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 |
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: |
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: |
7634f4e to
3ec8a4d
Compare
|
|
3ec8a4d to
0f5e935
Compare
0f5e935 to
9159c4b
Compare
9159c4b to
b3dc4c6
Compare
b3dc4c6 to
06dbb84
Compare
buluoray
left a comment
There was a problem hiding this comment.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
REQUEST_CHANGES at c95c70e. The behaviour is right; three statements describe a request shape the code no longer sends, and one of them is in shipped client code.
What it does for users: the Lessons card under Overview > Memory gets a search box over the listed window (newest 50) and a per-row Edit that rewrites one JSONL lesson's rule in place, keeping its position, file tier, applies-tier and NOT-clause, instead of delete-and-re-add, which lost all of those.
Blocking (false statements):
- website/src/api/client/memory.ts:204-205 says the edit sends the rule back "with the edited row's own file, scope, tier and NOT-clause". The row argument's type has no negative or applies field, MemoryTab.tsx saveEdit sends only scope, workspace, repo_scope and replaces, and the server keeps the stored clause and tier itself (learn.py replace_rule, and the route's own comment "the row's STORED clause, which the body never carries"). Please reword to what is sent: the row's file (scope / workspace), repo_scope and the replaces selector.
- The PR body's Tests section says "Save sends one request with the row's scope, workspace, repo_scope, tier, clause and replaces", and the test at website/src/test/OverviewMemoryTabCov80.test.tsx:777 is titled "carrying its own scope, tier and clause" while its assertion (line 786) checks a body with no clause and no applies-tier. Please retitle the test and fix the PR body line.
- The same file's test at line 880, "whose scope or NOT-clause cannot be sent back", names a NOT-clause condition that the Edit gate no longer has (MemoryTab.tsx gate: l.scope, l.repo_scope, l.rule_editable). Please drop "or NOT-clause".
Non-blocking:
- MemoryTab.tsx:114-118: the "A lesson row's key" doc comment now sits above EDIT_REFUSALS instead of lessonKey (line 126). Move it down.
Evidence:
- learn.py:474 LessonStore.replace_rule does the read-decide-write under one lock and writes only on replaced; the source row keeps ts, tier and negative, so the row count is unchanged at the cap.
- Mutation: removing the ambiguous return at learn.py:511 reddens test/test_lesson_edit_replace.py::test_an_edit_whose_text_names_two_rows_writes_nothing (expected False, 'replace_ambiguous', got True, None).
- Mutation: replacing the replace_vector_unsupported refusal at cron_lessons.py:419 with a pass reddens test_an_edit_against_a_populated_vector_tier_writes_nothing.
- Mutation: dropping l.rule_editable !== false from the Edit gate reddens "offers no Edit on a row whose rule is redacted or whose scope or NOT-clause cannot be sent back".
- Local runs: test/test_lesson_edit_replace.py plus test/test_lesson_changed_events.py, 46 passed; OverviewMemoryTabCov80.test.tsx, 67 passed. Full suites were not run locally.
- Guards are reused, not bypassed: replaces is parsed after the restricted-session, writes-switch and LEARN_ADD_SCHEMA checks in api_lessons_create, and it stays outside LEARN_ADD_SCHEMA so the learn_add tool cannot send it. A named workspace must be configured and not "default" before the edit picks a file.
- i18n: the nine new keys are in every manual catalog (en.json is generated and holds none of this card's keys, same as main).
- Spec: learn-cron-dashboard.md updated in the same commit and matches the code.
- CI at this head: 83 success, 11 skipped, 0 failing; PR Readiness success; all five bot lanes PASS with no HOLD; no human reviews; merges cleanly into main (merge-tree exit 0).
Source-only: the vector-store path beyond the refusal (MagicMock-backed in the test), and the screenshots.
|
HOLD (changes_requested) at c95c70e. buluoray has an active CHANGES_REQUESTED review at this head, and PR Readiness is red on it. I checked the three statements that review names, and each is stale:
To clear the hold, fix those three, then get buluoray to re-review or dismiss the request. A later commit needs a fresh review. The behaviour itself looks sound. replace_rule rewrites one row in place under the store lock, so a full store evicts nothing. It refuses missing, ambiguous and colliding edits without writing. The AI findings judged non-blocking:
— crew-pr-reviewer (r149) |
[operator: bolichen97] |
[operator: bolichen97] |
c95c70e to
9d7e30b
Compare
|
Rebased: main moved in docs/system-specs/modules/learn-cron-dashboard.md, src/kiro_crew/dashboard/handlers/cron.py, src/kiro_crew/dashboard/handlers/cron_lessons.py, src/kiro_crew/lesson_events.py, website/src/types/index.capabilities.ts and the website/src/i18n/locales/ catalogs since this head went green (d27a5fd -> c4f4ce3); CI re-running. The rebase cleared a merge conflict in [operator: bolichen97] |
|
resolution: narrowed -- this round fixes wording and removes two things, and adds no mechanism
[operator: bolichen97] |
|
[operator: bolichen97] @buluoray thank you: all three statements were stale, and each is fixed at 9d7e30b. Wording only, no behaviour change:
Non-blocking: the "A lesson row's key" doc comment now sits above The same push also:
The screenshots are re-captured from 9d7e30b. The two UX notes (an inline "Add as new lesson" action, and a wrapping edit box) are new scope, so they stay out of this PR. Could you re-review at 9d7e30b when you have a moment? |
buluoray
left a comment
There was a problem hiding this comment.
🤖 Kiro Crew Auto-Pipeline [operator: buluoray]:
REQUEST_CHANGES at 9d7e30b. Everything from my change request at c95c70e is fixed. I checked each item against the source at this head. One new gap remains, in code this push added. It is the one GPT 6.1 flagged, and I agree with it.
Fixed, each checked at 9d7e30b:
website/src/api/client/memory.ts:210-214: the comment now saysreplacesnames the edited row. The type sends onlyscope,workspace,repo_scopeandreplaces.OverviewMemoryTabCov80.test.tsx:777is now titled "carrying its own scope, workspace and repo_scope", and the PR body's Tests line names the same keys.OverviewMemoryTabCov80.test.tsx:896no longer names a NOT-clause condition.- The "A lesson row's key" comment now sits above
lessonKey(MemoryTab.tsx:122-126).
Blocking:
- A saved edit whose list re-read fails now shows nothing at all.
MemoryTab.tsx:604-607: afterreplaced, the editor closes andawait loadLessons().catch(() => undefined)drops the error.- Trigger: Save returns
replaced, thenGET /api/lessonsfails, for example during a gateway restart. - Outcome: the row still shows the old wording, with no notice. The user cannot tell a saved edit from a lost one. If they edit the same row again, the server no longer holds the old text. The retry is then refused with
replace_source_missing, whose notice ("This lesson changed or was removed. Reload the list and try again.") is the first sign the first save worked. - At c95c70e this path showed the delete banner, which was wrong in the other direction. Dropping that banner was right; dropping every notice is the gap.
- Smallest fix: keep the editor closed, and show the re-read failure through an
ErrorNoticethat says the edit was saved but the list could not be reloaded. Add one test withapi.lessonsrejecting after areplacedsave, asserting that notice. The Add box has the same silent path onmain, so leaving it alone is fine for this PR. - This is the GPT 6.1 finding on this head (
errors-use-error-notice). Please fix it rather than override it.
Non-blocking:
- The rebase, the removed
superseded?field and the re-captured screenshots look fine.
CI at this head: 84 success, 11 skipped, 2 failing (GPT 6.1 Review, for the finding above; PR Readiness, which waits on it). Auto-merge is on, so once this is fixed and re-reviewed the PR merges on its own.
The Lessons card could list, sort and delete a lesson but not find one by its text or correct one without deleting it and typing it again, which also lost the row's scope, tier and NOT-clause. A search box filters the listed lessons by rule text, and each row gets an Edit. Save sends the new text through POST /api/lessons with the row's scope and a `replaces` selector naming the row, and the JSONL store rewrites that one row in place under its lock: the row keeps its tier and NOT-clause, the row count never changes, and any outcome other than `replaced` writes nothing and keeps the draft. A list re-read that fails after a saved edit says the edit was saved. A row whose listed rule is redacted offers no Edit. Closes #17982
9d7e30b to
d3f23ca
Compare
|
self-added: yes
[operator: bolichen97] |
|
[operator: bolichen97] @buluoray thank you, agreed: a saved edit whose list re-read failed said nothing at all. Fixed at d3f23ca, as you suggested:
The Add box's silent re-read on |
|
The review found nothing that blocks this head. It still needs a maintainer: the change request from buluoray is open. Its last blocker was a list re-read that failed silently after a saved edit. That now looks fixed at this head, because saveEdit catches the reload error and shows an error notice. buluoray, please re-review or dismiss when you can. What the review checked on d3f23ca:
Done well: the content screens run against the clause stored now, not the clause the client listed. A clause another writer attached therefore survives an edit. Optional:
Once this merges, #18831 can be closed as superseded. |
buluoray
left a comment
There was a problem hiding this comment.
Approve on d3f23ca. Both of Ray's change requests (5 items over 2 reviews) are addressed at d3f23ca; the only delta since 9d7e30b is the saved-but-not-reloaded ErrorNotice plus its i18n key in all 13 manual catalogs, and the in-place replace still writes only on replaced with no lesson dropped or reordered. Each requested change is addressed: (1) memory.ts comment now states what is sent (memory.ts:204-206, type :211-214); (2) test title and PR body no longer claim scope/tier/clause (OverviewMemoryTabCov80.test.tsx:777 and the PR body Tests line); (3) test name matches the condition that exists (test :898, MemoryTab.tsx:907); (4) the lessonKey comment sits on lessonKey (MemoryTab.tsx:122-126); (5) saved-but-not-reloaded now shows an ErrorNotice (MemoryTab.tsx:604-612, :889) with its key in all 13 manual catalogs and a test (OverviewMemoryTabCov80.test.tsx:795-811). Decisive lines: website/src/pages/overview/MemoryTab.tsx:604-612, website/src/pages/overview/MemoryTab.tsx:889, website/src/test/OverviewMemoryTabCov80.test.tsx:795-811, src/kiro_crew/learn.py:474-531
|
[operator: bolichen97] Thanks for the three optional notes on d3f23ca. I checked each one against the code. None of them changes this PR, which stays as approved:
|
Problem / Motivation
Goal: A user can find a lesson in the Memory tab's Lessons table by its text, and correct a rule's wording there without deleting it and adding it again.
The Lessons card under Overview > Memory lists, sorts and deletes lessons, but it has no search and no way to fix a rule. Correcting one typo means deleting the row and re-adding it from the Add box, which files the new rule globally with no tier and no NOT-clause, whatever the old row had.
Builds on #18831 by @bhumin18.
Why it matters
A wrong rule is handed to every session until someone fixes it, and today the fix also loses the lesson's scope, workspace file, tier and NOT-clause unless the user retypes them through the CLI. In a store with dozens of lessons, finding the row to fix means scrolling a table that shows only the newest 20.
Not a goal
learn_*MCP tools.GET /api/lessonsreturns.What changed (motivation → approach → change)
The Lessons card (
website/src/pages/overview/MemoryTab.tsx) gets a search box and a per-row Edit. Typing in the box narrows the table to the lessons whose rule contains the text, across every row the list returned (its newest 50) rather than only the newest 20 the table shows without a query; a query that matches nothing shows the shared "no matches" line with a clear action.Edit turns the rule cell into a text box with Save and Cancel. Save sends the new text through the same
POST /api/lessonsthe Add box uses (createLessoninwebsite/src/api/client/memory.tstakes the row as an optional third argument), carrying the row's category,scope/workspaceandrepo_scope, plusreplaces: {rule, repo_scope}naming the row being edited, then re-reads the list. Reusing the add route keeps every guard it has (restricted sessions, the writes switch, validation, workspace ownership, the content screens, the audit).replacesis outsideLEARN_ADD_SCHEMA, so thelearn_addtool cannot send it.With
replaces, the route (src/kiro_crew/dashboard/handlers/cron_lessons.py, whose new helpers thecron.pyfacade lists) rewrites that one row and answersreplaced, or refuses and writes nothing. The JSONL store does it in place under its lock (LessonStore.replace_ruleinsrc/kiro_crew/learn.py): the row keeps its place, tier and the NOT-clause it holds at that moment, and the row count never changes, so a store at its 200-row cap evicts nothing. An add-then-delete would first have evicted an unrelated lesson. Areplacededit reports the old wording insuperseded, so it is audited and announced to collaborators like any write that replaces a lesson, and it tells subscribed appslessons.changedwith actionupdated(lesson_write_actioninsrc/kiro_crew/lesson_events.py). An edit naming a workspace that is not configured, or the reserveddefault, is refused with 400workspace_unknownas DELETE already does, since an unmapped name would resolve to another file. An edit against a vector tier is refused (replace_vector_unsupported): the card is hidden there, and the vector write would dedup, enrich or supersede rows the edit never named. A V1 store holding no decodable lesson is the list's JSONL fallback, so the edit goes to the JSONL file the list read.replacedreplaced, then the list re-read failsreplace_source_missing: no row matches the old rule and scope exactlyreplace_ambiguous: two rows share the old text and scope, so the selector cannot say whichreplace_collision: another row in that scope already holds the new text, and merging would drop one row's tierreplace_vector_unsupported: the list is the vector tierrefused,deduped,unchanged, or the request failsLegend: added, changed, unchanged.
An open edit counts as an unsaved draft in the tab's dirty state, so switching memory store, leaving the tab or reloading asks before the draft is lost, and one edit is open at a time: the other rows' Edit is disabled until Save or Cancel. The draft keeps the row as it was when Edit opened, so a search or a refresh that leaves the row out still shows it with its draft.
A rule the redaction chain changes is listed with a placeholder in it. Editing that text would store the placeholder, so
GET /api/lessonsmarks such a rowrule_editable: falseand it offers no Edit; the route would refuse it anyway, because the listed text matches no stored row.The
Lessontype inwebsite/src/types/index.capabilities.tsgainsrule_editable. The new strings are in every catalog underwebsite/src/i18n/locales/, andlearn-cron-dashboard.mddocuments the search and the edit.Backwards compatibility
Compatible:
rule_editableis a new optional key on rows ofGET /api/lessons,replacesis a new optional key onPOST /api/lessons(without it the route behaves as on main),createLesson's third argument is optional, and the Add box sends the same body as before.Removes nothing: no key, route or behaviour main has is removed.
Tests
test/test_lesson_edit_replace.py(new): an edit at the 200-row cap rewrites its row in place, keeps its tier and evicts nothing; an edit keeps a clause attached after the list was read; an edit onto another row's text, an edit of a row that is not stored (as a redacted listing is) and an edit whose old text names two rows all write nothing; an edit the content screens refuse for the row's stored clause names that reason, never capacity; a broken-scope row with the same text is not taken for the global row; an edit against a populated vector tier writes nothing, and one with an empty V1 vector store rewrites the listed JSONL row; a redacted rule is listedrule_editable: false.website/src/test/OverviewMemoryTabCov80.test.tsx,MemoryTab — lesson search and edit (#17982):repo_scopeandreplaces, deletes nothing itself and re-reads the list;repo_scopeisnull, or that comes from vector memory (it names no file tier) offers no Edit.Determinism: the edit block (10 tests) ran 10 times in a row, all green, and the whole file once in a shuffled order (
--sequence.shuffle, seed 51307), 68 of 68 green; the re-read test is red against 9d7e30b'sMemoryTab.tsx, where the failed re-read was silent, and green here.Proof: PROVEN test/test_lesson_edit_replace.py::test_an_edit_at_the_cap_rewrites_its_row_and_evicts_nothing, test/test_lesson_edit_replace.py::test_an_edit_onto_another_rows_text_changes_nothing, test/test_lesson_edit_replace.py::test_an_edit_of_a_row_that_is_not_stored_writes_nothing, test/test_lesson_edit_replace.py::test_an_edit_whose_text_names_two_rows_writes_nothing, test/test_lesson_edit_replace.py::test_an_edit_skips_a_broken_scope_row_with_the_same_text (head b0f455489a49)
Manual verification
Captured the Lessons card from this head (
d3f23ca400) running in an isolated gateway on a seeded JSONL store, with scripted Playwright, light and dark: a search narrowing the rows, a row in edit with every other row's Edit disabled, a saved edit whose list re-read failed, an edit the server refused, and a search with no match. The list, the edit'sPOST /api/lessons, itsreplacedanswer and itsreplace_ambiguousrefusal are the gateway's own responses. Two responses are rewritten.GET /api/memory/embedding-statushas itsproviderset tonone: the gateway reportsollamathere on every install, the Memory tab reads that as vector memory being active, and it hides the card whenever that is so. For the re-read capture, theGET /api/lessonsthat follows the saved edit answers 503, as it would during a gateway restart. The edit's rewrite against a real JSONL store, and its refusal on a real vector store, are covered bytest/test_lesson_edit_replace.py.Screenshots / video
Search narrowing the rows (light, dark):
A row in edit, with Save and Cancel; every other row's Edit is disabled until Save or Cancel (light, dark):
A saved edit whose list re-read failed: the editor is closed, and the notice says the edit was saved but the list could not be refreshed, with the error (light, dark):
An edit the server refused (
replace_ambiguous: two stored rows share the text and scope): the notice names the next step instead of the reason code, and the draft stays in the row:A search with no match:
Related Issues
Closes #17982
Sibling sweep
N/A — a
featPR.Pattern harvest
N/A — a
featPR.Checklist
feat|fix|docs|style|refactor|perf|test|chore|ci|build|revert: ...)Contribution License Agreement
Contributed under the project's Apache-2.0 license (see CONTRIBUTING.md).