Description
Company or project name
No response
Component
MCP server
Use case
Memories link to code only when code_namespace_for (server/memory/app/code_link_reads.py) finds a code namespace: the memory is written in one, or a repo:<id> tag names a configured repository (namespace_for_tags, server/code/app/memory_links.py). The Claude Code and Codex plugins add that tag to what their hooks capture, but a lesson the agent saves itself with loom_memory_set in its own (non-code) namespace goes straight to the server without it: the plugin's MCP header helper sends only X-Loom-Code-Scope, which the server applies to code.* calls and loom_search's repository gate, never to memory.set. So the lessons an agent writes on purpose to its own namespace, the ones most worth linking, never show up under code.symbol lessons unless the agent adds the tag by hand. Team file rules already link: the plugin's loom-memory skill ("Team file rules" in SKILL.md and reference.md) writes them into the repository's primary code namespace, where code_namespace_for finds the repository through trunk_namespace without a repo: tag.
Describe the solution you'd like
Propose and implement one of:
- (a) On
memory.setover MCP, when the session carries a code scope, add the scope'srepo:<id>tag unless the call names its ownrepo:tag.X-Loom-Code-Scopecarriesorg/namespace, not the tag: map it back to the configured repository'srepo_tag, and apply it inserver/transport/mcp_call.pynext toapply_code_scope(defined inserver/code/domain/scope.py). This touches the write path, so follow the identity and provenance rules in.claude/rules/memory-plane.md. - (b) Tell the agent to pass the tag: the primer line in
integrations/claude-code-plugin/lib/session-start.mjs(which today tells it to passrepo:<id>toloom_searchonly), and theloom_memory_setdescription inserver/transport/mcp_descriptions.py. Edit only the Claude Code plugin's file, then runpython scripts/codegen/agent_plugin_sync.pyto copy it tointegrations/codex-plugin/lib/session-start.mjs:make lintruns the script with--check, which fails unless the Codex copy matches byte for byte.
Either way, add a test that a memory saved in a plugin session is linked by the next memory_code_links pass. Discuss the choice in this issue first.
How to test: make format-check lint typecheck test-unit passes; for option (a), make test-unit-cov passes too: server/transport/mcp_call.py falls under the server/transport/ branch-coverage floor (86.0) in tests/inventory/coverage_floors.toml, which that target and CI check; for option (b), node --test integrations/claude-code-plugin/tests/*.test.mjs passes too (those tests cover the hook scripts the Claude Code and Codex plugins share).
Describe alternatives you've considered
The agent can add repo:<id> by hand today; nothing tells it to, so in practice it does not.
Where the need comes from
The need is mine, an AI tool helped shape the proposal
Additional context
Related: #644 (code.symbol returns no lessons when the memory_code_links reads exceed code_enrich_timeout_s). Both are about the lessons code.symbol shows from memory_code_links: this issue is about memories that never get a link, #644 about linked ones the read drops on a large table. Check the new links in memory_code_links itself, so the test does not depend on that read's time bound.
Size: L (several days, with review of the write path). Read CONTRIBUTING.md first (signed-off commits), and comment here to say you are working on it.
Activity
0mandrock1 commentedon Nov 19, 2026
I'd like to work on this and align on the choice before opening a PR.
I favour (b) as an incremental, low-risk fix:
loom_memory_settool description so an agent saving a memory about the current repository includes its actualrepo:<id>tag, even when writing into the agent's own namespace.agent_plugin_sync.py.memory_code_linksbehaviour in regression tests.Trade-off: (b) preserves the existing server write-path/provenance semantics, but it is best-effort: the agent may still omit the tag. If the requirement is deterministic linkage regardless of agent instruction-following, then (a) would be the right architecture, with the corresponding identity/provenance review.
I have a local candidate and test evidence for (b), but won't open a PR until we agree on that trade-off. Would you prefer the smaller best-effort change now, or the server-side guarantee in (a)?
zlareb1 commentedon Nov 19, 2026
@0mandrock1 please implement (a).
The plugin already adds
repo:<id>to rows it captures from the checkout. A memory the agent saves itself withmemory.setnever gets that tag:X-Loom-Code-Scopeonly fills the namespace oncode.*calls. With no tag,memory_code_linkshas no repository to link against, so the lesson never shows up on the code.Asking the agent to pass the tag, in the primer or the
memory.setdescription, leaves the link up to the model. This issue exists because the model does not pass it. A test of that change can only show that a caller who sends the tag gets a link.On MCP
memory.set, when the session has a code scope and the call has norepo:tag, add that scope'srepo:<id>inserver/transport/mcp_call.pynext toapply_code_scope. Leave the memory write path as it is.actorandsource_classstay stamped by the server.repo:tag keeps it.A line in the
memory.setdescription can say the agent may pass a differentrepo:tag. That line does not create the link.