Skip to content

fix(memory): percent-encode colons in peer_id so Matrix peers can use Memory (#6100)#6102

Merged
houko merged 4 commits into
mainfrom
fix/memory-matrix-peer-id-colon
Jun 14, 2026
Merged

fix(memory): percent-encode colons in peer_id so Matrix peers can use Memory (#6100)#6102
houko merged 4 commits into
mainfrom
fix/memory-matrix-peer-id-colon

Conversation

@houko

@houko houko commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

Summary

#5119 / #5120 made the per-peer key framing peer:{pid}:{key} injective by rejecting any peer_id containing :. Matrix user IDs are natively @user:matrix.org, so every Matrix user was locked out of memory_store / memory_recall / memory_list with an InvalidInput error.

Change

Instead of rejecting, percent-encode the colon before it enters the key (escape_peer_id: %%25, :%3A). The framing stays injective: peer T1 (prefix peer:T1:) can no longer strip the escaped key peer:T1%3AU2:… of peer T1:U2, so the cross-peer isolation boundary from #5119 is preserved — now enforced by escaping rather than rejection. Colon-free peer_ids encode to themselves, so existing rows are byte-identical and need no migration. Empty peer_id and peer:-prefixed keys are still rejected.

Files:

  • manifest_helpers.rs: new escape_peer_id; peer_scoped_key escapes instead of rejecting colons.
  • memory_access.rs: reject_bad_peer_id drops the colon check; memory_list builds the recovery prefix from the escaped pid.
  • agent_execution.rs / messaging.rs: stale "rejects colon-bearing" comments updated.

Tests

Test plan

  • cargo test -p librefang-kernel --lib test_peer_scoped_key
  • cargo test -p librefang-kernel --test kernel_handle_contract_memory
  • cargo clippy -p librefang-kernel -- -D warnings

Closes #6100

… Memory (#6100)

#5119/#5120 made the peer:{pid}:{key} framing injective by rejecting any peer_id containing ':', which locked Matrix users (@user:matrix.org) out of memory_store/recall/list. Instead of rejecting, escape_peer_id percent-encodes the colon (%->%25, :->%3A) before it enters the key, keeping the framing injective: peer T1 (prefix peer:T1:) can no longer strip the escaped key peer:T1%3AU2:... of peer T1:U2, so cross-peer isolation holds. Colon-free peer_ids encode to themselves (existing rows byte-identical, no migration); empty peer_id and peer:-prefixed keys are still rejected. Updates unit + security integration tests to assert accept-escape-isolate.
@cloudflare-workers-and-pages

cloudflare-workers-and-pages Bot commented Jun 14, 2026

Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Updated (UTC)
❌ Deployment failed
View logs
librefang-deploy 5d8e573 Jun 14 2026, 03:55 PM

@github-actions github-actions Bot added area/docs Documentation and guides area/kernel Core kernel (scheduling, RBAC, workflows) size/M 50-249 lines changed ready-for-review PR is ready for maintainer review labels Jun 14, 2026
The previous commit replaced the channels entry header with the new
memory entry header, leaving five continuation lines orphaned under
the memory bullet.  This restores the channels entry as a separate
bullet so both fixes are correctly attributed.

@houko houko left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The CHANGELOG diff replaced the channels: the dashboard configure form is no longer empty… entry header with the new memory entry header, leaving its five continuation lines orphaned under the memory bullet (the The Add-a-channel form… block through First-party adapter --describe is dependency-free… on lines 789–793 of the PR-branch file). Pushed a one-line fix that restores the channels entry as a separate bullet so both fixes are correctly attributed.


Generated by Claude Code

@houko
houko merged commit 73a93b3 into main Jun 14, 2026
32 of 33 checks passed
@houko
houko deleted the fix/memory-matrix-peer-id-colon branch June 14, 2026 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/docs Documentation and guides area/kernel Core kernel (scheduling, RBAC, workflows) ready-for-review PR is ready for maintainer review size/M 50-249 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Memory current is incompatible with Matrix

2 participants