Repository navigation
memory: entry provenance and per-agent trust scores (#309) - #329
Merged
currentbits merged 3 commits intoAug 17, 2026
Merged
Conversation
added 3 commits
August 17, 2026 18:19
Aggregate helpful/harmful/invalidated evidence per writer, multiply the cached factor into BASE_SCORE_SQL, and flag suspect agents in the maintenance report. NULL writers stay at 1.0 so existing ranks do not move. No new review_queue kind (CHECK constraint; a report row is enough).
Write agent+source on store/supersede, return them on every read that already carried agent, and let memory_search filter by writer. REST defaults source to rest; MCP defaults to mcp.
…nance-and-per-agent-trust-sc-c75041
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/memory-provenance-and-per-agent-trust-sc-c75041
branch
October 3, 2026 16:07
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.
Closes #309.
Why
The
entries.agentcolumn was written on every store and then never read — not as a filter, not as a ranking signal. That left two questions unanswerable: who wrote this memory and should I believe them. Without the second one, a single agent that keeps writing wrong memories quietly outranks the agents writing right ones (the memory-poisoning case in OWASP ASI06).What changed
Provenance. New
entries.sourcecolumn recording the write surface.agentandsourceare persisted bystore()andsupersede(), accepted at both the MCP and REST write surfaces (defaulting tomcp/restrespectively), and returned on every read path — FTS, graph, vector, the fused re-score,get(),recent()andbootstrap().memory_searchandGET /api/searchnow take an optionalagentfilter, so "show me what this agent wrote" is finally answerable.Trust.
agentTrust(db)rolls up each writer's helpful / harmful / invalidated evidence in one grouped query.trustFactor()turns that into a multiplier clamped to[0.5, 1.5], weighting a wrong memory heavier than a right one earns. The factor is exposed to SQLite asagent_trust(agent)and multiplied intoBASE_SCORE_SQL.Two constraints the implementation holds to:
Memoryinstance, not re-run per row. A feedback verdict drops the cache (that is the evidence that actually moves the number); a 5s TTL covers invalidation and raw SQL writes that bypassfeedback().agent_trust(NULL)returns exactly1.0, so the many existing entries with no recorded writer score precisely as they do today. There is a test asserting the two score expressions are equal for a NULL-agent row.Operator surface.
memory_maintenancegains atrustsection listing every writer's evidence and flagging those belowTRUST_SUSPECT(0.8).Notes
Trust is derived, never stored — nothing new is written to
entries, and the number recomputes from the evidence at hand.Low-trust entries are surfaced in the maintenance report rather than enqueued into
review_queue.review_queue.kindcarries aCHECKconstraint that a new kind would require migrating, and a report row costs nothing; worth revisiting if the report proves too passive in practice.The governance UI (#299) still needs to consume the new
agent/source/trustfields — this PR only makes them available.Testing
cd memory-server && node --test test/*.test.js→ 138/138 pass. New coverage: provenance round-trips through store/supersede/get/search, theagentfilter actually excludes other writers, REST surfaces carry both fields,agentTrustaggregation and fail-soft behaviour, NULL-agent rank invariance, cache-refresh-on-feedback, and a poisoned writer ranking below a clean one for identical text.