Commit 58bef02
committed
fix(metadata-protocol): let an org-scoped caller revert an env-wide commit (#7819 tier 1)
`revertCommit` and `rollbackToPackageCommit`'s target lookup each resolved their
target commit with a strict `organization_id` equality, which matches no row
whose column is NULL. An org-scoped caller therefore got COMMIT_NOT_FOUND (404)
for any commit recorded env-wide — a row that demonstrably exists and that the
same caller's `listCommits` hands back. Both lookups now accept org-scoped or
env-wide rows, the same `$or` `deletePackage` (#7705) and `listCommits` (#7779)
already carry.
The `$or` was chosen over the two alternatives rather than copied. `where` is
keyed on `id`, so the predicate reads like an authorization filter on a unique
key; measured against the only door it is not one. Authorization is
`requireManageMetadata`, checked before the call, and the `organizationId` that
arrives is the session's active org selection from `resolveActiveOrganizationId`
— a resolver whose body is entirely catch-wrapped and whose `undefined` omits
the predicate, i.e. the widest reading. A boundary that fails open is not a
boundary, which rules out "keep the check but distinguish 'not yours' from 'no
such commit'". Dropping the predicate outright would newly let an org caller
revert another organization's commit by id, a widening this card never asked
for. The body already agreed with the `$or`: #7559 made each item resolve its
scope from the row, and since #7814 `rollbackToPackageCommit` plans from
`listCommits` (org + env-wide) and fed each id back into a lookup that refused
half of them.
The no-org branch is deliberately left un-narrowed, exactly as #7705 and #7779
left theirs.
Pinned by a new real-engine/real-driver suite in packages/runtime (eight cases:
the premise out of SQLite, the positive per site, both negative directions, and
the no-org door per site; refusals asserted on code AND status per ADR-0112).
The #7814 handoff assertion that pinned this as known-incomplete now asserts the
rollback succeeds. Reverse verification, direction predicted first: 3 failed |
11 passed, exactly the three positive cases.
Tier 1 only — `duplicatePackage` and `reassignOrphanedMetadata` are untouched
and #7819 stays open to carry them.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019hxiiv8qFCUmDThHU1k7HV1 parent 3bb9340 commit 58bef02
4 files changed
Lines changed: 534 additions & 16 deletions
File tree
- .changeset
- packages
- metadata-protocol/src
- runtime/src
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12212 | 12212 | | |
12213 | 12213 | | |
12214 | 12214 | | |
12215 | | - | |
| 12215 | + | |
| 12216 | + | |
| 12217 | + | |
| 12218 | + | |
| 12219 | + | |
| 12220 | + | |
| 12221 | + | |
| 12222 | + | |
| 12223 | + | |
| 12224 | + | |
| 12225 | + | |
| 12226 | + | |
| 12227 | + | |
| 12228 | + | |
| 12229 | + | |
| 12230 | + | |
| 12231 | + | |
| 12232 | + | |
| 12233 | + | |
| 12234 | + | |
| 12235 | + | |
| 12236 | + | |
| 12237 | + | |
| 12238 | + | |
| 12239 | + | |
| 12240 | + | |
| 12241 | + | |
| 12242 | + | |
| 12243 | + | |
| 12244 | + | |
| 12245 | + | |
| 12246 | + | |
| 12247 | + | |
| 12248 | + | |
| 12249 | + | |
| 12250 | + | |
| 12251 | + | |
| 12252 | + | |
| 12253 | + | |
| 12254 | + | |
| 12255 | + | |
| 12256 | + | |
| 12257 | + | |
| 12258 | + | |
| 12259 | + | |
| 12260 | + | |
12216 | 12261 | | |
12217 | 12262 | | |
12218 | 12263 | | |
| |||
12487 | 12532 | | |
12488 | 12533 | | |
12489 | 12534 | | |
12490 | | - | |
| 12535 | + | |
| 12536 | + | |
| 12537 | + | |
| 12538 | + | |
| 12539 | + | |
| 12540 | + | |
| 12541 | + | |
| 12542 | + | |
| 12543 | + | |
| 12544 | + | |
| 12545 | + | |
| 12546 | + | |
| 12547 | + | |
| 12548 | + | |
12491 | 12549 | | |
12492 | 12550 | | |
12493 | 12551 | | |
| |||
Lines changed: 23 additions & 14 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
303 | 303 | | |
304 | 304 | | |
305 | 305 | | |
306 | | - | |
307 | | - | |
308 | | - | |
| 306 | + | |
| 307 | + | |
309 | 308 | | |
310 | | - | |
311 | | - | |
312 | | - | |
313 | | - | |
314 | | - | |
315 | | - | |
316 | | - | |
317 | | - | |
318 | | - | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
319 | 327 | | |
320 | | - | |
321 | | - | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
322 | 331 | | |
323 | 332 | | |
0 commit comments