fix: named serde default for supersedes_demotion#27
Conversation
#[serde(default)] on supersedes_demotion resolved to f32::default() = 0.0 instead of the intended 0.40. Users with partial config.toml files got no demotion applied to superseded memories. Adds default_supersedes_demotion() helper following the existing pattern (default_recency_weight, default_child_rescue_only, etc.) and wires it via #[serde(default = "default_supersedes_demotion")]. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Liorrr has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.
Liorrr
left a comment
There was a problem hiding this comment.
pr-review Summary
This PR fixes a serde deserialization bug for the supersedes_demotion field in EchoConfig. Previously, #[serde(default)] on an f32 field resolved to 0.0 (the type default) when the field was absent from a deserialized config (e.g., missing from config.toml). This silently gave users 0% supersession demotion instead of the intended 40%. The fix introduces a named serde default function default_supersedes_demotion() returning 0.40, correctly matching EchoConfig::default() at line 485.
The fix itself is mechanically correct and low-risk. One P2 out-of-diff finding is noted below.
Confidence Score: 4/5
No P1s. One P2 (stale documentation — not in this diff). The serde fix is correct. Mergeable; consider following up with a doc update.
Findings
| Sev | File | Line | Title |
|---|---|---|---|
| P2 | docs/ARCHITECTURE.md | 226, 757 | Stale doc claims supersedes_demotion default is 0.0 |
P2 — Stale doc claims supersedes_demotion default is 0.0
File: docs/ARCHITECTURE.md lines 226 and 757 (not in this diff — follow-up recommended)
The architecture doc states:
The older (superseded) memory receives a configurable demotion (supersedes_demotion, default 0.0).
And the example config block at line 757:
supersedes_demotion = 0.0 # score penalty for superseded memoriesBut the true runtime default has been 0.40 since KS78 (EchoConfig::default() line 485 and the new default_supersedes_demotion() function both return 0.40). A user reading the docs and omitting supersedes_demotion from their config.toml will expect no demotion (0.0) but get 40% demotion — a silent, significant behavioral difference.
Suggested follow-up fix in docs/ARCHITECTURE.md:
Line 226:
- The older (superseded) memory receives a configurable demotion (`supersedes_demotion`, default 0.40).
Line 757:
supersedes_demotion = 0.40 # score penalty for superseded memoriesChanged Files
| File | Notes |
|---|---|
crates/shrimpk-core/src/config.rs |
Fix correct — named serde default matches EchoConfig::default() |
Liorrr
left a comment
There was a problem hiding this comment.
pr-review Summary
This PR fixes a P1 serde default bug introduced in the previous commit (KS78 #11): the field on was decorated with , which resolves to = , silently disabling the entire multiplicative supersession demotion feature for any user whose omits the field.
The fix is correct and complete: a named default function returning is added and wired up via . The block already had (line 485) — the struct default and serde default are now consistent. The layer uses so it is unaffected. Both temporal and standard code paths in read and benefit from the corrected default. The update aligns the documentation to match.
No new issues introduced. No parallel code paths missed.
Confidence Score: 5/5
No findings — the fix resolves the P1 completely and no regressions are introduced. Recommend merge.
Summary
#[serde(default)]onsupersedes_demotionresolved tof32::default() = 0.0instead of the intended0.40config.tomlfiles got zero demotion applied to superseded memoriesdefault_supersedes_demotion()helper following the existing pattern (default_recency_weight,default_child_rescue_only, etc.)Test plan
cargo clippy -p shrimpk-core -- -D warningspasses (0 warnings)cargo test -p shrimpk-corepasses (91/91)cargo check --workspacepasses🤖 Generated with Claude Code