feat(memory): cross-project federation — FEDERATED scope (Phase 4 U3)#314
Open
fanhongy wants to merge 2 commits into
Open
feat(memory): cross-project federation — FEDERATED scope (Phase 4 U3)#314fanhongy wants to merge 2 commits into
fanhongy wants to merge 2 commits into
Conversation
Machine-wide shared memory tier reachable via existing store/recall/forget with scope="federated". Lowest recall precedence; writable by any agent but session; secret-keyword gate rejects credentials on federated writes. Closes #313.
…f sensitive information' Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
12 tasks
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
Every memory CAO stores today is trapped in one project —
recall()only sees the current project's wiki plus sharedglobal/. A lesson learned in project A is invisible in project B.This adds federation: a machine-wide shared tier (
FEDERATEDscope) reachable through the existingmemory_store/memory_recall/memory_forgetverbs withscope="federated". No new MCP tools, no new verbs. Closes #313 (Phase 4 U3).Design
SCOPE_RANK=0) — matches how agents already writeglobalproactively. Mirrors the existing session asymmetry (lowest recall precedence, lowest write rank).MEMORY_BASE_DIR/federated/— a top-level sibling ofglobal/, inside the existing path-containment guard. Its ownindex.md.services/secret_gate.pyscans content on federated writes and rejects AWS keys, PEM blocks, bearer tokens,password=/secret=assignments, and GitHub/GitLab PATs. The blast radius is every project, so credentials are blocked mechanically. Other scopes are unaffected..exists()guard in_get_search_dirskeeps recall byte-identical to today when no federated memory exists (no presence cache needed).Changes
models/memory.py—FEDERATEDenum valueservices/memory_scoring.py—SCOPE_RANK[federated]=0,SCOPE_PRECEDENCE[federated]=4(+ asymmetry comment)services/memory_service.py— storage path,scope_id→None, both precedence dicts (incl. the duplicate literal), search-dir wiring, federated-only secret-gate hook instore()services/secret_gate.py(new) —scan_for_secrets(), 6 credential patternsservices/cleanup_service.py,mcp_server/server.py,cli/commands/memory.py— scope plumbing + descriptionsskills/cao-memory/SKILL.md—federatedrow + "share across projects" guidanceTesting
test/services/test_secret_gate.py(new) — positive/negative pattern coverage incl. the canonicalAuthorization: Bearer <token>header formtest/services/test_memory_service.py— federated store/recall roundtrip, ranks-last, file location, forget, secret-rejected-nothing-written, same-content-allowed-at-global (proves federated-only gating), empty-federated search-dirs byte-identical, scan_all no-double-addtest/services/test_scoring.py—scope_write_allowedfederated table; load-bearing recency invariant still greenBuilt via a design → implement → 3-lens adversarial review (correctness/security/regression) → validate workflow. The review caught a real bug: the bearer-token regex required a
:/=separator and missed the canonicalAuthorization: Bearer <token>header — fixed, with the documenting xfail flipped to a passing positive test.Out of scope
Cross-machine sync; web UI surface; import/export conflict plumbing (Phase 4 U2, lands separately).