Skip to content

0.5.7: origin-aware retention (compactByOrigin + SymNode opts)#26

Merged
sym-bot merged 2 commits intomainfrom
feat/origin-aware-retention
May 2, 2026
Merged

0.5.7: origin-aware retention (compactByOrigin + SymNode opts)#26
sym-bot merged 2 commits intomainfrom
feat/origin-aware-retention

Conversation

@sym-bot
Copy link
Copy Markdown
Owner

@sym-bot sym-bot commented May 2, 2026

Summary

Adds optional discrimination between self-authored and peer-received CMBs at compaction time. Apps that benefit from retaining their own lineage chains longer than peer chatter (e.g. retrospective analysis of generation-CMB → outcome-CMB chains) configure split thresholds. Existing apps see no behavioral change.

API additions

  • MemoryStore.compactByOrigin(localFreshnessMs, peerFreshnessMs) — self entries (peerId == null) use localFreshness, peer entries use peerFreshness. Hot-descendant preservation rule unchanged (chains stay hot regardless of origin).
  • SymNode constructor opts localRetentionSeconds + peerRetentionSeconds. Each defaults to retentionSeconds when omitted.

Compatibility

  • MemoryStore.compact(freshnessMs) is now a back-compat shim that calls compactByOrigin(freshnessMs, freshnessMs). No behavioral change for callers that don't opt into origin-aware retention.
  • Existing SymNode instances with only retentionSeconds set behave identically to v0.5.6.
  • Log line in _runRetentionPurge keeps the single-value shape when local == peer; surfaces both values when they differ.

Test plan

  • node --test tests/memory-store.test.js — 18/18 pass
  • Shim equivalence: compactByOrigin(N, N) returns a number, same shape as legacy compact(N)
  • Origin discrimination: under split thresholds (local 120s, peer 30s), a 60s-old peer entry compacts to cold while a 60s-old self entry stays hot
  • Manual: spin up a SymNode with localRetentionSeconds: 7776000, peerRetentionSeconds: 2592000, write self + peer entries, observe hourly retention log shows both values

🤖 Generated with Claude Code

sym-bot and others added 2 commits May 2, 2026 07:01
Adds optional discrimination between self-authored and peer-received
CMBs at compaction time. Apps that benefit from retaining their own
lineage chains longer than peer chatter (e.g. retrospective analysis
of generation-CMB → outcome-CMB chains) configure split thresholds;
existing apps see no behavioral change.

MemoryStore:
  - new `compactByOrigin(localFreshnessMs, peerFreshnessMs)` —
    self entries (peerId == null) use localFreshness, peer entries
    use peerFreshness. Hot-descendant preservation rule unchanged
    (chains stay hot regardless of origin).
  - `compact(freshnessMs)` shimmed to call compactByOrigin with both
    values equal. Back-compat preserved; no behavior change for
    callers that don't opt in.

SymNode:
  - new constructor opts `localRetentionSeconds` + `peerRetentionSeconds`.
    Each defaults to `retentionSeconds` so existing apps unaffected.
  - `_runRetentionPurge` (run on start + hourly) uses the origin-
    aware path; log line surfaces both values when they differ,
    keeps single-value log shape when equal (existing log-grep
    tooling unaffected).

Tests:
  - shim equivalence: compactByOrigin(N, N) returns a number, same as
    legacy compact(N).
  - origin discrimination: under split thresholds (local 120s, peer
    30s), a 60s-old peer entry compacts to cold while a 60s-old self
    entry stays hot. Validates the discrimination is the cause, not
    coincidence.
  - 18/18 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
CMO PR #26 review notes:

N13: change `entry.peerId ? peerCutoff : localCutoff` to
  `entry.peerId != null ? peerCutoff : localCutoff`. Defensive
  against 0/''/false peerIds that shouldn't exist today but might
  via test fixtures or future relay edge cases. Matches the
  docstring's "peerId == null" wording exactly.

N15: one-line docstring add to compactByOrigin noting that lineage
  chains are preserved across origins — a peer entry whose self-
  descendant is still hot stays hot regardless of peerFreshnessMs.
  The hot-descendant rule transcends origin discrimination by
  design (lineage walks must remain intact at retention boundaries);
  saying so explicitly prevents readers from assuming "peer entries
  compact at peerCutoff" is absolute.

18/18 tests pass.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@sym-bot sym-bot merged commit 8513aea into main May 2, 2026
2 checks passed
@sym-bot sym-bot deleted the feat/origin-aware-retention branch May 2, 2026 06:05
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