Skip to content

Add Shared-Memory Governance Benchmark (SMGB): dataset + evaluation#32

Closed
mrrahman1517 wants to merge 1 commit into
mainfrom
feature/shared-memory-governance-benchmark
Closed

Add Shared-Memory Governance Benchmark (SMGB): dataset + evaluation#32
mrrahman1517 wants to merge 1 commit into
mainfrom
feature/shared-memory-governance-benchmark

Conversation

@mrrahman1517

@mrrahman1517 mrrahman1517 commented Jul 15, 2026

Copy link
Copy Markdown
Collaborator

What & why

Single-user memory benchmarks (LongMemEval, LoCoMo, DMR — the ones in PR #31) only score recall. They can't tell a governed shared-memory system from a naive one. This PR adds the Shared-Memory Governance Benchmark (SMGB): a public, system-agnostic benchmark for the governance of shared agent memory.

The one-table argument

Reference runners on the seed set (python -m benchmarks.governance.run_governance --reference):

system        queries mean_recall leak_rate total_leaks isolation_violations stale_leaks
-----------------------------------------------------------------------------------------
oracle        14      1.000       0.000     0           0                    0
naive_shared  14      1.000       0.500     13          0                    1
naive_global  14      1.000       0.643     15          2                    1

All three baselines score mean_recall = 1.000 — a recall-only benchmark would rate them identical. Only the leakage / isolation / stale-propagation axes reveal that naive_shared leaks 13 facts and naive_global also breaches tenant isolation. Recall alone cannot distinguish governed memory from naive; SMGB can.

Design highlights

  • No LLM judge. Ground truth is derived deterministically from a scope + policy graph, so scoring is reproducible and free. (PiSAs 2607.05318 is LLM-judged; ArgusFleet 2606.24535 is proprietary — SMGB removes both blockers.)
  • System-agnostic. A "run" is just {query_id: [ranked memory_ids]}. Any memory system can be scored; no SDK or network needed.
  • Self-checking data. The loader validates every hand annotation against the policy-derived labels and rejects mismatches, so dataset authoring bugs can't slip in.
  • Time is first-class. Every query has an as_of; promotion / supersession / deletion are timeline events. The same question before vs after a promotion has different correct answers.

Seven axes

utility, leakage, isolation, promotion, conflict (supersession), deletion, provenance.

What's included

  • benchmarks/governance/schema.py, policy.py (deterministic core), scorer.py, loader.py, run_governance.py (CLI), package README.md.
  • benchmarks/governance/data/seed_scenarios.jsonl — 6 scenarios / 14 queries covering all axes (incl. the two private->shared promotion cases from the whiteboard), reproducible via _generate_seed.py.
  • benchmarks/tests/test_governance_{policy,scorer,seed}.py — 16 tests.
  • Docs/shared_memory_governance_benchmark.md — formal design + verified gap analysis, for team circulation.

Verification

  • python -m pytest benchmarks/tests -q -> 16 governance tests pass
  • ruff check benchmarks/governance -> clean
  • CLI --reference, --validate-only, --json-out all verified

Scope

Self-contained and based directly on main (introduces the benchmarks/ package scaffold). A companion multi-agent consistency harness — durability/staleness of shared writes under concurrency, per Golab et al. — is tracked separately and can land later; this PR does not depend on it.

Open questions for review

Scenario coverage priorities, scope taxonomy, whether to ship the live Cosmos adapter in v1, provenance-chain depth, and public naming — see the "Open questions" section of the design doc.

…et + evaluation

Single-user memory benchmarks (LongMemEval, LoCoMo, DMR) only score recall and
cannot tell a governed shared-memory system from a naive one. SMGB adds a public,
system-agnostic benchmark for the governance of shared agent memory:
authorization-filtered retrieval, private->shared promotion, tenant isolation,
conflict/supersession, scope-aware deletion, and provenance.

Ground truth is derived deterministically from a scope + policy graph (no LLM
judge), so scoring is reproducible and free. A run is just {query_id: [ranked
ids]}, so any memory system can be scored.

- benchmarks/governance/: schema, deterministic policy, system-agnostic scorer,
  loader with hand-label validation, and a CLI (run_governance.py).
- data/seed_scenarios.jsonl: 6 scenarios / 14 queries across all 7 axes,
  including two private->shared promotion cases, tenant isolation, supersession,
  deletion, and provenance. Reproducible via data/_generate_seed.py.
- Reference runners (oracle / naive_shared / naive_global) demonstrate the point:
  all three score mean_recall 1.000, but only the leakage/isolation/stale axes
  separate them (naive_shared: 13 leaks; naive_global: 2 isolation violations).
- benchmarks/tests/test_governance_{policy,scorer,seed}.py: 16 tests.
- Docs/shared_memory_governance_benchmark.md: formal design + verified gap
  analysis (PiSAs 2607.05318, ArgusFleet 2606.24535).

Self-contained: introduces the benchmarks/ package scaffold. A companion
multi-agent consistency harness is tracked separately.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@mrrahman1517 mrrahman1517 force-pushed the feature/shared-memory-governance-benchmark branch from f3040e3 to 813d691 Compare July 15, 2026 01:20
@mrrahman1517 mrrahman1517 changed the base branch from feature/multi-agent-shared-memory to main July 15, 2026 01:20

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds the Shared-Memory Governance Benchmark (SMGB) to evaluate governed shared-memory systems on governance failure modes (leakage, tenant isolation, promotion timing, supersession/staleness, deletion, provenance) that recall-only single-user benchmarks cannot detect.

Changes:

  • Introduces benchmarks/governance/ with a deterministic policy layer, system-agnostic scorer, dataset loader/validator, and CLI runner.
  • Adds a checked-in SMGB seed dataset (seed_scenarios.jsonl) plus a reproducible generator script.
  • Adds unit + dataset integrity tests and documentation (design doc + package README), and links the design doc from Docs/README.md.

Reviewed changes

Copilot reviewed 15 out of 16 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
Docs/shared_memory_governance_benchmark.md Adds the formal SMGB design, gap analysis, axes, and reference-benchmark motivation.
Docs/README.md Links the SMGB design doc under “Research & Benchmarks”.
benchmarks/init.py Adds a top-level benchmarks package marker.
benchmarks/governance/init.py Exposes the SMGB public API (loader/policy/scorer/schema + reference runners).
benchmarks/governance/README.md Documents SMGB purpose, quick start, axes, scoring model, and dataset format.
benchmarks/governance/schema.py Defines dependency-free dataclasses + parsing/constants for scenarios/queries/memories/events.
benchmarks/governance/policy.py Implements deterministic authorization/currentness labeling from scope + timeline.
benchmarks/governance/scorer.py Implements system-agnostic scoring + reference runners and report aggregation.
benchmarks/governance/loader.py Loads JSONL scenarios and validates referential integrity + hand labels vs policy.
benchmarks/governance/run_governance.py Adds CLI for validation, reference runner scoring, and external run scoring.
benchmarks/governance/data/seed_scenarios.jsonl Adds the seed dataset (6 scenarios / 14 queries) covering all axes.
benchmarks/governance/data/_generate_seed.py Provides a reproducible generator for the committed seed dataset.
benchmarks/tests/init.py Test package marker.
benchmarks/tests/test_governance_policy.py Adds unit tests for promotion, isolation, supersession/history, deletion, label complements.
benchmarks/tests/test_governance_scorer.py Adds unit tests for scorer discrimination, abstention semantics, k cutoff behavior.
benchmarks/tests/test_governance_seed.py Adds integrity tests for the checked-in seed dataset and reference baseline discrimination.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +177 to +188
"""Fraction of retrieved targets whose claimed author matches ground truth."""
targets = labels.must_retrieve & retrieved_set
if not targets:
return 0, len(labels.must_retrieve)
claims = (provenance or {}).get(query.id, {})
correct = 0
for mem_id in targets:
gold_author = scenario.memories[mem_id].provenance.author
claimed = claims.get(mem_id, {}).get("author")
if claimed is not None and claimed == gold_author:
correct += 1
return correct, len(labels.must_retrieve)
Comment on lines +204 to +210
def oracle_run(scenario: Scenario, k: int = 10) -> Run:
"""Perfect system: return exactly the authorized-and-relevant target set."""
run: Run = {}
for query in scenario.queries:
labels = compute_query_labels(scenario, query)
run[query.id] = list(labels.must_retrieve)[:k]
return run
Comment on lines +213 to +222
def oracle_provenance(scenario: Scenario) -> ProvenanceClaims:
"""Gold provenance claims matching :func:`oracle_run` (all authors correct)."""
claims: ProvenanceClaims = {}
for query in scenario.queries:
labels = compute_query_labels(scenario, query)
claims[query.id] = {
mem_id: {"author": scenario.memories[mem_id].provenance.author}
for mem_id in labels.must_retrieve
}
return claims
Comment on lines +223 to +240
def from_dict(d: dict[str, Any]) -> "Query":
axis = d.get("axis", "utility")
if axis not in QUERY_AXES:
raise ValueError(f"unknown query axis {axis!r}; expected {sorted(QUERY_AXES)}")
mr = d.get("must_retrieve")
mnr = d.get("must_not_retrieve")
return Query(
id=d["id"],
principal=d["principal"],
as_of=parse_time(d["as_of"]),
axis=axis,
question=d.get("question", ""),
relevant=tuple(d.get("relevant", ()) or ()),
temporal_mode=d.get("temporal_mode", "current"),
expected_answer=d.get("expected_answer"),
must_retrieve=tuple(mr) if mr is not None else None,
must_not_retrieve=tuple(mnr) if mnr is not None else None,
)
Comment on lines +62 to +66
for scope_id in principal.scopes:
if scope_id not in scenario.scopes:
problems.append(
f"{sid}: principal {principal.id!r} references unknown scope {scope_id!r}"
)
Comment on lines +68 to +72
for mem in scenario.memories.values():
if mem.scope not in scenario.scopes:
problems.append(f"{sid}: memory {mem.id!r} initial scope {mem.scope!r} unknown")
if mem.tenant not in scenario.tenants:
problems.append(f"{sid}: memory {mem.id!r} tenant {mem.tenant!r} not in tenants")
Comment on lines +77 to +78
if ev.type == "promote" and (not ev.to_scope or ev.to_scope not in scenario.scopes):
problems.append(f"{sid}: promote event has unknown to_scope {ev.to_scope!r}")
@mrrahman1517

Copy link
Copy Markdown
Collaborator Author

Superseded by #33. Per our public-repo contribution guidelines, I've moved this work to a branch in my fork (\mrrahman1517/AgentMemoryToolkit) and re-opened it as #33 (same commit \813d691, identical diff). Closing this one in favor of #33.

@mrrahman1517 mrrahman1517 deleted the feature/shared-memory-governance-benchmark branch July 15, 2026 02:13
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.

2 participants