Repository navigation
fix: name the lessons a write superseded instead of a bare insert - #8585
Conversation
Design Review (Fable 5) — 🟡 CONCERNSDesign-level review of Design-Verdict: CONCERNS Sound additive reporting fix, but the report is ephemeral and interactive-only, so the stated harm survives on unattended and dashboard paths. Watch
Suggestions
[DESIGN-REVIEWED] d4f81c4 |
Opus 4.8 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: |
First Principles Review (Fable 5) — 🟡 CONCERNSPremise-level review of I have everything I need. The reuse claims check out ( First-Principles-Verdict: CONCERNS The fix is real and minimal, but the dashboard — one of the three human surfaces with this exact silence — still says nothing. What this change shipsIntent: tell the user which stored lessons a lesson-save silently deleted. This is a FIX.
Watch
[FIRST-PRINCIPLES-REVIEWED] d4f81c4 |
GPT 5.6 Review — ✅ no blocking findingsGPT 5.6 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: |
0cc86fb to
d03ce0d
Compare
d03ce0d to
2eca019
Compare
2eca019 to
5c3c0d7
Compare
5c3c0d7 to
bf2c1a1
Compare
bf2c1a1 to
e0e1aeb
Compare
|
GPT's Zero-delta against base (the same route already sends the lesson's own GPT 5.6 now reports no blocking findings on CodeQL on this head is down to ONE alert, |
…insert write_lesson deduplicates on substring containment, and the direction where the SUBMITTED rule contains a STORED one tombstones the stored row. Teaching "when a release is in progress, never force push to a shared branch" therefore retired a stored "never force push to a shared branch", and the call returned LessonWriteOutcome.INSERTED with reason=None -- so the caller was told its lesson was saved and the store no longer held any rule against force pushing outside a release. The row is a tombstone, so it is also gone from get_lessons, learn_list and the injected lessons block. The deletion is deliberate and stays. Three separate records establish it: the docstring's "longer wins" and "newer replaces older", the spec's dedup table, and onboarding_import, which routes to set_semantic_if_absent precisely BECAUSE "it deletes an existing lesson on exact-substring OR >50% topic overlap" -- a contract described that exactly is not an accident, and the remedy chosen there was to avoid the function rather than change it. The silence was not deliberate, and it was total. This branch was the only one of the four in the dedup scan that deleted a row without logging; its three siblings each log. Nothing in LessonWriteResult could carry a deleted row either, so the event left no trace at any level. So: every rule the scan deletes is now recorded in LessonWriteResult.superseded and named -- in full, not counted -- by /api/lessons, the learn add CLI and the learn_add tool. Collected at all three delete sites, not just the substring one: one result object cannot report some of its deletions and stay trustworthy. Loosening the containment test would have been the wrong fix twice over. It would not work -- verbatim containment at word boundaries makes the stored rule's keyword set a SUBSET of the submitted rule's, so topic overlap scores 100% and deletes the same row three lines below, measured -- and it would cost the check its ability to say no, accumulating a near-identical row per re-phrasing. Nothing here is loosened; the same rows are deleted as before. Refs #7206
af2ebdd to
d4f81c4
Compare
bolichen97
left a comment
There was a problem hiding this comment.
Approved after strict tech-lead review.
Data integrity — the core question. superseded is populated at ALL THREE delete sites (substring existing_lower in rule_lower, topic-overlap ratio >= 0.5, semantic longer-wins) and carried on EVERY return path after the dedup scan: DEDUPED/substring_covered, DEDUPED/semantic_similarity, REFUSED, and INSERTED/ENRICHED. That completeness is what makes the field trustworthy — a result that reported some of its deletions and not others would be worse than none. The REFUSED path is the one that matters most and it is covered: rows were tombstoned and nothing was stored in their place.
No deletion behaviour moves. Every comparison stays on the embed rendering (existing_text, existing_lower, the keyword set, the len() tiebreak); only the REPORT uses _lesson_display_text, with a fallback to the comparison text so the report can never be emptier than the row it names. Keeping the stored NOT-clause in the report is right — that is the sharpest half of the guidance and the row is a tombstone, so there is no second place to read it from. Two characterization tests pin the supersede so a later "fix" cannot loosen containment while the reporting tests stay green.
Result type. Frozen dataclass, tuple default (), appended last — the ~60 existing two-arg construction sites are untouched and truthiness is unchanged.
Security. CLI order is correct and non-obvious: strip terminal controls FIRST, then redact. Stripping can only JOIN characters, never split a token, so it can only help the credential regex; the reverse order leaks AKIA<CSI>IOSFODNN7EXAMPLE verbatim by reassembling it after the regex has already failed to match. Route redacts through _redact_memory_field, which I verified recurses into lists (_shared.py). All three dedup log lines now carry row ids + category + count instead of lesson text, which removed CodeQL #811/#812/#813 (no longer open) rather than papering over them. The residual control-split bypass in _redact_memory_field is zero-delta against main — the same route already sends the lesson's own rule and category through the same helper — and is correctly filed as #8750 instead of being fixed in a lesson-reporting PR.
The one CodeQL red is not this PR's. Verified independently: code-scanning/alerts?ref=refs/pull/8585/merge returns ZERO alerts, and the only open alert on this file is #643 (py/weak-sensitive-data-hashing, open since 2026-08-20 at line 445). This PR adds +17 lines above 445 (the docstring and field hunks at 165/191), which is exactly the shift to 462, and the diff adds no hashing call. CodeQL is not a required context — the commit status is success on PR Readiness.
Signals. All five AI lanes green on this head: GPT 5.6 and Opus 4.8 no findings; Design and First Principles CONCERNS (advisory, not BLOCK) and both name the SAME deferred item — the dashboard Memory tab renderer plus a reason at delete_semantic time. The route already sends the field, so that follow-up is self-contained UI work, and deferring an unverifiable website/ change (no node_modules, nine i18n locales through a formal pipeline) out of an otherwise fully verified backend PR is the right trade. The six cancelled check-runs are superseded duplicate runs; each has a success on this head.
Scope and module rules. Backend + spec + tests only, no website/ files, so the ux-review-required ruleset does not apply. docs/system-specs/modules/memory-skills-hooks.md documents the asymmetric substring rule, the superseded field, and the conflict-resolution table row — the module's spec-with-code requirement is met. 1 commit, Pattern harvest present.
The honest scoping is the strongest thing here: the deletion policy and the length-as-scope question are left to maintainers with #6175, and only the reporting gap is closed.
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Guard the supersede by stored authority: a stored row that outranks the
write -- `user_explicit` over a lower-authority source, or strictly
higher stored confidence (the onboarding import writes user lessons at
confidence 1.0 under source "import") -- is never displaced by it. That
write returns the old deduped outcome instead, so newest-wins cannot
invert the authority order `_write_semantic` already enforces for
same-key writes. Regression tests cover both directions plus the
import-sourced row, and were proven red without the guard.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- The learn_add deduped reply is tailored by reason code: the
`semantic_similarity` case is now only reachable when a lower-authority
write hit a user_explicit lesson, so that reply must not coach the
learn_remove-and-re-add path around the guard.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Guard the supersede by stored authority: a stored row that outranks the
write -- `user_explicit` over a lower-authority source, or strictly
higher stored confidence (the onboarding import writes user lessons at
confidence 1.0 under source "import") -- is never displaced by it. That
write returns the old deduped outcome instead, so newest-wins cannot
invert the authority order `_write_semantic` already enforces for
same-key writes. Regression tests cover both directions plus the
import-sourced row, and were proven red without the guard.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- The learn_add deduped reply is tailored by reason code: the
`semantic_similarity` case is now only reachable when a lower-authority
write hit a user_explicit lesson, so that reply must not coach the
learn_remove-and-re-add path around the guard.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Guard the supersede by stored authority: a stored row that outranks the
write -- `user_explicit` over a lower-authority source, or strictly
higher stored confidence (the onboarding import writes user lessons at
confidence 1.0 under source "import") -- is never displaced by it. That
write returns the old deduped outcome instead, so newest-wins cannot
invert the authority order `_write_semantic` already enforces for
same-key writes. Regression tests cover both directions plus the
import-sourced row, and were proven red without the guard.
- Semantic supersedes are deferred until the scan settles the write: rows
are scanned newest-first, not authority-first, so deleting mid-scan let
a lower-authority near-duplicate be destroyed just before a
higher-authority match declined the write -- losing a stored lesson
while storing nothing. Deletions now run only on the path where the
submission is stored; a declined write deletes nothing from this
branch. Proven red-before-green with a two-row scan-order test.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- The learn_add deduped reply is tailored by reason code: the
`semantic_similarity` case is now only reachable when a lower-authority
write hit a user_explicit lesson, so that reply must not coach the
learn_remove-and-re-add path around the guard.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Authority pre-pass (settled after a review retrospective across three
rounds on this span): every refusal this change introduces is decided
BEFORE the scan takes its first deletion. A non-mutating pre-pass over
the same rows the semantic branch sees (shared lazy-backfill budget,
blobs memoized onto the row dicts) returns the old deduped outcome when
a stored near-duplicate outranks the write -- `user_explicit` over a
lower-authority source, or strictly higher stored confidence (the
onboarding import stores user lessons at confidence 1.0 under source
"import"). A write declined on authority therefore deletes nothing and
reports an empty `superseded`; the mutating scan keeps main's
delete-as-you-go shape for the write-proceeds path. Regression tests
cover both guard directions, the import-sourced row, and the
declined-write-deletes-nothing sequence, each proven red without the
protection.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- The learn_add deduped reply is tailored by reason code: the
`semantic_similarity` case is now only reachable when a lower-authority
write hit a user_explicit lesson, so that reply must not coach the
learn_remove-and-re-add path around the guard.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Authority pre-pass (settled after a review retrospective across three
rounds on this span): every refusal this change introduces is decided
BEFORE the scan takes its first deletion. A non-mutating pre-pass over
the same rows the semantic branch sees (shared lazy-backfill budget,
blobs memoized onto the row dicts) returns the old deduped outcome when
a stored near-duplicate outranks the write -- `user_explicit` over a
lower-authority source, or strictly higher stored confidence (the
onboarding import stores user lessons at confidence 1.0 under source
"import"). The pre-pass covers PURE semantic matches only: a row the
scan's substring or topic-overlap branch would claim first keeps main's
lexical outcome (those branches are source-blind by main's design). A
write declined on authority therefore deletes nothing and reports an
empty `superseded`; the mutating scan keeps main's
delete-as-you-go shape for the write-proceeds path. Regression tests
cover both guard directions, the import-sourced row, and the
declined-write-deletes-nothing sequence, each proven red without the
protection.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- The learn_add deduped reply is tailored by reason code: the
`semantic_similarity` case is now only reachable when a lower-authority
write hit a user_explicit lesson, so that reply must not coach the
learn_remove-and-re-add path around the guard.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Authority pre-pass (settled after a review retrospective across three
rounds on this span): every refusal this change introduces is decided
BEFORE the scan takes its first deletion. A non-mutating pre-pass over
the same rows the semantic branch sees (shared lazy-backfill budget,
blobs memoized onto the row dicts) returns the old deduped outcome when
a stored near-duplicate outranks the write -- `user_explicit` over a
lower-authority source, or strictly higher stored confidence (the
onboarding import stores user lessons at confidence 1.0 under source
"import"). The pre-pass covers PURE semantic matches only: a row the
scan's substring or topic-overlap branch would claim first keeps main's
lexical outcome (those branches are source-blind by main's design).
The mutating semantic branch's own supersedes are DEFERRED and execute
only when the write proceeds, so a later `substring_covered` refusal
cannot strand a deletion newest-wins took where the old tie-break would
have refused. A write declined for any reason therefore deletes nothing
via the semantic branch and reports it honestly in `superseded`.
- The learn_add deduped reply labels the quoted text as the DROPPED
submission and names the learn_list -> learn_remove -> re-add recovery.
(An earlier draft carried a second, authority-flavored reply variant;
it was unreachable on a current build and is removed.)
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Authority pre-pass (settled after a review retrospective across three
rounds on this span): every refusal this change introduces is decided
BEFORE the scan takes its first deletion. A non-mutating pre-pass over
the same rows the semantic branch sees (shared lazy-backfill budget,
blobs memoized onto the row dicts) returns the old deduped outcome when
a stored near-duplicate outranks the write -- `user_explicit` over a
lower-authority source, or strictly higher stored confidence (the
onboarding import stores user lessons at confidence 1.0 under source
"import"). The pre-pass covers PURE semantic matches only: a row the
scan's substring or topic-overlap branch would claim first keeps main's
lexical outcome (those branches are source-blind by main's design).
The mutating semantic branch's own supersedes are DEFERRED and execute
only when the write proceeds, so a later `substring_covered` refusal
cannot strand a deletion newest-wins took where the old tie-break would
have refused. A write declined for any reason therefore deletes nothing
via the semantic branch and reports it honestly in `superseded`.
- The learn_add deduped reply labels the quoted text as the DROPPED
submission and names the learn_list -> learn_remove -> re-add recovery.
The `semantic_similarity` reason -- only reachable when the stored row
outranks the write -- deliberately withholds that coaching: following
it would delete the row the store just protected. A test locks the
reply to never name learn_remove.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Authority pre-pass (settled after a review retrospective across three
rounds on this span): every refusal this change introduces is decided
BEFORE the scan takes its first deletion. A non-mutating pre-pass over
the same rows the semantic branch sees (shared lazy-backfill budget,
blobs memoized onto the row dicts) returns the old deduped outcome when
a stored near-duplicate outranks the write -- `user_explicit` over a
lower-authority source, or strictly higher stored confidence (the
onboarding import stores user lessons at confidence 1.0 under source
"import"). The pre-pass covers PURE semantic matches only: a row the
scan's substring or topic-overlap branch would claim first keeps main's
lexical outcome (those branches are source-blind by main's design).
The mutating semantic branch's own supersedes are DEFERRED and execute
only when the write proceeds, so a later `substring_covered` refusal
cannot strand a deletion newest-wins took where the old tie-break would
have refused. A write declined for any reason therefore deletes nothing
via the semantic branch and reports it honestly in `superseded`.
- The learn_add deduped reply labels the quoted text as the DROPPED
submission and names the learn_list -> learn_remove -> re-add recovery.
The `semantic_similarity` reason -- only reachable when the stored row
outranks the write -- deliberately withholds that coaching: following
it would delete the row the store just protected. A test locks the
reply to never name learn_remove.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Authority pre-pass (settled after a review retrospective across three
rounds on this span): every refusal this change introduces is decided
BEFORE the scan takes its first deletion. A non-mutating pre-pass over
the same rows the semantic branch sees (shared lazy-backfill budget,
blobs memoized onto the row dicts) returns the old deduped outcome when
a stored near-duplicate outranks the write -- `user_explicit` over a
lower-authority source, or strictly higher stored confidence (the
onboarding import stores user lessons at confidence 1.0 under source
"import"). The pre-pass covers PURE semantic matches only: a row the
scan's substring or topic-overlap branch would claim first keeps main's
lexical outcome (those branches are source-blind by main's design).
The mutating semantic branch's own supersedes are DEFERRED and execute
only when the write proceeds, so a later `substring_covered` refusal
cannot strand a deletion newest-wins took where the old tie-break would
have refused. A write declined for any reason therefore deletes nothing
via the semantic branch and reports it honestly in `superseded`.
- The learn_add deduped reply labels the quoted text as the DROPPED
submission and names the learn_list -> learn_remove -> re-add recovery.
The `semantic_similarity` reason -- only reachable when the stored row
outranks the write -- deliberately withholds that coaching: following
it would delete the row the store just protected. A test locks the
reply to never name learn_remove.
- Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and
DROPPED the submission when it lost, so character count decided which of
two near-identical rules was current.
Corrections land on the losing side of that comparison as a rule: a
retraction collapses a detailed stale claim ("tool X is available, 48
verbs, attaches on port 9224") into a short accurate one ("tool X is not
installed"). The shorter text lost, and the stale lesson stayed in
effect -- the one outcome that actively misleads the agent rather than
merely losing detail. Observed live: a measured correction was refused
while the claim it disproved kept applying, and the only recovery was a
blind learn_remove on a guessed substring.
The substring and topic-overlap branches directly above already
supersede the stored row unconditionally, so newest-wins makes the three
dedup paths agree instead of one of them arbitrating on length.
The learn_add reply had a matching problem: it printed the SUBMITTED rule
straight after "an existing stored lesson already covers it", which reads
as a quote of the stored lesson. A caller believed it had been shown the
winner, could not tell a correct dedup from a dropped correction, and was
never told the replace path. It now labels the text as what was DROPPED
and names the learn_list/learn_remove sequence.
Substring dedup still refuses -- a rule literally contained in a stored
one is genuinely covered.
Drive-to-green additions on top of isotope14's original change (rebase
onto current main plus review fixes):
- Authority pre-pass (settled after a review retrospective across three
rounds on this span): every refusal this change introduces is decided
BEFORE the scan takes its first deletion. A non-mutating pre-pass over
the same rows the semantic branch sees (shared lazy-backfill budget,
blobs memoized onto the row dicts) returns the old deduped outcome when
a stored near-duplicate outranks the write -- `user_explicit` over a
lower-authority source, or strictly higher stored confidence (the
onboarding import stores user lessons at confidence 1.0 under source
"import"). The pre-pass covers PURE semantic matches only: a row the
scan's substring or topic-overlap branch would claim first keeps main's
lexical outcome (those branches are source-blind by main's design).
The mutating semantic branch's own supersedes are DEFERRED and execute
only when the write proceeds, so a later `substring_covered` refusal
cannot strand a deletion newest-wins took where the old tie-break would
have refused. A write declined for any reason therefore deletes nothing
via the semantic branch and reports it honestly in `superseded`.
- The learn_add deduped reply labels the quoted text as the DROPPED
submission and names the learn_list -> learn_remove -> re-add recovery.
The `semantic_similarity` reason -- only reachable when the stored row
outranks the write -- deliberately withholds that coaching: following
it would delete the row the store just protected. A test locks the
reply to never name learn_remove.
- Rebase composition: keep main's `superseded` reporting (#8585) on the
supersede path, and log row ids rather than rule text, matching the
identities-not-content logging doctrine in this scan.
- Spec sync: the dedup table row in
docs/system-specs/modules/memory-skills-hooks.md drops "longer text
wins" for "newer replaces older" and notes the user_explicit
protection.
Co-authored-by: isotope14 <266124104+isotope14@users.noreply.github.com>
Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
…dev#6175) Semantic lesson dedup tie-broke on `len(rule) > len(existing_text)` and DROPPED the submission when it lost, so character count decided which of two near-identical rules was current. Corrections land on the losing side of that comparison as a rule: a retraction collapses a detailed stale claim ("tool X is available, 48 verbs, attaches on port 9224") into a short accurate one ("tool X is not installed"). The shorter text lost, and the stale lesson stayed in effect -- the one outcome that actively misleads the agent rather than merely losing detail. Observed live: a measured correction was refused while the claim it disproved kept applying, and the only recovery was a blind learn_remove on a guessed substring. The substring and topic-overlap branches directly above already supersede the stored row unconditionally, so newest-wins makes the three dedup paths agree instead of one of them arbitrating on length. The learn_add reply had a matching problem: it printed the SUBMITTED rule straight after "an existing stored lesson already covers it", which reads as a quote of the stored lesson. A caller believed it had been shown the winner, could not tell a correct dedup from a dropped correction, and was never told the replace path. It now labels the text as what was DROPPED and names the learn_list/learn_remove sequence. Substring dedup still refuses -- a rule literally contained in a stored one is genuinely covered. Drive-to-green additions on top of isotope14's original change (rebase onto current main plus review fixes): - Authority pre-pass (settled after a review retrospective across three rounds on this span): every refusal this change introduces is decided BEFORE the scan takes its first deletion. A non-mutating pre-pass over the same rows the semantic branch sees (shared lazy-backfill budget, blobs memoized onto the row dicts) returns the old deduped outcome when a stored near-duplicate outranks the write -- `user_explicit` over a lower-authority source, or strictly higher stored confidence (the onboarding import stores user lessons at confidence 1.0 under source "import"). The pre-pass covers PURE semantic matches only: a row the scan's substring or topic-overlap branch would claim first keeps main's lexical outcome (those branches are source-blind by main's design). The mutating semantic branch's own supersedes are DEFERRED and execute only when the write proceeds, so a later `substring_covered` refusal cannot strand a deletion newest-wins took where the old tie-break would have refused. A write declined for any reason therefore deletes nothing via the semantic branch and reports it honestly in `superseded`. - The learn_add deduped reply labels the quoted text as the DROPPED submission and names the learn_list -> learn_remove -> re-add recovery. The `semantic_similarity` reason -- only reachable when the stored row outranks the write -- deliberately withholds that coaching: following it would delete the row the store just protected. A test locks the reply to never name learn_remove. - Rebase composition: keep main's `superseded` reporting (kirodotdev#8585) on the supersede path, and log row ids rather than rule text, matching the identities-not-content logging doctrine in this scan. - Spec sync: the dedup table row in docs/system-specs/modules/memory-skills-hooks.md drops "longer text wins" for "newer replaces older" and notes the user_explicit protection. Co-authored-by: isotope14 <266124104+isotope14@users.noreply.github.com> Co-authored-by: Kiro Crew <noreply@kirodotdev.github.io>
What is the problem?
write_lessondedupes on substring containment. In the direction where the SUBMITTEDrule contains a STORED one, the stored row is tombstoned:
Reproduced on a throwaway store at
origin/main:Both halves of the report hold, and the second is worse than reported. The write is
silent at every level:
LessonWriteResulthasoutcome/reason/stored/wrote-- every fielddescribes the SUBMITTED lesson. Nothing can carry a deleted row.
logging. Its three siblings each log (
Lesson dedup:,Lesson conflict:,Lesson semantic dedup:).get_lessons,learn_listand theinjected lessons block.
The deletion itself is deliberate, and this PR does not change it. Three independent
records establish intent: the docstring (
longer wins,newer replaces older), the specdedup table, and -- decisively --
onboarding_import.py:4269-4274, which routes toset_semantic_if_absentprecisely becauseA contract described that exactly is not an accident, and the remedy chosen there was to
avoid the function rather than change it.
Why this issue matters to the user
The lesson store is the surface where a user teaches the agent. Attaching a condition to
a rule makes the text longer and the guidance narrower, so "longer wins" retires the
rule that applies in more cases and keeps the one that applies in fewer. The user never
retracted the general rule, was told the save succeeded, and cannot find the loss: the
tombstone is filtered by every read path. On the reporter's own store 291 rows carry
is_deleted = 1, and there is currently no way to attribute any of them.How our fix solves it
Symptom -> cause -> fix:
learn_addsays "Saved lesson" for a call that destroyed a lesson.result type had no field for it, and this one branch did not even log.
LessonWriteResultgainssuperseded: tuple[str, ...] = (), populated atall three delete sites (substring, topic-overlap, semantic). One result object
cannot report some of its deletions and stay trustworthy -- a field that is truthful
for one branch and silently empty for another is worse than no field. Defaulted, so
the ~60 existing construction sites are unchanged.
REFUSED-- that is the pathwhere it matters most, since rows were deleted and nothing was stored in their place.
ENRICHEDis decided in pass 1 and skips the scan, so it always reports none./api/lessons(a JSON array, always present), thelearn addCLI, and thelearn_addtool -- in full, not counted and not truncated, because that text is thelast readable copy of a tombstoned row.
Why not loosen the containment test. It would have been wrong twice. It does not
work: verbatim containment at word boundaries makes the stored rule's keyword set a
SUBSET of the submitted rule's, so topic-overlap scores 100% and deletes the same row
three lines below. Measured by excising the branch from source -- the general rule is
still gone, with
Lesson conflict: ... (100% overlap). And it would cost the check itsability to say no, accumulating a near-identical row for every re-phrasing. Nothing
here is loosened. The same rows are deleted as before.
Two of the reporter's three questions are untouched by design -- whether text length may
stand in for scope, and whether the delete direction should exist at all. Both are
behaviour changes to stores users already have, and #6175 extends the same supersede
policy to the semantic branch, so they belong together and with the maintainers. Only
the reporting question is answered here. Refs #7206.
The report names the whole stored lesson, clause included. Dedup compares rules
through
_lesson_embed_text, which returns a mapping row'srulefield alone so thecomparison basis matches the embedding space. Reporting on that same rendering dropped
the stored NOT-clause, which is the sharpest half of the guidance -- so the clause became
unrecoverable at the exact moment the row was tombstoned, inside the mechanism that
exists to stop that. The three report sites now use
_lesson_display_text, therecomposition the injected prompt and
learn listalready use, so a restored rule readsexactly as it was stored. Every COMPARISON stays on the embed rendering, so no dedup
decision moves:
existing_lower, the keyword set, thelen()tiebreak and both loglines are untouched.
Sanitizing the reported text. Reporting a superseded rule prints stored USER text on
a path that never printed it before, so both output surfaces are routed through the
treatment each already applies to stored text -- neither is a new mechanism:
The CLI strips terminal control sequences with
_TERMINAL_CTRL_RE, THEN redactscredentials and exfiltration URLs. The order is the whole correctness of this, and the
intuitive order is the unsafe one. An earlier revision redacted first, on the stated
reasoning that an escape inside a credential would break the regex if the controls went
first -- that was exactly backwards. Measured: with
AKIA<CSI>IOSFODNN7EXAMPLEstored,redact-then-strip prints
AKIAIOSFODNN7EXAMPLEverbatim, because the escape stops thecredential regex matching and the control-strip then REASSEMBLES the token;
strip-then-redact masks it. Stripping can only ever JOIN characters, never split a
token, so running it first can only help the regex. A test plants the pre-split
credential so a future reordering reddens -- the two single-treatment tests each show
one treatment happens and neither shows they compose in the safe order.
An earlier revision of this change was control-stripping only, on the grounds that
learn listprints every stored lesson to the same terminal with the same treatment.That was the wrong comparison and is reversed here:
learn listis an EXPLICIT requestto see the store, while this block surfaces a lesson the user did not ask for and is
about to lose. The right comparison is the route, which delivers the SAME field and does
redact -- so controls-only made one feature's two delivery paths disagree about whether
a superseded rule may carry a secret. A lesson written by history consolidation also
carries model output the user never typed, so "their own store" is not "their own
knowledge".
The recovery it advises is one the policy actually permits. Earlier wording said only
"re-add it with wording that does not overlap this one", which is incomplete in a way that
sends the user into a refusal: a VERBATIM re-add of the superseded rule is declined by the
substring branch, since the narrower rule now contains it. Measured, all three cases:
verbatim re-add ->
deduped/substring_covered, nothing restored; wording sharing fewsignificant words ->
inserted, both rules coexist, nothing superseded (so it does NOTping-pong); removing the narrower rule first -> the general rule inserts and is restored
verbatim. The text now names the two that work and says plainly that a verbatim re-add is
declined, and both are pinned by tests.
POST /api/lessonssends the array through_redact_memory_field, the shared chainthis handler already applies to the lesson's own rule and category. Redacting at the
route covers both readers, since the dashboard and the
learn_addtool each see onlywhat the route sends. This path is worse than a read: the row is being deleted, so this
response is the only place that text is echoed at all.
Every log line in this dedup scan now carries IDENTITIES, never lesson content.
A lesson holds whatever the user once told the agent -- credentials, paths, names -- so
a log line reproducing its text converts a silent-deletion bug into a disclosure bug,
on a sink that persists to disk and may reach a notification channel. All three lines
log the store's own row ids (
lesson.<digest>), the category, and a count or theoverlap ratio: enough for an operator to see THAT a general rule was replaced and
WHICH one, joined to the tombstoned row, the
delete_semanticaudit record, and thematching
supersededentry. The text lives only in the result -- the read path thelessons themselves use -- where every surface redacts it.
The id is logged rather than a freshly computed digest deliberately: a new hash would
correlate with nothing. Nothing here hashes anything, so no weak-hashing exposure is
added --
_lesson_keyalready derived these ids, and CodeQL flags that derivation atits own site (
vector_memory.py:445on main, alert feat(issue-radar): open same-repo references in an in-app sheet #643), not at a line that logs theresult.
Two of the three lines are main's, and they are touched for one reason: they are the
two alerts CodeQL attributes to this PR.
git blameon the merge commit CI analysedputs both on
64e47961a(the fork import), and the MD5 alert ond1aa30999-- thisPR's commit appears in none of them; they are reported because the surrounding hunks
changed. An earlier revision instead wrapped them in
redact_and_truncate, which wasworse twice over: it tripped
test_security_posture.py::TestGateSideLogRedactorSpelling(a gate-side log line mustread
redact_log_via_context, not the companion-blind baseline pass) AND added CodeQLalerts, because wrapping a tainted value in a call CodeQL does not model as a sanitizer
makes the flow visible where a bare slice was not tracked. Removing the text answers
both gates without arguing with either, and the census stays at 0 found / 0 expected.
The CLI strips terminal control sequences with
_TERMINAL_CTRL_RE, THEN redactscredentials and exfiltration URLs. The order is the whole correctness of this, and the
intuitive order is the unsafe one. An earlier revision redacted first, on the stated
reasoning that an escape inside a credential would break the regex if the controls went
first -- that was exactly backwards. Measured: with
AKIA<CSI>IOSFODNN7EXAMPLEstored,redact-then-strip prints
AKIAIOSFODNN7EXAMPLEverbatim, because the escape stops thecredential regex matching and the control-strip then REASSEMBLES the token;
strip-then-redact masks it. Stripping can only ever JOIN characters, never split a
token, so running it first can only help the regex. A test plants the pre-split
credential so a future reordering reddens -- the two single-treatment tests each show
one treatment happens and neither shows they compose in the safe order.
An earlier revision of this change was control-stripping only, on the grounds that
learn listprints every stored lesson to the same terminal with the same treatment.That was the wrong comparison and is reversed here:
learn listis an EXPLICIT requestto see the store, while this block surfaces a lesson the user did not ask for and is
about to lose. The right comparison is the route, which delivers the SAME field and does
redact -- so controls-only made one feature's two delivery paths disagree about whether
a superseded rule may carry a secret. A lesson written by history consolidation also
carries model output the user never typed, so "their own store" is not "their own
knowledge".
The recovery it advises is one the policy actually permits. Earlier wording said only
"re-add it with wording that does not overlap this one", which is incomplete in a way that
sends the user into a refusal: a VERBATIM re-add of the superseded rule is declined by the
substring branch, since the narrower rule now contains it. Measured, all three cases:
verbatim re-add ->
deduped/substring_covered, nothing restored; wording sharing fewsignificant words ->
inserted, both rules coexist, nothing superseded (so it does NOTping-pong); removing the narrower rule first -> the general rule inserts and is restored
verbatim. The text now names the two that work and says plainly that a verbatim re-add is
declined, and both are pinned by tests.
POST /api/lessonssends the array through_redact_memory_field, the shared chainthis handler already applies to the lesson's own rule and category. Redacting at the
route covers both readers, since the dashboard and the
learn_addtool each see onlywhat the route sends. This path is worse than a read: the row is being deleted, so this
response is the only place that text is echoed at all.
The log line this change adds identifies both rows by their md5 KEY, never by text.
A log is a persistent sink, so a credential in a lesson would sit in
gateway.logindefinitely; filtering it on the way out only narrows that, while logging keys removes
it. An operator can still tie the line to the
supersededentry in the result and tothe
delete_semanticaudit row, and the RESULT is the recovery channel -- it carriesthe full text, redacted at each surface.
An earlier revision instead wrapped three log sites in
redact_and_truncate, includingthe two pre-existing sibling lines. That is withdrawn and those two are byte-identical
to main again. It failed two gates at once, and both were right: this repo's own
ratchet (
test_security_posture.py::TestGateSideLogRedactorSpelling) requires agate-side log line to read
redact_log_via_contextrather than the companion-blindbaseline pass, and CodeQL raised three new
py/clear-text-loggingalerts becausewrapping a tainted value in a call it does not model as a sanitizer made the flow
visible where a bare slice was not tracked. Removing the text answers both without
arguing with either, and it leaves the pre-existing lines' behaviour untouched -- they
still log
rule[:60]raw, as on main, which the test asserts explicitly rather thanleaving implicit.
The CLI redacts credentials and exfiltration URLs, then strips terminal control
sequences with
_TERMINAL_CTRL_RE. Both, in that order: an escape sequence embeddedinside a credential would break the credential regex if the controls went first, so the
secret would escape redaction. Same two redactors, same order, this file already applies
to a verdict reason at
cli_commands.py:1893.An earlier revision of this change was control-stripping only, on the grounds that
learn listprints every stored lesson to the same terminal with the same treatment.That was the wrong comparison and is reversed here:
learn listis an EXPLICIT requestto see the store, while this block surfaces a lesson the user did not ask for and is
about to lose. The right comparison is the route, which delivers the SAME field and does
redact -- so controls-only made one feature's two delivery paths disagree about whether
a superseded rule may carry a secret. A lesson written by history consolidation also
carries model output the user never typed, so "their own store" is not "their own
knowledge".
POST /api/lessonssends the array through_redact_memory_field, the shared chainthis handler already applies to the lesson's own rule and category. Redacting at the
route covers both readers, since the dashboard and the
learn_addtool each see onlywhat the route sends. This path is worse than a read: the row is being deleted, so this
response is the only place that text is echoed at all.
Every lesson text this scan logs goes through
redact_and_truncate(already importedand used in this file), which redacts BEFORE slicing so a credential straddling 60
chars cannot leak as an unredacted fragment. A log is a persistent sink, so a raw
[:60]would keep a credential-bearing lesson ingateway.logindefinitely.Applied to all three lesson-text log sites in the scan, not only the one this change
added, and that widening is deliberate: the supersede path runs through the substring
AND topic-overlap branches, so a guarantee holding on one and not the other is worth
nothing. It is the same argument as populating
supersededat every delete site. Thetwo pre-existing sites logged raw text on main; the helper is an existing one, so no
mechanism is introduced.
Every path that carries a superseded rule now redacts credentials: the CLI, the route,
the
learn_addtool (via the route), and all three log lines. The audit is closed on thetext this change introduces.
The one thing deliberately left as it is on main is the
Saved:line's echo of the rulethe user just typed. It is their own input in the same breath -- masking a string they
literally just put on their own command line would tell them nothing and hide their own
command from them -- where a STORED rule may have been written by consolidation, an
import, or a subagent, and is printed when they are not looking at it.
Base. Rebased onto
origin/mainat6b7847856f6c2cb7926a768c3039ae1d6827a3ac, stated here so a red never costs anargument about whose it is. Only a push moves the base -- a re-run recomputes against the
base recorded in the original event -- so any inherited red older than this sha is not
this PR's.
main's own push-event CI was green onc791f0f1d(12:27:52Z), which this basecontains; the tip's own push CI had not reported when the rebase was taken.
The one CodeQL red is not this PR's, and here is why without re-deriving it.
py/weak-sensitive-data-hashingatsrc/kiro_crew/vector_memory.py:462, which ismain's own OPEN alert feat(issue-radar): open same-repo references in an in-app sheet #643 at line 445 -- this PR's+116net lines in that file are exactly what moves 445 to 462, and the diff adds zero hashing calls.52eb59f39(headd4f81c42bmerged intoorigin/mainb6716378a),git blameputs line 462 ond1aa30999(patrigao, "fix(lessons): attach a NOT-clause..."); this PR's commit appears nowhere in that blame.:2050) and Expose an agent-invokable app self-update action (MCP tool / API) for .app installs #503 (:3437) -- andCodeQLis not a required context here: the commit STATUS on this head issuccess. Clearing the alert would need security-events write, which no participant in this PR has.What tests we did
test/test_lesson_write_outcome.py, 10 new tests in two classes.Positive control. Run against pristine
origin/mainwith only the test file copiedin: 6 failed, 4 passed. Four fail with
AttributeError: 'LessonWriteResult' object has no attribute 'superseded', one withassert 'REMOVED 1 stored lesson' in 'Saved lesson: a rule'-- main's own words for awrite that removed a lesson -- and one on the route omitting the key. The 4 that pass are
deliberate characterization pins that must hold both ways:
test_the_general_rule_is_still_deleted-- asserts the supersede still happens, so alater "fix" cannot loosen containment while the reporting tests stay green.
test_the_refuse_direction_is_unchanged_and_deletes_nothing-- the other direction ofthe same test keeps declining and mutating nothing.
test_removing_only_the_substring_branch_would_not_have_saved_the_lesson-- computesthe overlap ratio from the store's own
_lesson_keywordsso it cannot drift from thearithmetic the branch performs.
test_the_tool_ignores_a_superseded_field_that_is_not_a_list_of_text-- the fieldcrosses HTTP; a malformed value must read as "none reported".
Security fixes carry their own positive control. Stashing only the two
srcchangesand re-running the same tests:
AssertionError: raw credential returned in a responseandAssertionError: the OSC payload itself must not survive. Both fail without their fix.Suites run (only files touching this path; never the full suite):
test_lesson_write_outcometest_lesson_contradictiontest_lesson_project_scopetest_api_input_validationtest_json_object_body_guard(244 passed) *test_vector_memorytest_vector_memory_coveragetest_onboarding_importtest_lesson_rankingtest_memory_smoketest_embedding_model_apply(762 passed,11 skipped) *
test_cli_commands_coverage -k "learn or lesson"(11 passed) *test_ephemeral_sessionstest_mcp_core_more_coveragetest_instance_credential_pairingtest_historytest_history_coverage(799 passed).1816 passed, 0 failed.
Gates: black gate (diff-scoped) * flake8 * isort * mypy (4 files) *
docs-lint.sh(261 files) -- all green.
Two pre-existing exact-body assertions on
POST /api/lessonswere updated for the addedkey; they are the only deletions in the test diff.
Any other suggestions on the work
Principles is right that
MemoryTab.tsxreceivessupersededand renders none of it,so the reported silence survives on that surface. It is deferred on two measured
grounds. First, the string is user-facing, and this repo translates through a formal
pipeline (
website/src/i18n/TRANSLATION-PROMPT.md: "the prompt is the pipeline", withper-locale style guides, a glossary, and CI-validated shards across 14 catalogs) --
hand-writing nine translations would bypass a documented process. Second,
website/has no installed
node_moduleson this machine, sotsc,vitestand the three i18ngates cannot run here, and
OverviewMemoryTabCov80.test.tsxmockscreateLessonandwould need updating. Shipping a frontend change I cannot verify into an otherwise
verified PR is the wrong trade. The route already sends the field, so the follow-up is
a self-contained UI change: response type, render, test.
delete_semanticrecords no reason, so a tombstonefrom this branch is indistinguishable from a
learn_remove. That is why thereporter's 291-tombstone figure cannot be attributed, and it stays true after this PR
-- the report reaches the caller in the moment, not the historical record. A reason at
tombstone time is worth having whichever way the policy questions are decided.
LessonStore._insert_or_enrichmatches on exact rule text plus scope and has no rule that supersedes, so the JSONL
store keeps both the general rule and the narrower one. The same two
learn_addcallsleave 2 lessons in JSONL and 1 in the vector store. Noted in the spec here; whether
they should agree is a policy question.
substring branch. But it aligns that branch with the policy under question, so if the
delete direction is ever withdrawn, both need deciding together.
learn list --deletedor an undo would turn this warning intosomething the user can act on directly.
Pattern harvest
Rule candidate: when a report says an operation is "silent", check every level
independently -- result value, log, and store -- and check whether the sibling branches in
the same loop announce themselves. Here three of four dedup branches logged and one did
not, and that asymmetry inside a single function separated the deliberate policy
(deleting) from the accident (not saying so), which decided what the fix had to be.
Rule candidate: before loosening a check to save data it destroys, excise the check and
measure. The collapse here was over-determined -- the next rule down deleted the same row
at 100% overlap -- so the tempting fix would have changed nothing a user could see while
costing the check its ability to say no.
Refs #7206