Skip to content

🔨 chore(database): re-tighten getBuiltinAgent onConflict after 0109#15475

Merged
arvinxx merged 1 commit into
canaryfrom
chore/tighten-builtin-agent-onconflict
Jun 4, 2026
Merged

🔨 chore(database): re-tighten getBuiltinAgent onConflict after 0109#15475
arvinxx merged 1 commit into
canaryfrom
chore/tighten-builtin-agent-onconflict

Conversation

@arvinxx

@arvinxx arvinxx commented Jun 4, 2026

Copy link
Copy Markdown
Member

💻 Change Type

  • 🔨 chore

🔗 Related Issue

Follow-up to #15472 / LOBE-9962 (workspace_id migration phase 4).

🔀 Description of Change

Migration 0109 turned agents_slug_user_id_unique into a partial index (WHERE workspace_id IS NULL). During the rollout, #15472 temporarily used a bare onConflictDoNothing() (no arbiter) in getBuiltinAgent so the upsert worked regardless of whether the index was the legacy full unique or the new partial — avoiding a deploy-ordering footgun.

Now that 0109 has flipped the index in every environment (verified: agents_slug_user_id_unique is valid, unique, predicate workspace_id IS NULL), this restores the precise arbiter:

.onConflictDoNothing({ target: [agents.slug, agents.userId], where: isNull(agents.workspaceId) })

so genuine/unexpected unique violations surface instead of being silently swallowed. Builtin agents are always workspace-less, so the predicate always holds.

🧪 How to Test

  • Tested locally — agent.test.ts 114/114 pass against the partial index.
  • Added/updated tests
  • No tests needed

…partial index

Now that migration 0109 has flipped agents_slug_user_id_unique to a partial
index (WHERE workspace_id IS NULL) in all environments, restore the precise
conflict arbiter { target: [slug, userId], where: isNull(workspaceId) } so
unexpected unique violations surface instead of being silently swallowed by the
bare onConflictDoNothing() transition form.

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

vercel Bot commented Jun 4, 2026

Copy link
Copy Markdown

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

Project Deployment Actions Updated (UTC)
lobehub Ready Ready Preview, Comment Jun 4, 2026 2:03pm

Request Review

@dosubot dosubot Bot added the size:S This PR changes 10-29 lines, ignoring generated files. label Jun 4, 2026

@sourcery-ai sourcery-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.

We've reviewed this pull request using the Sourcery rules engine

@codecov

codecov Bot commented Jun 4, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 70.85%. Comparing base (537c39f) to head (6849e22).

Additional details and impacted files
@@            Coverage Diff            @@
##           canary   #15475     +/-   ##
=========================================
  Coverage   70.84%   70.85%             
=========================================
  Files        3255     3255             
  Lines      321112   321115      +3     
  Branches    29340    35001   +5661     
=========================================
+ Hits       227496   227510     +14     
+ Misses      93434    93423     -11     
  Partials      182      182             
Flag Coverage Δ
app 61.51% <ø> (+<0.01%) ⬆️
database 92.54% <100.00%> (+<0.01%) ⬆️
packages/agent-manager-runtime 49.69% <ø> (ø)
packages/agent-runtime 80.48% <ø> (ø)
packages/builtin-tool-lobe-agent 18.52% <ø> (ø)
packages/context-engine 84.19% <ø> (ø)
packages/conversation-flow 91.29% <ø> (ø)
packages/device-gateway-client 90.51% <ø> (ø)
packages/eval-dataset-parser 95.15% <ø> (ø)
packages/eval-rubric 76.11% <ø> (ø)
packages/fetch-sse 87.28% <ø> (+1.71%) ⬆️
packages/file-loaders 87.89% <ø> (ø)
packages/memory-user-memory 74.99% <ø> (ø)
packages/model-bank 99.99% <ø> (ø)
packages/model-runtime 84.51% <ø> (ø)
packages/prompts 72.51% <ø> (ø)
packages/python-interpreter 92.90% <ø> (ø)
packages/ssrf-safe-fetch 0.00% <ø> (ø)
packages/types 35.34% <ø> (ø)
packages/utils 84.98% <ø> (ø)
packages/web-crawler 88.08% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Store 68.53% <ø> (ø)
Services 54.75% <ø> (ø)
Server 71.81% <ø> (-0.01%) ⬇️
Libs 57.15% <ø> (+0.14%) ⬆️
Utils 81.48% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@arvinxx arvinxx merged commit f77f31e into canary Jun 4, 2026
38 of 39 checks passed
@arvinxx arvinxx deleted the chore/tighten-builtin-agent-onconflict branch June 4, 2026 17:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant