feat: surface stale code_verified claims in graph context - #128
Open
divo12 wants to merge 2 commits into
Open
Conversation
Author
|
Hi @kushalpatil07 |
This was referenced Jul 28, 2026
Quarantine proven stale claims in graph context packets using stored anchor fingerprints, without changing ranking or writing to memory. Co-authored-by: Cursor <cursoragent@cursor.com>
Unify audit and graph-context stale detection on one pure helper so both paths use the same baseline comparison rule. Co-authored-by: Cursor <cursoragent@cursor.com>
divo12
force-pushed
the
feat/freshness-foreground-surface
branch
from
July 30, 2026 08:40
fea8308 to
6cbc9d4
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Builds on #111 anchor fingerprints. When an agent runs
greplica graph context, selectedcode_verifiedclaims are checked against their stored fingerprint baseline (same tree-sitter code signature captured at proposal apply time).Read-only: no auto-demote, no hook changes, no schema migrations. Ranking pipeline untouched.
System architecture
Where this sits in Greplica
flowchart TB subgraph writePath [Write path - unchanged] PROP[Proposal JSON] APPLY[applyProposal] FP_STORE[anchor_fingerprints on claims row] PROP --> APPLY --> FP_STORE end subgraph readPath [Read path - this PR] CLI["greplica graph context"] BUILD[GraphContextBuilder.build] RANK[BM25 + embeddings + graph boost + coherence] SEL[selectClaims - resolve anchors] STALE[attachStaleClaims - compare to baseline] PKT[selectGraphObjects + rankPacketResults] RENDER[renderGraphContextMarkdown] CLI --> BUILD --> RANK --> SEL --> STALE --> PKT --> RENDER end FP_STORE -. baseline read .-> STALE REPO[(Working tree)] -. re-hash survivors .-> STALEFreshness is a trust overlay on the existing retrieval packet. It does not change how claims are ranked or selected — only how proven-stale claims are labeled and surfaced in the final Markdown.
Graph context pipeline (before vs after)
flowchart LR subgraph before [Before] R1[rank] --> S1[selectClaims] --> O1[selectGraphObjects] --> P1[render] end subgraph after [After - this PR] R2[rank] --> S2[selectClaims] --> F2[attachStaleClaims] --> O2[selectGraphObjects] --> P2[render] endInsertion point: after
selectClaims, before packet assembly. Only the ~3–10 selected claims are checked, not the full graph.Per-claim freshness check
flowchart TD START[Selected claim] --> CV{code_verified with anchors?} CV -->|no| FRESH[No freshness field - Best Claims] CV -->|yes| BASE{anchor_fingerprints baseline?} BASE -->|no| FRESH BASE -->|yes| PART[Partition resolved anchors] PART --> ALL{All structurally broken?} ALL -->|yes| STRUCT[freshness: structural - no re-hash] ALL -->|no| HASH[fingerprintAnchor on survivors only] HASH --> CMP{classifyStale} CMP -->|hash differs| CONTENT[freshness: content] CMP -->|no proof| FRESH STRUCT --> QUAR[Needs re-verification] CONTENT --> QUARStructural =
missing_file,missing_symbol, orambiguous_symbolon every anchor.Content = at least one resolving anchor whose tree-sitter code signature hash differs from the baseline stored at apply time.
Fresh (no
freshnessfield) = baseline missing, hashes match, or staleness cannot be proven.Module boundaries
code-anchors/fingerprint.ts(#111)code-anchors/freshness.ts(new)classifyStale()— shared rule for future background demotegraph-context/claim-freshness.ts(new)graph-context/context-builder.tsattachStaleClaimsafterselectClaimsgraph-context/render.ts(stale)on supporting claim refsstorage/sqlite/repository.ts(#111)readClaimAnchorFingerprints()— one batched queryPacket output shape
Performance guards
code_verifiedclaimsCodeAnchorResolverper request (symbol cache reuse fromselectClaims)How it works
After claim selection (post-retrieval, not in BM25/semantic scores):
code_verifiedclaims and claims with noanchor_fingerprintsbaselineselectClaimsstructuralstale (no re-hash)## Needs re-verification; components/flows mark supporting claim ids as(stale)Files
libs/knowledge-graph/code-anchors/freshness.ts— pureclassifyStale()rulelibs/knowledge-graph/graph-context/claim-freshness.ts—attachStaleClaims()with early exitslibs/knowledge-graph/graph-context/context-builder.ts— wire-up afterselectClaimslibs/knowledge-graph/graph-context/render.ts— quarantine section + stale markersscripts/check-freshness-foreground.js— deterministic regression testTest plan
npx tsc --noEmitcleannpm testgreen (includes newcheck-freshness-foreground.js)return 3→return 8) → quarantined withcontentreasonstructuralreason, no hash worksource_verifiedclaim → skipped(stale)on related componentsNon-goals (follow-up PRs)
--invalidateclaim_supportscoring