#147: bind memory namespace into the signed cap service (approach B)#150
Open
hanwencheng wants to merge 1 commit into
Open
#147: bind memory namespace into the signed cap service (approach B)#150hanwencheng wants to merge 1 commit into
hanwencheng wants to merge 1 commit into
Conversation
…h B) memory.put/get now mint the cap with service="memory:<namespace>" instead of a static "memory". Because the broker signs `service` and the worker already derives the S3 key, AAD, and on-chain scope check from cap.payload.service, this makes the namespace: - tamper-proof (signed into the cap), - authorized via the existing isServiceInScope gate, - storage-segregated (bots/<actor>/memory/memory:<ns>.enc), - AAD-bound, with NO CapPayload change, NO broker change, and no byte-exact broker<->worker signature risk. Also fixes a latent bug where every namespace collided at the single memory.enc key. No worker behavior change (it already keys/scopes/AADs off the signed service); added a test proving namespace-folded services segregate storage. Verified: cargo test -p agentkeys-mcp-server (35) + -p agentkeys-worker-memory green.
6 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
First real increment of #147 (the memory system), using approach B (chosen with the maintainer): fold the memory namespace into the signed
servicefield of the cap-token (service = "memory:<namespace>") instead of adding a new signed cap claim.Why approach B
The cap-token already signs
service, and both the broker (isServiceInScope) and the memory worker (key derivation + AAD + scope re-check) already operate entirely offcap.payload.service. So making the memory service carry the namespace gives, for free:memory:travelcap can't be edited intomemory:personal.isServiceInScope(operator, actor, keccak("memory:travel"))gate now authorizes the namespace. No new mechanism.bots/<actor>/memory/memory:travel.enc, physically distinct frommemory:personal.No
CapPayloadchange, no broker change, no byte-exact broker↔worker signature risk, no breaking cap-format. It also fixes a latent bug: today every namespace collides at the singlememory.enckey (the worker ignored the bodynamespace).Changes
crates/agentkeys-mcp-server/src/tools/memory.rs—memory.put/memory.getnow mint the cap withservice = "memory:<namespace>"(was a static"memory"+ a redundant body field the worker ignored).crates/agentkeys-worker-memory/src/handlers.rs— added a test proving namespace-folded services segregate storage (memory:travel≠memory:personalkey). No behavior change in the worker — it already keys/scopes/AADs off the signed service.Verification
cargo test -p agentkeys-mcp-server— green (35 tests).cargo test -p agentkeys-worker-memory— green (incl. the new segregation test).Remaining for #147 (follow-up commits on this PR)
harness/phase1-wire-demo.sh+ theheima-scope-setstep grantmemory:travel(and seed in thetravelnamespace) instead ofmemory, so the--realflow authorizes the namespaced service. (--lightis unaffected — the in-memory backend keys off the body namespace.)memory:<namespace>(canonical-names + bucket-layout note).memory:prefix in the worker S3 key (bots/<actor>/memory/travel.enc) and a cross-namespace-denial integration test in the stage-3/wire harness.Notes
/create-prpolicy: committed from the worktree (git), pushed via jj; noCo-Authored-By.