Skip to content

Migrate metadata out of the sm_ namespace (agent_scope et al.) - #97

Draft
Dhravya wants to merge 2 commits into
mainfrom
agent-scope-migration
Draft

Migrate metadata out of the sm_ namespace (agent_scope et al.)#97
Dhravya wants to merge 2 commits into
mainfrom
agent-scope-migration

Conversation

@Dhravya

@Dhravya Dhravya commented Aug 19, 2026

Copy link
Copy Markdown
Member

Summary

Ports #92 onto the CLI-free architecture and finishes the rule behind it: nothing the plugin writes may use the sm_ prefix — that's Supermemory's internal namespace.

  • Writes: agent_scope (was reserved sm_scope), agent_project_id, agent_capture_mode, agent_source.
  • Reads: canonical-container profile/search requests filter on agent_scope metadata; legacy containers stay unfiltered for compatibility.
  • The capture test asserts no metadata key starts with sm_.

⛔ Release gate

Do not merge/release until supermemoryai/mono#2895 (the sm_scope→agent_scope backfill) is deployed and complete. Until then, filtered canonical reads return nothing — a silent recall outage. Note for the backfill: this PR also renames sm_project_id/sm_capture_mode/sm_source; only agent_scope is read-critical, but the backfill should cover all four for consistency.

Supersedes #92, which targeted the pre-refactor file layout.

Test plan

  • node --test test/unit.mjs — 23 passing; capture asserts the agent_* keys and the sm_-free invariant, recall and session-start assert the filter shape on stubbed /v4/profile requests.

🤖 Generated with Claude Code

Dhravya and others added 2 commits August 18, 2026 20:23
Captures stamp searchable agent_scope instead of reserved sm_scope;
canonical-container profile/search reads filter on it. Ports #92 onto
the CLI-free architecture.

RELEASE GATE: do not ship until the backend sm_scope→agent_scope
backfill (supermemoryai/mono#2895) is deployed and complete — filtered
reads return nothing until then.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…pace

sm_project_id→agent_project_id, sm_capture_mode→agent_capture_mode,
sm_source→agent_source. The capture test now asserts no metadata key
starts with sm_.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@Dhravya
Dhravya marked this pull request as draft August 19, 2026 03:27
@Dhravya

Dhravya commented Aug 19, 2026

Copy link
Copy Markdown
Member Author

Do not merge — dependency inventory from auditing both local repos. The sm_ keys are a cross-product contract, not plugin-internal:*

supermemory-mono reads:

  • apps/api/src/lib/sm-source.ts — document source resolution from metadata.sm_source + x-sm-source header (update path preserves existing)
  • apps/api/src/routes/memories/index-effect.ts — consumer-source branching (sm_source === "consumer", 2 sites) and sm_capture_mode propagation into derived memories (3 sites)
  • apps/api/src/lib/posthog/index.tssm_capture_mode / sm_plugin_version event props
  • Company Brain writes sm_source: "company-brain" (writeback.ts, company-context.ts)
  • No agent_scope support on main yet — mono#2895 is still open

supermemory (console/MCP/extension):

  • apps/web/hooks/use-plugin-space-meta.ts + apps/web/lib/plugin-space.ts — plugin-space rendering contract on sm_project_id / sm_source
  • apps/web/lib/plugin-document.ts — document source display from sm_source
  • apps/mcp/src/server/client/index.ts and apps/browser-extension/utils/api.ts — both write sm_source

Merge order for the real fix:

  1. mono: accept agent_* alongside sm_* in sm-source resolution, consumer branching, capture-mode propagation, analytics (dual-read)
  2. supermemory web: dual-read agent_project_id/agent_source in plugin-space + document views
  3. mono#2895 backfill deployed + complete (covering all four keys)
  4. merge this PR (plugin writes agent_* only)
  5. later: drop sm_* dual-reads once old documents are backfilled and old plugin versions age out

@Dhravya Dhravya mentioned this pull request Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant