Commit 0526be1
feat(server): status compare-and-set + locked-baseline patch + terminal-reopen gate (RBR-929/950/951/953)
Consolidates the three RBR-929 step branches (RBR-950/951/953) that were
verified passing on rbr953-terminal-reopen-gate but never merged to
fork/master, cherry-picked and rebased onto current tip.
RBR-950 (AC1/AC2/AC4): opt-in status compare-and-set on issuesSvc.update.
`expectedStatus`/`expectedStatuses` becomes a SQL WHERE predicate
(inArray(issues.status, ...)) on the write itself, so a losing write from a
stale snapshot affects zero rows instead of clobbering. A losing CAS throws
`conflict` (409), distinguishable from `null` (not-found).
RBR-951 (AC3): the row-lock half of the fix, minus the blocked-bookkeeping
test (rbr951-locked-baseline-patch.test.ts) and its assignee-derived cleanup
logic, which depend on unblockDescriptor/blockedTransitionAt/
blockedOwnerNotifiedAt columns from an unrelated, unmerged upstream PR
(paperclipai#10112) not present in this schema. Kept applyLockedBaselinePatchFields for
the assignee-derived lock-clearing fields (checkoutRunId/executionRunId/
executionAgentNameKey/executionLockedAt), which are real columns here, and
the re-assertion of assertTransition against the locked read inside
runUpdate (the actual RBR-864 fix: a stale non-terminal snapshot cannot
regress a row that has since committed done).
RBR-953: gates terminal (done/cancelled) -> non-terminal transitions behind
an explicit allowTerminalReopen opt-in, independent of the CAS opt-in. This
is the actual fix for the RBR-864 class of incident (recovery reconciler
reverting a completed issue back to blocked from a stale snapshot).
allowTerminalReopen is granted to the 3 legitimate reopen callers that exist
in this codebase: board/human comment reopen and the explicit PATCH
/issues/:id status-write path (server/src/routes/issues.ts), and the
deferred-comment-wake reopen (server/src/services/heartbeat.ts). A 4th
caller from the original RBR-953 diff, the status-card compile reopen
(server/src/services/status-cards.ts), does not exist in this codebase and
was dropped. Also grants it to the task-watchdog revive path
(server/src/services/task-watchdogs.ts), present here as `shouldReopen`.
Test currency fix: the RBR-950 "stays opt-in" test asserted a plain
`svc.update(id, { status: "blocked" })` with no CAS keys could still clobber
`done`. That was true when RBR-950 landed alone but is stale now that
RBR-953's assertTransition gate refuses *any* ungated done -> blocked write
regardless of CAS keys. Split into two tests: the original opt-in behaviour
now scoped to non-terminal -> non-terminal transitions (still true), plus a
new test asserting the CAS opt-in and the terminal-reopen opt-in are
independent gates (per RBR-1103 review).
Verified on this branch (embedded Postgres, not July-era production):
- rbr929-update-status-cas.test.ts: 9/9 pass (was 7/8 with the stale
assertion; now 9/9 with the split test)
- rbr953-terminal-reopen-gate.test.ts: 10/10 pass
- tsc --noEmit: identical error set to unmodified fork/master (adapter-acpx
module resolution + 2 pre-existing plugin-host-services.ts errors),
confirmed by diffing against a clean fork/master worktree with the same
node_modules — this diff introduces zero new typecheck errors.
RBR-929, RBR-950, RBR-951, RBR-953, RBR-1103
Co-authored-by: Paperclip <noreply@paperclip.ing>1 parent c9645f3 commit 0526be1
6 files changed
Lines changed: 746 additions & 9 deletions
File tree
- server/src
- __tests__
- routes
- services
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
0 commit comments