Commit c27a649
authored
fix(db): preserve immutable artifact persistence (#145)
## Summary
- Fix generated media persistence by removing an unnecessary row lock on
immutable output metadata.
- Keep serialization at the existing per-user advisory transaction
boundary.
- Consolidate the pre-launch database history into one current-schema
baseline and one snapshot.
- Enforce that the agent role can insert/read generated outputs but
cannot update them.
## Decisions Made
| Decision | Choice | Reasoning |
|---|---|---|
| Concurrency boundary | Existing per-user advisory transaction lock |
It already serializes reservation and finalization; a second row lock on
immutable output rows was redundant. |
| Runtime permissions | Keep bounded INSERT/SELECT and no UPDATE |
Generated output metadata is immutable after publication. |
| Migration history | One clean baseline | This is a pre-launch
implementation and does not retain compatibility migrations. |
## How to Review
1. Review `packages/db/src/artifact-upload-intents.ts` for the
transaction change.
2. Review `scripts/supabase-target/index.ts` for the immutable ACL
assertion.
3. Verify `packages/db/drizzle` contains one SQL baseline, one snapshot,
and one journal entry.
## Test Plan
- [x] `pnpm --filter @cheatcode/db db:generate` (no schema changes)
- [x] `pnpm turbo typecheck`
- [x] `pnpm turbo lint`
- [x] `pnpm turbo build`
- [ ] Rebaseline the verified production Drizzle ledger and run
migration dry-run
- [ ] Deploy the agent Worker
- [ ] Generate images in production with natural-language and
explicit-action prompts
## Linear
No Linear issue was provided for this production fix.
## Plan
No repository plan document was required for this bounded fix.1 parent 7521d49 commit c27a649
11 files changed
Lines changed: 111 additions & 6304 deletions
File tree
- packages/db
- drizzle
- meta
- src
- scripts/supabase-target
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
53 | 53 | | |
54 | 54 | | |
55 | 55 | | |
56 | | - | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
57 | 59 | | |
58 | 60 | | |
59 | 61 | | |
| |||
106 | 108 | | |
107 | 109 | | |
108 | 110 | | |
109 | | - | |
110 | | - | |
111 | | - | |
112 | | - | |
113 | | - | |
114 | | - | |
115 | | - | |
116 | | - | |
117 | | - | |
118 | | - | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
127 | | - | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
128 | 114 | | |
129 | 115 | | |
130 | 116 | | |
| |||
142 | 128 | | |
143 | 129 | | |
144 | 130 | | |
145 | | - | |
146 | | - | |
147 | | - | |
148 | | - | |
149 | | - | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
150 | 135 | | |
151 | 136 | | |
152 | 137 | | |
| |||
0 commit comments