feat(memory): cross-project federation — FEDERATED scope (Phase 4 U3)#314
Open
fanhongy wants to merge 5 commits into
Open
feat(memory): cross-project federation — FEDERATED scope (Phase 4 U3)#314fanhongy wants to merge 5 commits into
fanhongy wants to merge 5 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
Contributor
There was a problem hiding this comment.
Pull request overview
Adds a new machine-wide memory tier by introducing a federated scope that is readable across projects, stored in a disjoint on-disk root, and guarded by a federated-only secret/credential pattern gate to reduce blast radius.
Changes:
- Introduces
MemoryScope.FEDERATEDand wires it through store/recall/forget, search-dir enumeration, and scope precedence/write-rank behavior. - Adds
services/secret_gate.pyand enforces it only onscope="federated"writes. - Updates CLI/MCP descriptions + docs and adds/extends unit tests for federated behavior and the secret gate.
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| test/services/test_secret_gate.py | New tests for scan_for_secrets() secret-pattern detection. |
| test/services/test_scoring.py | Adds federated-specific write-guard tests and asserts the recency invariant test still exists. |
| test/services/test_memory_service.py | Adds federated store/recall/forget/layout/precedence/search-dir/secret-gate coverage. |
| src/cli_agent_orchestrator/skills/cao-memory/SKILL.md | Documents federated scope usage and precedence. |
| src/cli_agent_orchestrator/services/secret_gate.py | Implements regex-based secret scanning for federated writes. |
| src/cli_agent_orchestrator/services/memory_service.py | Adds federated scope plumbing: scope_id resolution, pathing, search dirs, secret-gate hook. |
| src/cli_agent_orchestrator/services/memory_scoring.py | Extends precedence/rank tables and clarifies federated asymmetry in comments. |
| src/cli_agent_orchestrator/services/cleanup_service.py | Updates retention + parsing logic to recognize federated scope/dir. |
| src/cli_agent_orchestrator/models/memory.py | Adds FEDERATED enum value and updates scope field description. |
| src/cli_agent_orchestrator/mcp_server/server.py | Updates MCP tool parameter descriptions to include federated scope. |
| src/cli_agent_orchestrator/cli/commands/memory.py | Updates CLI help text to include federated scope. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
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).