Skip to content

feat(memory): authorize scoped note access and durable cleanup - #9096

Merged
mzxchandra merged 5 commits into
stagingfrom
codex/scoped-memory-restack
Oct 16, 2026
Merged

mzxchandra merged 5 commits into
stagingfrom
codex/scoped-memory-restack

Conversation

@mzxchandra

Copy link
Copy Markdown
Contributor

Summary

  • Add live authorization for personal, workspace, and Project memory notes through direct HTTP (POST /api/mothership/memories/access) and checkpoint transport (memory_notes_access control).
  • Personal and workspace notes stay available when Projects is off; Project targets return 503 and workspace results carry currentProject: null.
  • Strip remember payloads from chat exports and queue durable cleanup when an account, workspace, or Project is physically deleted.
  • Graph memory keeps its separate memory_scope contract and eligibility; both operations share the existing owned-chat and authorized-use-case infrastructure.
  • No Sim schema migration.
  • Supersedes the closed feat(memory): authorize scoped access and durable cleanup #8934; rebased onto staging now that Project file sharing (feat(project-files): add public sharing and protected delivery #9019) has merged.

Rollout

  • Requires simstudioai/mothership#689 (expansion) for the matching worker contract, persistence, and cleanup endpoint.
  • Mothership improvement(docs): added new docs content, cleanup old content #690 (contraction) only changes worker storage and is not a dependency of this PR.
  • Project memories follow the existing projects flag; there is no memory-specific flag.

Type of Change

  • New feature

Testing

  • 12 real-PostgreSQL checks (resolve-access.integration.ts, cleanup.integration.ts): both transports, Projects on/off/on, read-only private writes, Project Files capability on shared writes, cross-organization denial, detach, cleanup rollback and retry.
  • 19 control-transport and graph memory_scope regression tests.
  • App type-check, strict API validation, changed-file Biome, git diff --check.
  • Mothership check:contract-sync passes against this branch (canonical memory-notes-access.ts and sim-transport.ts byte-identical).
  • Paired live test with an isolated worker passed 17 assertions over direct HTTP and checkpoint transport; a direct probe returned 200 for personal read, workspace private write, and Project read, and 403 for a read-only actor's shared Project write.
  • Browser pass with a real model against Mothership improvement(kb): pagination for docs + remove kb token count problematic query  #689: personal, workspace, and Project notes saved and recalled through this endpoint; a read-only member saw shared notes but not another user's private notes; Projects off hid Project notes while chat kept working.

Checklist

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

Companion PRs

  • simstudioai/mothership#689

Rename the scoped-note control kind from memory_access to
memory_notes_access so it is distinct from graph memory_scope. The HTTP
path, delegation audience sim:memory-access, and semantic operation id
are unchanged.
@vercel

vercel Bot commented Oct 15, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 16, 2026 1:34am 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 Oct 15, 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#689 — OPEN, not merged (targets staging) — feat(memory): add personal, project, and workspace scopes

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic review

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@cubic review

@mzxchandra 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.

All reported issues were addressed across 18 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/data-drains/sources/copilot-chats.ts Outdated
Comment thread apps/sim/lib/mothership/memories/application/resolve-access.ts Outdated
Comment thread apps/sim/lib/mothership/memories/cleanup-outbox.ts
@greptile-apps

greptile-apps Bot commented Oct 15, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Critical impact] The PR appears safe to merge, with no new actionable issues in the latest changes.

Summary

Adds live access checks for personal, workspace, and Project notes, removes memory payloads from chat exports, and queues cleanup during account deletion.

  • Mothership can check live permissions before using memory notes.
  • Deleting an account queues cleanup for its memory notes.
  • Chat exports leave memory-note payloads out of transcripts.
  • The source checker accepts imports in synced worker contracts.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  HTTP["Direct HTTP"] --> Access["Resolve current note access"]
  Control["Checkpoint control"] --> Access
  Access --> Chat["Check actor and owned chat"]
  Chat --> Target["Check requested scope and permissions"]
  Target --> Result["Return current authority to worker"]
  Delete["Account deletion transaction"] --> Queue["Queue credential-bound cleanup"]
  Queue --> Worker["Worker cleanup with retries"]
Loading

Reviews (5) · Last reviewed commit: "test(memory): use the shared env and out..." · Reviewed by Greptile

Comment thread apps/sim/lib/mothership/memories/application/resolve-access.ts Outdated
Comment thread apps/sim/lib/mothership/memories/application/resolve-access.ts Outdated
…port rule

contracts:sync copies these files byte for byte from the worker, whose
sibling imports are relative, so they cannot use the app's aliases.
Exempt only files in lib/mothership/generated that carry the sync header,
and drop their baseline entries.
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 15, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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.

All reported issues were addressed across 21 files

Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/sim/lib/mothership/memories/application/resolve-access.ts Outdated
…skip keyless cleanup

Project note checks took the Project lock exclusively while already holding
it shared, so overlapping workspace checks could deadlock; they now read
under the shared Project lock and the permission-group read lock, as
Project Files does. Exports also redact remember calls stored in the
legacy top-level toolCalls list. A Sim without COPILOT_API_KEY never
reached a worker, so it queues no memory cleanup it could not deliver.
@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

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

Comment thread apps/sim/lib/mothership/memories/cleanup-outbox.ts

@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 22 files

Confidence score: 5/5

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

Turn on auto-fix | Re-trigger cubic

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@greptile

@mzxchandra

Copy link
Copy Markdown
Contributor Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@mzxchandra 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 22 files

Confidence score: 5/5

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

You've manually re-run cubic several times on this PR. Each manual re-review checks the full PR again and counts toward your usage quota. To preserve your usage limits, we recommend letting cubic automatically review new commits.

Turn on auto-fix | Re-trigger cubic

@mzxchandra
mzxchandra marked this pull request as ready for review October 16, 2026 01:52

@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 22 files

Confidence score: 5/5

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

Turn on auto-fix | Re-trigger cubic

@mzxchandra
mzxchandra merged commit f73b9db into staging Oct 16, 2026
53 checks passed
@mzxchandra
mzxchandra deleted the codex/scoped-memory-restack branch October 16, 2026 02:08

This branch was previously deployed

1 inactive deployment
Preview — 9ae7c1a1 Deployed Oct 16, 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