Repository navigation
refactor(patches): avoid unused inventory reads and broad row locks - #281
Conversation
Astra reviewReviewed StandardsNo merge-blocking method or YAGNI findings. SpecP1 · Intent: revalidate ownership under the selected patch locksUserLifecyclePage.ts:220–227, following the lock removal in Patches.ts:1107–1113. The brief asks to “change selected patches in ID order before changing the user.” The narrower locking loses the existing exact-selection protection against reassignment. The handler reads ownership before acquiring patch-row locks. Reproduced with real Postgres and the HTTP handler, without replacing service implementations:
The confirmation returns 303, retires the new owner's patch, and deactivates the original user. It should refuse with 409 and leave both lifecycle states unchanged. The retained exact-confirmation test covers reassignment before the request, not this interleaving. Keep the narrower lock scope, but acquire the submitted patch IDs' row locks in ID order inside Patches before re-reading and validating the selection. Reject ownership changes under those locks and roll back the whole operation. Verification
Summary: Standards 0 blockers; Spec 1, worst P1: concurrent reassignment lets deactivation retire another user's patch. |
Opus reviewFirst-reviewer pass standing in for grok build. Fixed point Verdict: net simplification, ship it after the one judgement call below gets a decision. 179 lines out, 132 in, and the deletions are the expensive ones: a per-read company lease with an N-iteration inventory loop, and a Verification asked forNo wire body changed — confirmed. Inventory is still Deadlock freedom — the argument holds. Rollback-together regression still proves one transaction — yes, and slightly better. StandardsSources: CLAUDE.md,
SpecBrief: (1) Nothing from the brief is missing. Clause 3 is fully met. Clause 1 is met and its coverage is not lost: the deleted
Coverage gap worth one testNothing proves the headline claim of clause 2 — that a deactivation commit no longer blocks unrelated patches. SummaryStandards: 10 findings, all judgement calls, no hard violations; worst is N3 (the twelve duplicated lines across the two new call sites, carrying a third copy of the access clump). Spec: 4 findings; worst is S1 (the Reviewed with |
|
Addressed the Astra and Opus reviews in 5b74b28; CI test repair is in 01f9737. Fixed
Kept as-is
Verification
These are internal locking/precondition changes. Wire schemas, CLI output, migrations, dev-loop contracts, product vocabulary, and served-page markup are unchanged. Both lifecycle directions are covered. No review-body or inline threads were present; this comment records the disposition of both conversation reviews. Rechecked conversation comments, review bodies, and inline comments after the final push: no new review findings. PR is open and mergeable; not merged. |
2d9fd06 to
33f737e
Compare
01f9737 to
99bc99c
Compare
33f737e to
84167a9
Compare
99bc99c to
65905d1
Compare
) Portal rendering mixed confirmations with the index, card and versions pages through one mutable options bag. The API guard also depended on portal rendering and browser-session services just to answer hand-crafted overlong names. Split confirmation handling into `confirmationPage`, preserving the existing refusal precedence, copy and form state. Leave portal name bounds to its routes and remove the portal branch from the API guard. Unroutable overlong POSTs and encoded-slash GETs now use the existing 404 responses; API behavior stays unchanged. Stacked on `portal/cleanup-read-path` (#281). This PR contains only the next cleanup commit and should merge after that branch. ## Verification - `pnpm lint` passed. - `pnpm typecheck` passed. - `pnpm exec vitest run apps/server packages/portal` passed: 86 tests across 5 files. - Earlier full-suite runs each passed 936 of 938 tests, with 5-second timeouts in different untouched Postgres or CLI tests. All timed-out cases passed in isolation; no assertions or timeouts were relaxed. Model: `openai-codex/gpt-6-astra`. Harness: Oh My Pi.
Patch lists loaded inventory they never display, and user lifecycle commits locked every patch in the company. Lifecycle API refusals repeated the same response construction.
Fetch inventory only for detail routes. Keep the dependency advisory lock and transaction owned by Patches, and change selected patches in ID order before changing the user. Share the refusal mapping without changing wire bodies or unavailable-inventory semantics. The rollback regression still proves patch and user changes commit together.
Stacked on #272, with base branch
portal/259-e2e-docs. This PR contains only the cleanup commit above that stack.Verification
pnpm lintpnpm typecheckpnpm test:postgres-concurrency— 7 passedpnpm exec vitest run packages/portal/src/PortalPages.test.ts— 47 passedImplemented with
openai-codex/gpt-6-astrausing Oh My Pi.