Commit 0ee1ec2
committed
fix(metadata-protocol): listCommits no longer hides env-wide commit history (#7779)
`protocol.listCommits` selected the ADR-0067 timeline with the strict
`organization_id` equality that #7705 (PR #7771) had just replaced one
function above it. `organization_id = '<org>'` matches no row whose
column is NULL, so a session with an active organization was shown none
of the commits recorded env-wide.
Live, not latent, and measured before the fix was written — which the
card set as step one. `recordPackageCommit` stores `request.
organizationId ?? null`, and the only door into a publish (the
dispatcher's `POST /packages/:id/publish-drafts`) forwards an org only
when `resolveActiveOrganizationId` yields one. That resolver answers
`undefined` both for a session with no active organization and for ANY
throw on the auth seam, since its whole body is `catch`-wrapped. So a
publish made before an org is selected, or during a transient auth
blip, records its commit env-wide permanently — the timeline is
append-only. Driven on a real engine over SQLite, a no-org publish
wrote `organization_id: null` and the org-scoped read of that same
package then returned `[]`.
The blast radius is wider than the audit/observability one the card
projected, and that is a finding rather than a detail:
`rollbackToPackageCommit` derives the set of commits it must undo FROM
THIS LIST. A commit the list could not see was silently never
reverted — measured pre-fix, an org-scoped rollback past an env-wide
commit answered `{success: true, revertedCommits: []}` with that
commit's changes still live. A rollback that reports success and rolls
back nothing is a correctness defect, not a reporting one.
An org-scoped read now matches its own organization OR env-wide — the
`$or` shape this package already uses for #3115, the shape #7705
applied to the sibling `deletePackage` read, and the shape the SQL
driver's own tenant wall uses (#2734).
Both directions that must not widen are pinned: another organization's
commits stay invisible, another package's are never returned, and
newest-first ordering is unchanged. The no-org branch is deliberately
left package-wide rather than narrowed to `organization_id IS NULL` —
narrowing would hide every org-scoped commit from that door instead,
re-creating the bug pointed the other way, which is why #7705 left its
own no-org branch alone. The whole shape, or none of it.
The pin uses a real engine and a real driver and asserts the
CONSEQUENCE. Both existing `deletePackage` suites stubbed
`engine.find`, which is why neither could see the sibling defect; the
question here is whether `organization_id = 'org'` matches a NULL
column, which is a property of the driver's SQL and not of a stub's
`filter()`. It seeds through the real publish path and reads back what
landed in SQLite.
Reverse-verified with the direction predicted first: restoring the
strict equality was predicted to turn exactly the two positive cases
red and leave all four others green, because strict equality is
NARROWER than the `$or` — it cannot reach another org's rows or
another package's, and does not touch the no-org branch. Measured on
revert: exactly that, 2 failed / 4 passed, both failures `[1]` vs `[2]`.
KNOWN REMAINING GAP, reported on #7779 rather than fixed here — this
card holds `protocol.ts`, a serialized file, for `listCommits` alone.
`revertCommit` and `rollbackToPackageCommit`'s own target lookups still
carry the identical strict equality. The consequence is now loud rather
than silent: the rollback above reports `success: false` naming the
commit it could not resolve, instead of claiming success over a no-op.
Strictly better and non-destructive, but not the whole repair, so the
new suite asserts it and the remainder cannot drift unnoticed.
Ratchets unchanged: runtime's TEST_DEBT measured exactly 227, its
recorded ceiling, with zero errors attributable to the new file; the
query-options-erasure ratchet holds at 67 non-test sites.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Kp1rUCEFGp3eYRztsRx1B11 parent 098b629 commit 0ee1ec2
3 files changed
Lines changed: 422 additions & 1 deletion
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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12114 | 12114 | | |
12115 | 12115 | | |
12116 | 12116 | | |
12117 | | - | |
| 12117 | + | |
| 12118 | + | |
| 12119 | + | |
| 12120 | + | |
| 12121 | + | |
| 12122 | + | |
| 12123 | + | |
| 12124 | + | |
| 12125 | + | |
| 12126 | + | |
| 12127 | + | |
| 12128 | + | |
| 12129 | + | |
| 12130 | + | |
| 12131 | + | |
| 12132 | + | |
| 12133 | + | |
| 12134 | + | |
| 12135 | + | |
| 12136 | + | |
| 12137 | + | |
| 12138 | + | |
| 12139 | + | |
| 12140 | + | |
| 12141 | + | |
| 12142 | + | |
| 12143 | + | |
| 12144 | + | |
| 12145 | + | |
| 12146 | + | |
| 12147 | + | |
| 12148 | + | |
| 12149 | + | |
| 12150 | + | |
| 12151 | + | |
| 12152 | + | |
12118 | 12153 | | |
12119 | 12154 | | |
12120 | 12155 | | |
| |||
0 commit comments