research(agent-memory): structural-time-gated compaction for bursty-idle workloads - #943
Draft
ruvnet wants to merge 4 commits into
Draft
research(agent-memory): structural-time-gated compaction for bursty-idle workloads#943ruvnet wants to merge 4 commits into
ruvnet wants to merge 4 commits into
Conversation
Add StructuralTimePolicy and GatedStructuralTimePolicy, two new CompactionPolicy variants that replace CoherencePolicy's wall-clock recency term with emergent-time's Structural Proper Time (embedding arc length), which contributes zero internal time during an idle gap with no writes. Additive only: CoherencePolicy and its default behavior are unchanged. Also adds MemoryStore::advance_clock() to let callers model an idle period explicitly, and a path dependency on the (dependency-free) emergent-time crate. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01M5e9casHjBrBgkXWkmGWtb
…mark Nightly benchmark comparing LRU / CoherenceWeighted (baseline) / StructuralTime / GatedStructuralTime on a synthetic bursty-idle workload (a long idle gap between two topic-disjoint writing bursts) versus a steady control workload. Includes embedded acceptance tests and an 8-seed robustness test (cargo test -p ruvector-agent-memory --example temporal_compaction_bench), plus an FNV-1a witness seal over the run's parameters and results. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01M5e9casHjBrBgkXWkmGWtb
README (full methodology, raw benchmark evidence, disclosed dataset iteration, ecosystem/RVF/RVM/ruFlo/MCP analysis, practical and long-horizon applications), a standalone gist, and the raw benchmark output committed as evidence. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01M5e9casHjBrBgkXWkmGWtb
Records the decision, evidence, alternatives considered (EntropyClock and WindowedDeltaClock, both rejected for lacking an honest per-entry input in this crate), and open questions (chiefly: validate against real agent traces before considering default-on promotion). Regenerates docs/adr/INDEX.md via scripts/adr-index.mjs. Co-Authored-By: claude-flow <ruv@ruv.net> Claude-Session: https://claude.ai/code/session_01M5e9casHjBrBgkXWkmGWtb
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
ruvector-agent-memory::CoherencePolicyscores memory-compaction retention with a recency term based onlast_accessed_at— a wall/step clock. This run tests whether swapping that recency signal foremergent-time's Structural Proper Time (internal time driven by embedding movement, not wall-clock ticks) improves retention for agents whose activity is bursty: dense writing sessions separated by long idle gaps (waiting on a human, a slow tool call, an overnight pause).Result: ACCEPT. On a synthetic bursty-idle workload, wall-clock
CoherenceWeightedretains 27.2% of held-out relevant memories after compaction; the newStructuralTimepolicy retains 59.0% (+31.8pp) — while on a matched steady-activity control workload the two are statistically identical (59.0% vs 59.0%, +0.0pp). Direction reproduces across 8 independent seeds.Connects 4 existing RuVector pieces (agent memory,
emergent-time, vector coherence scoring, witness/provenance hashing) with zero new algorithms and zero new transitive dependencies —emergent-timeis itself dependency-free.Hypothesis (pre-registered)
What changed
crates/ruvector-agent-memory/src/temporal_compaction.rs(new) —StructuralTimePolicy(candidate A) andGatedStructuralTimePolicy(candidate B), both additiveCompactionPolicyimplementations.CoherencePolicy's default behavior is untouched.crates/ruvector-agent-memory/src/memory.rs— addsMemoryStore::advance_clock()to model an idle period.crates/ruvector-agent-memory/examples/temporal_compaction_bench.rs(new) — the benchmark, with embedded acceptance tests + an 8-seed robustness test.Cargo.toml— one new path dependency:emergent-time(already in-workspace, dependency-free).docs/adr/ADR-340-structural-time-memory-compaction.md,docs/research/nightly/2026-08-29-structural-time-memory-compaction/{README,gist}.md+ raw benchmark evidence.Benchmark command
Real benchmark results
Acceptance: [A] +31.8pp ≥ 3.0pp → PASS. [B] same → PASS. [C] steady regression +0.0pp, tolerance −1.0pp → PASS. Verdict: ACCEPT.
Witness (FNV-1a over seed+params+rounded recall, reusing
emergent_time::witness::fnv1a64— no new hash):e0d3b9cf5b37176e, reproduced byte-for-byte across every run used for this report.Robustness:
structural_time_wins_across_multiple_seedsre-checks the direction of the effect across 8 independent seeds (1,2,3,4,5,340,7777,99991) — all pass.Honest disclosures (see README "Reading the numbers honestly")
GatedStructuralTimePolicyadds nothing measurable on this dataset — identical toStructuralTimePolicyin both workloads. The jitter gate never binds at the tested noise level. Reported as a neutral finding, not hidden.LruPolicyalso beatsCoherenceWeightedon the bursty-idle workload (66.7% vs 27.2%). Not the paper's claim (not a like-for-like comparison), but disclosed because it shows the coherence term — when its context window is realistically unrelated to what's later queried — actively degrades an otherwise-cleaner recency cutoff under the idle gap, whichStructuralTime(same coherence formula) does not.insert(), which silently discarded idle-gap timestamps) was also caught and fixed before any acceptance number was recorded.Limitations (explicitly not claimed)
Synthetic dataset only (no real agent trace), one gap magnitude, one two-phase topic-disjoint dataset shape, only the embedding channel of
StructuralMetricis honestly populated (no entropy/graph/prediction-error signal available in this crate), and candidate B is not validated as beneficial. See the ADR's "Rejection Criteria" and README "Failure modes" for the full list.Security review
Pure scoring-function change inside an existing, already-gated
compact()call. No new external input, no new authority, no new serialization format, no reward-hack surface (ground truth and dataset generator are fixed before any policy result is computed; acceptance thresholds are constants the candidate policies cannot see or influence).Production recommendation
Not proposed for default-on promotion from this single run. Ships as an additional, independently-selectable
CompactionPolicybehind no feature flag — adoptable incrementally with zero migration cost. Recommended before any real-deployment use: validate against a corpus of real agent-memory traces (this crate's ownledger/observationmodules could source one).MetaHarness / Flywheel / Darwin status
Checked, not assumed:
npx metaharness --helpresolves (a project-scaffolding CLI, not an in-repo research daemon; not applicable to a single bounded hypothesis like this one).npx ruvector harness doctor/flywheel/darwin --json— no such CLI exists in this repository; no such tool call is fabricated in the report. Evidence retention, evolutionary search, and promotion gating were performed directly and are documented in the ADR/README instead.Generated by Claude Code