Skip to content

fix(knowledge): backfill legacy KB workspace ownership - #7600

Merged
icecrasher321 merged 2 commits into
stagingfrom
codex/fix-legacy-kb-workspaces
Sep 8, 2026
Merged

icecrasher321 merged 2 commits into
stagingfrom
codex/fix-legacy-kb-workspaces

Conversation

@icecrasher321

@icecrasher321 icecrasher321 commented Sep 8, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • Reject null or empty workspace updates so knowledge bases cannot be detached from their workspace. Preserve organization-owned search indexes.
  • Register a resumable script migration for legacy unscoped KBs. Prefer workspaces whose enabled Knowledge blocks reference the KB, then workflow run counts and recency. Require creator write/admin access, suffix conflicting names, and reconcile affected storage accounting atomically.
  • Preserve soft deletion when deleting a workspace: mark KBs deleted, archive documents, and pause connectors. Repeated deletion also cleans up children left active by an earlier deletion.

The migration leaves KBs without a writable destination or with conflicting file bindings unchanged and reports the skipped counts. It runs through the existing migration runner; no production migration was executed for this PR.

Type of Change

  • Bug fix

Testing

  • 118 focused unit tests and 28 PostgreSQL integration tests passed, covering destination selection, name collisions, accounting, concurrent moves, rollback/resume, lock contention, and workspace deletion.
  • App, database, and auth type checks passed.
  • Repository lint, audit suite, block registry, and generated-artifact checks passed.

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)

@vercel

vercel Bot commented Sep 8, 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 Sep 8, 2026 7:23pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Sep 8, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

The PR appears safe to merge, with the previously reported migration-timeout problem fully fixed and no new actionable issues identified.

Summary

  • Rejects null or empty workspace ownership at API, application, and service boundaries.
  • Adds a resumable migration that selects writable destinations, handles name and file-binding conflicts, and reconciles storage accounting transactionally.
  • Extends workspace deletion to archive knowledge-base children, including cleanup retries for previously archived workspaces.
  • The previous migration-timeout concern is fully fixed: migration transactions inherit the runner’s unlimited lock and statement timeouts through its pinned database session.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Legacy unscoped knowledge base] --> B{Creator has writable active workspace?}
  B -- No --> C[Leave unchanged and report skipped]
  B -- Yes --> D[Rank references, runs, recency, and last selection]
  D --> E[Lock knowledge base and destination]
  E --> F{Foreign file-binding conflict?}
  F -- Yes --> G[Leave unchanged and report conflict]
  F -- No --> H[Allocate non-conflicting name]
  H --> I[Assign workspace and clear folder]
  I --> J[Rebuild workspace and payer storage totals]
  J --> K[Commit atomic move]
Loading

Comment thread packages/db/script-migrations/0013_backfill_legacy_knowledge_base_workspaces.ts Outdated
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 8, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

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

@icecrasher321
icecrasher321 merged commit 0a63dda into staging Sep 8, 2026
34 checks passed
@icecrasher321
icecrasher321 deleted the codex/fix-legacy-kb-workspaces branch September 8, 2026 19:27

This branch was successfully deployed

1 active deployment
Preview — d3e9c12a Deployed Sep 8, 2026 by vercel[bot]
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