Skip to content

feat(pipeline): audit background failures, cascade deletes and react to memory relations - #1640

Open
rohitg00 wants to merge 15 commits into
feat/iii025-s2a-observer-pipelinefrom
feat/iii025-s2b-cascade-audit
Open

rohitg00 wants to merge 15 commits into
feat/iii025-s2a-observer-pipelinefrom
feat/iii025-s2b-cascade-audit

Conversation

@rohitg00

Copy link
Copy Markdown
Owner

Summary

Stage 2b of the iii 0.25 stack. It targets #1639 (then #1637, #1636 and #1634). Everything here runs through observers when observe bindings are active; with AGENTMEMORY_BINDINGS=trigger none of it is bound and behavior is unchanged.

  • Failure audit (feat(audit): consolidation/extract failures as first-class audit events with retry-with-backoff #766): observers on mem::compress, mem::summarize, mem::graph-extract, mem::consolidate-pipeline, mem::reflect and mem::skill-extract route thrown errors and soft failures (output.success == false) to mem::record-failure. Each failure becomes a *-failed audit row with its code, a 300-character message, target ids and retryable (timeouts, connection errors, open breaker, 429/5xx, compression_failed). Identical (function, code) failures inside a fixed 60 s window collapse into one row; the next row carries dedupedCount. mem::status gains failures: { transient, permanent, lastAt }, which counts every failure. The observer metadata carries source_fn, so rows name the function that failed, not the observer.
  • Delete cascade (Facet tags survive lesson deletes and observation forgets (follow-up to #1591) #1624, Observation eviction leaves session counters and graph provenance stale #1157 counters): a state::on-changed observer on deletes in mem:obs:*, mem:memories, mem:lessons and lesson soft-deletes removes BM25 and vector entries at once. Facet cleanup and session observationCount reconciliation are batched: one flush per 500 ms or 200 ids, single-flight, retried after a failed flush. Deleting 300 observations wrote 2 cascade audit rows, not 300 full scans.
  • Relation reactions (feat(graph): state trigger auto-stales targets on supersedes/contradicts/extends edges #768): supersedes, contradicts and extends relations update their target memory. Reactions are tracked per (target, type) in mem:relation-reactions, with the set of contributing relations:
    • supersedes marks the target non-latest and halves its strength once; later supersedes only join.
    • contradicts decays confidence cumulatively, with a 0.05 floor.
    • extends links the source into relatedIds.
    • Deleting a relation undoes the reaction only when no relation of that type still points at the target; the original values are restored.
    • Replays are idempotent. A supersedes cycle is skipped and audited, while mutual contradicts is allowed.
  • mem::relate: writes to relatedIds now take the per-memory lock and re-read the row, so they no longer overwrite a concurrent reaction. The lock is reentrant for self-relations.
  • Replace import (import "replace" wipes KV but leaves search indices stale #938, keyword index): a single-flight BM25 rebuild runs after a replace import. The vector index is not rebuilt here.

Live verification (engine 0.25.0, state 0.22.22, http 0.22.8, fake OpenAI-compatible server)

check result
compress against an LLM returning HTTP 500 compress-failed row, functionId: mem::compress, code: compression_failed, retryable: true; 8 failures → 1 row; status counters move
two supersedes on one memory, then delete each isLatest:false, strength 7 → 3.5; after first delete unchanged (1 contributor left); after second delete true / 7 restored and mark removed
300 observation deletes in one session 2 cascade flushes (200 + 100); observationCount equals the real key count
self-relation through REST, then a second relate on that memory both 201, no lock wait
gate:large-store --small --assert pass

Not covered

Test plan

  • npm run build, npm run skills:gen, npm run docs:sync, npm run skills:check
  • npm test: 4159 passed, 6 skipped
  • test/cascade-audit.test.ts: failure classification and fixed-window dedupe, multi-relation undo, cumulative contradicts with floor, mutual contradicts, supersedes cycle, extends undo, idempotent replay, delete batching (one facet read, one key listing per session), flush failure without unhandled rejection, items queued mid-flush, self-relation lock
  • Live checks in the table above

Fixes #1624. Refs #766 #768 #938 #1157.

@vercel

vercel Bot commented Oct 29, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
agentmemory Ready Ready Preview Nov 8, 2026 3:55pm UTC

Request Review

@coderabbitai

coderabbitai Bot commented Oct 29, 2026 •

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 5f0ea9d2-d654-4d8e-83ad-3590afa279ae

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • Trigger review
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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

devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

…audit

CHANGELOG follows the base branch; release PRs carry the entry.
…radiction floor

- Delete facets for a flushed batch with one scan per target type
  instead of one full facet scan per deleted record.
- Requeue a delete whose target read failed, so its facets are cleaned
  up on the next flush instead of being dropped.
- Track each contradiction's raw penalty against a base confidence and
  apply the change in the floored value, so undoing one contradiction
  does not lift confidence while another still holds it at the floor.
- Cover search and vector restoration on the final supersedes undo.
devin-ai-integration[bot]

This comment was marked as resolved.

… finite

- Re-add an un-superseded memory to the vector index with its session,
  embed text and memory context; the previous two-argument call never
  embedded it.
- Treat a memory without a stored confidence as 1 in the contradicts
  reaction, so the stored value never becomes NaN, and type the field.
- Rebuild the keyword index after a replace import from the store passed
  to the handler; the previous closure referenced an undefined name.
devin-ai-integration[bot]

This comment was marked as resolved.

A contradiction on a memory with no stored confidence started from 1, so
the stored value could rise above the type salience and promote a
contradicted fact in retention. Start from 0.5, the default salience.

This branch was successfully deployed

1 active deployment
Preview — 574f57fc Deployed Nov 8, 2026 by vercel[bot]
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