Repository navigation
test(helpers): use the lock-wait and inject helpers in two standing-approval tests - #3275
Conversation
…pproval and expiry tests The two postgres-platform files polled pg_blocking_pids in hand-rolled loops and wrapped app.inject by hand. They now use the shared helpers; the helpers get JSDoc parameter types so TypeScript callers can pass their options.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
… type injectJson's session Review nits: editor hovers now show the description with the parameter types, and TypeScript callers get the session shapes authenticatedHeaders accepts.
|
Codex review: needs maintainer review before merge. What this changesThis PR replaces duplicated request and lock-wait plumbing in two standing-approval integration tests with existing shared helpers. Example: Two PostgreSQL operations wait behind an uncommitted withdrawal transaction.
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it completes a useful test-helper migration, and the introduced diff contains no actionable defect. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe PostgreSQL integration suite sends authenticated requests through the controller's Fastify app and exercises credential owners against database fixtures; shared helpers construct requests and observe PostgreSQL lock waits before assertions. flowchart TB
Tests[Standing approval tests] --> Inject[injectJson]
Inject --> API[Fastify controller API]
API --> Database[PostgreSQL]
Tests --> Owners[Prepared credential owners]
Owners --> Database
Tests --> Waiter[waitForLockWaiter]
Waiter --> Database
Technical reviewBest possible solution: Retain the focused migration to existing helpers with the current race and authorization assertions intact. Do we have a high-confidence way to reproduce the issue? This PR addresses duplicated test plumbing rather than a reported product failure; source inspection confirms both copies remain on fetched main. Is this the best way to solve the issue? Using the existing helpers is the smallest complete cleanup, and the retained callers preserve their authenticated requests and consequential race assertions. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against f8002a432b2c. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 23, 2026, 1:39 AM ET / 05:39 UTC. |
Problem
Two postgres-platform files still carried private copies of patterns that have shared helpers:
postgres-standing-approval-api.test.tspolledpg_blocking_pidsin a hand-rolled deadline loop and wrappedapp.injectby hand (host header, session headers, JSON body) for its login and itsrequesthelper.postgres-prepared-standing-expiry.test.tspolledpg_blocking_pidsin a hand-rolled loop until two backends waited on the withdrawal transaction.Both files were held by open PRs when the earlier helper batches ran.
Change
waitForLockWaiter(tests/helpers/postgres-lock-waits.mjs), keeping their timeouts (10 s and 900 ms), the statement filter (queryLike: "%FROM occ.namespaces%FOR UPDATE%") and the waiter count (2).requestwrapper useinjectJson(tests/helpers/inject-json.mjs). The wrapper stays as a closure for the default session.waitForLockWaiterandinjectJsonget JSDoc@paramtypes. These are the first TypeScript callers, and without the typestscinferred the destructured options from their defaults alone and refusedtimeoutMs,queryLikeandbody. Nothing changes at runtime.Two small behaviour differences, both the ones earlier migrations accepted: the helper polls every 20 ms instead of spinning, and it waits for at least the expected number of waiters instead of exactly that many. The helper also drops the
wait_event_type='Lock'filter, which is redundant becausepg_blocking_pidsis non-empty only for heavyweight lock waits.Left as is:
postgres-prepared-standing-removal'sblocked()(it takes an array of blockers, matches an exact count and an optional specific waiter, and returns every pid), andstanding-git-conversation.ts's fixture server (it runs only withOCC_TEST_STANDING_GIT_CODEX, which CI does not set).Verification
tsc --build tsconfig.json tests/tsconfig.json: clean.eslintandprettier --checkon the four files: clean.FOR UPDATE: killed the approval test on both sides (the lock wait times out).FOR NO KEY UPDATE: killed the approval test on both sides (the statement filter no longer matches).lockLiveSessionwithoutFOR SHARE OF n: killed both "protected successor ... draft custody" expiry cases on both sides.generation=$4changed to>=: survived on both sides.waitForLockWaiterdescription moved into its JSDoc block, andinjectJson'ssessiontyped asstring | { cookie, origin? }). After that commit,tsc --build --forceis clean and both files pass 2/2 again.Risks
Test-only. The JSDoc additions affect type checking only.