Skip to content

Commit c288004

Browse files
committed
docs: correct lock-ranking claim to verification test, not the provider
1 parent 81b13c0 commit c288004

1 file changed

Lines changed: 14 additions & 7 deletions

File tree

CLAUDE.md

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -439,13 +439,20 @@ report in chat, but it never computes it.
439439
(`varchar(50)``varchar(100)`, which Postgres does NOT rewrite) from a genuine
440440
type change (which does). It reports the conservative rewrite verdict for both
441441
rather than risk a false SAFE.
442-
- **Lock strength is ranked by an explicit ordering list, not `max(mode)`.**
443-
Postgres lock mode names sort alphabetically in a way that has nothing to do with
444-
strength — `"ShareLock".compareTo("AccessExclusiveLock") > 0`, so a naive
445-
string-max would report a statement that also takes `ShareLock` as the stronger
446-
of the two, when `AccessExclusiveLock` is in fact the most exclusive mode
447-
Postgres has. Any code that needs "the worst lock this statement takes" must
448-
rank against Postgres's real lock hierarchy, not compare mode names.
442+
- **The verification test ranks lock strength by an explicit ordering list, not
443+
`max(mode)` — the provider itself does not rank at all.**
444+
`PostgresMigrationRiskProvider` never computes a lock mode; each rule hardcodes
445+
the one it asserts (e.g. `addForeignKey` always reports `ShareRowExclusiveLock`).
446+
The ranking lives only in `PostgresMigrationRiskVerificationTest`
447+
(`LOCK_STRENGTH` + `strongestLock()`), which has to pick the strongest lock out
448+
of however many rows a query against the real `pg_locks` returns. It needs the
449+
ordering because Postgres lock mode names sort alphabetically in a way that has
450+
nothing to do with strength — `"ShareLock".compareTo("AccessExclusiveLock") > 0`,
451+
so a naive string-max would call `ShareLock` the stronger of the two, when
452+
`AccessExclusiveLock` is in fact the most exclusive mode Postgres has. Any future
453+
code that needs "the worst lock a query is holding" from `pg_locks` must rank
454+
against Postgres's real lock hierarchy, not compare mode names — but that need
455+
has not yet reached production code, only this test.
449456
- **Authorization is asserted in the service, before parsing, credential
450457
decryption, or session opening** (`MigrationRiskService.analyze` calls
451458
`accessControlService.assertCanReadConnectionContent` first). The controller is

0 commit comments

Comments
 (0)