Skip to content

fix(salience): exclude retired claims from the reflex#519

Open
jeffrey701 wants to merge 2 commits into
vouchdev:testfrom
jeffrey701:fix/salience-exclude-retired-claims
Open

fix(salience): exclude retired claims from the reflex#519
jeffrey701 wants to merge 2 commits into
vouchdev:testfrom
jeffrey701:fix/salience-exclude-retired-claims

Conversation

@jeffrey701

@jeffrey701 jeffrey701 commented Jul 17, 2026

Copy link
Copy Markdown

What changed

compute_salience now skips claims whose status is superseded,
archived or redacted when it builds the per-entity claim list, so
_meta.vouch_salience counts live evidence only. the exclusion set is a
module-level frozenset, matching how graph, digest, health and
experts each declare it.

Why

the salience reflex was the one read surface that never got the
retired-claim filter. every other one applies it — context.py,
graph.py, digest.py, health.py, compile.py, and experts.py,
which spells the invariant out: "a superseded / archived / redacted
claim is not live evidence and must never inflate an entity ranking".
compute_salience walked store.list_claims() with no status check at
all.

two things went wrong as a result. an entity's claim_count counted
retracted claims, so the number disagreed with every other surface. and
top_claim_id is just the lowest-sorting claim id, so a retired claim
could take the top slot and hand an agent a pointer to knowledge the
reviewer had already pulled — including a redacted claim, the one
status that exists precisely because the text was masked.

this is #78 on the surface it missed: that issue closed the
archived/superseded leak in kb.context, and the same exclusion was
carried to the other read paths, but the salience sidebar was skipped.

What might break

nothing on disk: no file moves, no field changes shape, and no kb.*
method changes signature — this is a surface change to values, not to
shape. for a kb that has retired claims, an entity's claim_count in
_meta.vouch_salience will drop and its top_claim_id may move to a
live claim. that is the fix. a kb with no retired claims is byte-identical.

VEP

not a surface change — no method, model, on-disk layout, bundle or
audit-log shape is touched.

Tests

  • New / changed behaviour has a test
  • CHANGELOG.md updated under ## [Unreleased]
  • make check passes locally (lint + mypy + pytest) — see below

tests/test_salience.py::test_retired_claims_are_not_salient is
parametrized over all three retired statuses and fails on the previous
code. the fixture's live claim is c1, the retired one c0, so on the
old code the retired claim both inflates claim_count (2 != 1) and wins
top_claim_id.

what i ran, and honestly what i could not:

  • ruff check src tests — clean.
  • mypy src — clean apart from two pre-existing errors this branch
    doesn't touch (sandbox.py:112, os.getuid / os.getgid don't exist
    on windows; they resolve on linux ci).
  • pytest tests/test_salience.py plus every module that consumes
    salience — hooks, trust, openclaw_context_engine, experts,
    sessions, themes, triage — all pass.

i'm on windows and the full suite wedges locally on an unrelated test, so
i leaned on ci for the whole matrix rather than claim a green make check
i didn't see.

Summary by CodeRabbit

  • Bug Fixes
    • Updated entity salience reporting so it counts only live claims.
    • Excluded superseded, archived, and redacted claims from claim_count and top_claim_id, preventing recommendations to retired content.
  • Documentation
    • Updated the changelog entry to reflect the corrected entity-salience behavior.
  • Tests
    • Added coverage ensuring retired claims are not included in salience reporting.

the entity-salience reflex counted every claim referencing a matched
entity, skipping the retired-claim exclusion that context, graph,
digest, health and experts all apply. a superseded, archived or
redacted claim therefore inflated an entity's claim_count and could be
handed back as its top_claim_id, pointing an agent at knowledge the
reviewer had already retracted.

vouchdev#78 closed this leak on the context path and the same exclusion was
carried to the other read surfaces; the salience sidebar was missed.
compute_salience now skips retired claims, so _meta.vouch_salience
reports live evidence only.

the regression test covers all three retired statuses. it fails on the
previous code: the retired claim sorts ahead of the live one, so it
both inflates claim_count and takes top_claim_id.
@github-actions github-actions Bot added docs documentation, specs, examples, and repo guidance retrieval context, search, synthesis, and evaluation tests tests and fixtures size: XS less than 50 changed non-doc lines labels Jul 17, 2026
@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: a625f60e-e4b4-4c2a-aa9d-d7bddfb7a7e0

📥 Commits

Reviewing files that changed from the base of the PR and between 8c380bb and e103760.

📒 Files selected for processing (1)
  • src/vouch/salience.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/vouch/salience.py

Walkthrough

Entity salience excludes superseded, archived, and redacted claims from claim_count and top_claim_id. Parametrized tests cover each retired status, and the changelog documents the correction.

Changes

Entity salience filtering

Layer / File(s) Summary
Retired claim filtering and regression coverage
src/vouch/salience.py, tests/test_salience.py, CHANGELOG.md
Defines retired claim statuses, skips them during salience computation, verifies all three statuses, and documents the fix.

Estimated code review effort: 2 (Simple) | ~10 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately captures the main change: excluding retired claims from salience calculation.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/vouch/salience.py`:
- Around line 38-41: Update the comment near the live-evidence claim filtering
logic to begin with lowercase prose by changing its opening “A” to lowercase;
leave the remaining explanation and behavior unchanged.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 3e331abf-9c82-4076-b5ac-8d8c9bfc59ab

📥 Commits

Reviewing files that changed from the base of the PR and between 74abc8e and 8c380bb.

📒 Files selected for processing (3)
  • CHANGELOG.md
  • src/vouch/salience.py
  • tests/test_salience.py

Comment thread src/vouch/salience.py Outdated
house style is lowercase prose in comments; the new frozenset comment
opened with a capital. no behaviour change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs documentation, specs, examples, and repo guidance retrieval context, search, synthesis, and evaluation size: XS less than 50 changed non-doc lines tests tests and fixtures

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants