Skip to content

feat(mothership): sign the private memory scope for the memory sidecar - #10185

Open
myxamediyar wants to merge 7 commits into
stagingfrom
feat/memory-scope-attestation
Open

myxamediyar wants to merge 7 commits into
stagingfrom
feat/memory-scope-attestation

Conversation

@myxamediyar

@myxamediyar myxamediyar commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Sim can sign the private-memory scope it returns, so the memory service can check that a memory request carries exactly the ids Sim returned for the call
  • attestation.ts: an EdDSA JWT over those ids (sub the user, org, ws, space, chat), issuer sim, audience mothership-memory, valid one minute, signed with MOTHERSHIP_MEMORY_SIGNING_KEY (Ed25519, PKCS#8 PEM, newlines as \n)
  • read-scope.ts returns it as attestation only while memory is enabled and a key is set; without a key nothing changes
  • The memory-scope contract gains the optional attestation; .env.example documents the key, which a self-hosted Sim on the hosted endpoint leaves unset
  • The verifier needs only the public key, so it can check a scope but never sign one; kept separate from the HS256 internal tokens in lib/auth/internal.ts, whose shared secret also authorizes Sim's internal API
  • Who a scope call acts for is bound by run grants (feat(mothership): serve worker calls only for a user and chat sim granted #10192): with MOTHERSHIP_REQUIRE_RUN_GRANT set, the scope route serves only the user and chat a grant names, so the signature then speaks for Sim end to end. A memory service should require this signature only from a Sim that requires run grants

Companion: simstudioai/mothership#977

Type of Change

  • New feature

Testing

  • read-scope.test.ts: the scope is signed for the memory service only, for one minute, with the ids it returns; nothing is signed while memory is off or no key is set
  • A token signed by this code verifies against the matching public key with a standard EdDSA JWT library and is refused when the ids differ
  • lib/mothership and lib/core/config suites pass (3262 tests); bun run lint:check, bun run type-check and bun run check:audits pass

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

myxamediyar and others added 2 commits November 17, 2026 17:14
read_scope returns an attestation while memory is enabled and
MOTHERSHIP_MEMORY_SIGNING_KEY is set: a one-minute EdDSA JWT over the user,
organization, workspace, space and chat it just authorized, which the
mothership memory sidecar verifies with Sim's public key instead of trusting
the worker that forwards it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
MOTHERSHIP_MEMORY_SIGNING_KEY is set only for a Mothership whose memory service lists its public
key; a Sim on the hosted endpoint leaves it unset.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@vercel

vercel Bot commented Nov 18, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
docs Ready Ready Preview Nov 19, 2026 1:07am UTC

Request Review

@github-actions github-actions Bot added the requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep label Nov 18, 2026
@github-actions

Copy link
Copy Markdown

⚠️ Cross-repo companion check

One or more companion PRs aren't merged into staging yet. Merging this without them will leave copilot and sim out of sync — merge them in lockstep.

  • ❌ simstudioai/mothership#977 — OPEN, not merged (targets staging) — feat(memory): move private memory to postgres with access-checked levels and a r

@greptile-apps

greptile-apps Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] No new blocking issues found; the signature must not be treated as proof of the worker's acting identity without run grants.

Summary

Adds optional, short-lived signatures over the private-memory scope returned by Sim.

  • Sim can sign enabled private-memory scopes for the memory sidecar.

The earlier worker-identity concern was acknowledged and deferred by myxamediyar to PR #10192: run grants must bind worker calls to a user and chat. This PR checks that memory requests carry the IDs Sim returned; it does not establish that binding itself. No new actionable issues found.

Reviews (2) · Last reviewed commit: "chore(mothership): merge staging into th..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 6 files

This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

…s check

The signature lets the memory service check that a request carries exactly the ids Sim returned
for the call. It does not on its own stop a worker that names another chat when it asks for a
scope; run grants on the worker routes cover that separately.
@myxamediyar

Copy link
Copy Markdown
Contributor Author

@greptile

@myxamediyar

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Nov 19, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@myxamediyar I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 6 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Tip: Get a Slack DM when cubic finishes reviewing your PRs. Connect Slack

Turn on auto-fix | Re-trigger cubic

This branch was successfully deployed

1 active deployment
Preview — e76e5103 Deployed Nov 19, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

requires-mothership-merge Has a companion PR on the mothership/copilot side — merge in lockstep

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant