Skip to content

fix: named serde default for supersedes_demotion#27

Merged
Liorrr merged 2 commits into
masterfrom
fix/ks78-serde-default
Jun 13, 2026
Merged

fix: named serde default for supersedes_demotion#27
Liorrr merged 2 commits into
masterfrom
fix/ks78-serde-default

Conversation

@Liorrr

@Liorrr Liorrr commented Apr 10, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Greptile P1 from PR KS78: Relative supersession demotion — multiplicative 0.40 (#11) #22: #[serde(default)] on supersedes_demotion resolved to f32::default() = 0.0 instead of the intended 0.40
  • Users with partial config.toml files got zero demotion applied to superseded memories
  • Adds default_supersedes_demotion() helper following the existing pattern (default_recency_weight, default_child_rescue_only, etc.)

Test plan

  • cargo clippy -p shrimpk-core -- -D warnings passes (0 warnings)
  • cargo test -p shrimpk-core passes (91/91)
  • cargo check --workspace passes

🤖 Generated with Claude Code

#[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>

@greptile-apps greptile-apps Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Liorrr has reached the 50-review limit for trial accounts. To continue receiving code reviews, upgrade your plan.

@Liorrr Liorrr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 memories

But 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 memories

Changed Files

File Notes
crates/shrimpk-core/src/config.rs Fix correct — named serde default matches EchoConfig::default()

@Liorrr Liorrr left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@Liorrr
Liorrr merged commit 25616ac into master Jun 13, 2026
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant