Skip to content

fix(core): enforce scope-aware export import#1037

Merged
kunickiaj merged 1 commit into
mainfrom
05-04-fix_core_enforce_scope-aware_export_import
May 5, 2026
Merged

fix(core): enforce scope-aware export import#1037
kunickiaj merged 1 commit into
mainfrom
05-04-fix_core_enforce_scope-aware_export_import

Conversation

@kunickiaj
Copy link
Copy Markdown
Owner

@kunickiaj kunickiaj commented May 5, 2026

Description

Treats export/import as replication-equivalent and applies scope-aware rules to both directions:

  • `exportMemories` filters by local scope visibility and only exports sessions whose memories are locally visible.
  • Exported memories include `scope_id`; null/blank legacy rows export as `LOCAL_DEFAULT_SCOPE_ID` rather than getting promoted to a coordinator scope.
  • `importMemories` validates scopes before writes/dryRun, but the validation is dedupe-aware: rows that are already present in the destination DB (matched by import_key) do not require active scope authorization, so a re-import remains a no-op even after the operator's membership is revoked.
  • `scopeCanBeImported` only auto-allows `local-default`; `legacy-shared-review` still requires authority/membership.
  • CLI `import` catches import failures and emits a human/JSON error instead of throwing.

Implements codemem-ov4g.5.10.

Type of Change

  • 🐛 Bug fix (fixes an issue)

Testing

  • Relevant checks pass locally (`pnpm run tsc`, `pnpm run lint`, `pnpm run test`)
  • Added/updated tests for changes
  • Manually verified changes work as expected

Coverage: scope round-trip, null-scope exports, unauthorized-scope import rejection, idempotent re-import after revoked authorization.

Checklist

  • Code follows project style (`pnpm run lint` passes for touched files)
  • Self-review completed
  • Documentation updated (if needed)
  • No new warnings introduced

Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 0806658440

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread packages/core/src/export-import.ts Outdated
@kunickiaj kunickiaj force-pushed the 05-04-fix_api_enforce_scope-safe_viewer_and_cli_memory_access branch from cb2c44b to f6b5722 Compare May 5, 2026 14:36
@kunickiaj kunickiaj force-pushed the 05-04-fix_core_enforce_scope-aware_export_import branch 2 times, most recently from 741f366 to 754f71f Compare May 5, 2026 14:46
Copy link
Copy Markdown
Owner Author

kunickiaj commented May 5, 2026

Merge activity

  • May 5, 2:59 PM UTC: A user started a stack merge that includes this pull request via Graphite.
  • May 5, 3:18 PM UTC: Graphite rebased this pull request as part of a merge.
  • May 5, 3:19 PM UTC: @kunickiaj merged this pull request with Graphite.

@kunickiaj kunickiaj changed the base branch from 05-04-fix_api_enforce_scope-safe_viewer_and_cli_memory_access to graphite-base/1037 May 5, 2026 15:14
@kunickiaj kunickiaj changed the base branch from graphite-base/1037 to main May 5, 2026 15:16
@kunickiaj kunickiaj force-pushed the 05-04-fix_core_enforce_scope-aware_export_import branch from 754f71f to 4e6bea6 Compare May 5, 2026 15:17
@kunickiaj kunickiaj merged commit 7efaa3e into main May 5, 2026
8 checks passed
@kunickiaj kunickiaj deleted the 05-04-fix_core_enforce_scope-aware_export_import branch May 5, 2026 15:19
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