Commit 49b57c6
authored
fix(db): scope artifact upload row lock (#146)
## Summary
- lock only the active `v2_agent_runs` row while validating
artifact-upload ownership
- keep project, thread, and user joins read-only under their
least-privilege grants
- preserve the transaction fence against a concurrent run completion
## Why
PostgreSQL applies an unqualified `FOR UPDATE` to every relation in a
joined query. The agent role intentionally cannot update projects, so
generated media reached persistence and then failed before its upload
intent could be committed. `FOR UPDATE OF v2_agent_runs` matches the
intended concurrency boundary and the clean baseline ACLs.
## Verification
- `pnpm exec biome check packages/db/src/artifact-upload-intents.ts`
- `pnpm turbo lint`
- `pnpm turbo typecheck --filter=@cheatcode/db
--filter=@cheatcode/agent-worker`
- `pnpm turbo build --filter=@cheatcode/agent-worker`
- `pnpm db:migrate -- --dry-run`1 parent c27a649 commit 49b57c6
1 file changed
Lines changed: 1 addition & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
289 | 289 | | |
290 | 290 | | |
291 | 291 | | |
292 | | - | |
| 292 | + | |
293 | 293 | | |
294 | 294 | | |
295 | 295 | | |
| |||
0 commit comments