Skip to content

test(postgres): sign the provisioning administrator in once per file - #2965

Merged
freeqaz merged 3 commits into
mainfrom
test-deslop-1019c
Oct 19, 2026
Merged

freeqaz merged 3 commits into
mainfrom
test-deslop-1019c

Conversation

@freeqaz

@freeqaz freeqaz commented Oct 19, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

tests/integration/postgres-agent-provisioning.test.mjs is the slowest file in the PostgreSQL Platform lane, with a CI median of 86.4 s over 15 green main runs. The lane runs 2 files at a time and sums to 263 s, so each second saved in this file cuts about 0.5 s from the lane (median 132 s).

Every createFixture call signed the same bootstrap administrator in again: 64 sign-ins per run, about 210 ms each of password hashing. Instrumented locally at 2 CPUs, those sign-ins took 13.6 s of an 87.6 s run. Some of that overlaps other async work and some is instrumentation overhead, so the measured saving is about 7 s, not 13.6 s. All other fixture setup together took about 9 s: app composition 1.5 s, Namespace readiness 7.3 s, worker stops 0.4 s.

Change

This is test-only. No assertion changes. createFixture's text is unchanged, but its sign-in call now goes through the file-local wrapper.

  • A file-local signInToControllerApp wraps the helper. For the bootstrap administrator it signs in once per set of sign-in options and returns that same session to every later fixture. Every other account, or the administrator with any other password, still signs in on every call, as before (the source-requester and second-administrator cases).
  • Each fixture still composes its own app against the same database and auth secret, so the stored session is valid in all of them.
  • A failed sign-in is not cached.

Why no state can leak between tests:

  • The session is only authentication. No test signs out, ends or revokes a session.
  • The tests that revoke the administrator's Installation bindings (revokeCurrentPrincipal) restore them in that fixture's teardown, before the next test starts, exactly as before.
  • Authorization still runs on every request.
  • The administrator was already the same account in every fixture, and the file's tests already run one after another in one database.
  • Keying by sign-in options also covers fix: prepare native admin access on the first Agent deployment #2259. That PR signs in against a production origin for its native-admin cases, and those get their own session.

Verification

  • Pins: 20 runs at 2 CPUs (CPUs 4-5), each on a freshly prepared database: 20/20, 55 tests each.
  • Mutants: 16 mutants of packages/occ/src/index.ts, covering provisioning stop/delete cancellation, the Configuration settle window, retry admission, the request read check, the abandoned-effect wait, replay fingerprints, request authorization and Namespace readiness. Each ran against main's file and this file, each run on a fresh database. The kill sets are equal for every mutant, matched by test name. 9 are killed and 7 survive on both sides.
Mutant Killing tests (main = this PR)
stop_no_cancel 5
delete_no_cancel 3
settle_const_30s 3
replay_fingerprint 2
retry_running_returns 1
read_actor 1
abandoned_transport_wait 1
request_admin_install 1
stop_cancel_message 1
settle_window_short, retry_actor, retry_after_cancel, retry_agent_lifecycle, abandoned_agent_deleting, retry_namespace_ready, provision_namespace_ready survive on both
  • Time: paired runs at 2 CPUs (CPUs 4-5), alternating main's file and this one, each on a fresh database, load 3-10.
main this PR
Runs (s) 81.9, 84.6, 83.7, 84.0 77.8, 77.4, 76.4, 76.1
Median (s) 83.8 76.9
Same check after rebasing on f92cc40 (s) 82.9 78.8

CI estimate: the file drops from 86.4 s to about 79 s (-8%), and the PostgreSQL Platform lane from 132 s to about 128.5 s. The remaining time is mostly waits: about 10 s of retry backoff jitter that the test can't inject, and Namespace readiness.

Risks

  • A future test that ends the administrator's session would break the later tests in this file. Such a test should sign in a separate account, as the existing second-administrator case does. The comment above the wrapper says so.
  • The lane gain is small, about 3.5 s on the PostgreSQL Platform lane. That lane does not set CI Required's length.

Every fixture in postgres-agent-provisioning signed the same bootstrap
administrator in again (about 210 ms of password hashing each, 64
fixtures, about 13 s of an 87 s file at 2 CPUs). Each fixture's app
reads the same stored session (same database and auth secret), so the
file now signs in once and reuses that session. No test ends it; tests
that need another identity still sign that account in themselves.
…touching the fixture

Open #2259 rewrites createFixture's compose/sign-in lines and signs in
against a production origin for native-admin cases. Keying the shared
administrator session by sign-in options, and wrapping the helper
instead of editing createFixture, keeps that PR conflict-free and gives
its https origin its own session.
@freeqaz
freeqaz requested a review from a team as a code owner October 19, 2026 20:22
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@clawsweeper clawsweeper Bot added P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 19, 2026
…password

A test that signs the administrator in with a wrong password to check refusal must not get the
cached session. Also reword the wrapper comment: the key is the set of sign-in options.
@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses the bootstrap administrator’s authenticated session across PostgreSQL provisioning fixtures while preserving separate sign-ins for other credentials.

Example: Run all 55 PostgreSQL provisioning tests against a fresh database.

  • Before: The reported run performs 64 bootstrap administrator sign-ins during fixture creation.
  • After: Fixtures reuse one successful administrator sign-in; other accounts and passwords bypass the cache.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused patch appears correct and exact-head CI passes; performance and mutation evidence remains reported harness validation rather than independently inspected execution artifacts.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored, test-only change has no changed shipped entry point; reported PostgreSQL repetitions and mutation comparisons support it, and exact-head PostgreSQL Platform CI passed.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Contributors repeatedly pay password-authentication costs while running the PostgreSQL provisioning suite.
Reason: The maintainer-authored optimization has a measured benefit, a small test-only footprint, and unchanged behavioral assertions.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR makes a focused fixture optimization, with passing checks on the exact head and no actionable defect found.

Priority: P3
Reviewed head: 8b1ef0a03ab2de24bc5fb7713f8940edd8780b2b

Before merge

None.

Findings

None.

Agent review details

How this fits together

The integration fixtures compose controller applications against shared PostgreSQL storage and send authenticated provisioning requests through Fastify, IAM, and the durable worker.

flowchart LR
  Fixtures[Provisioning fixtures] --> Cache[File-local session cache]
  Cache --> Auth[Controller sign-in]
  Auth --> Database[Shared PostgreSQL database]
  Cache --> Requests[Fastify requests]
  Requests --> IAM[Current IAM authorization]
  IAM --> Database
Loading

Technical review

Best possible solution:

Retain file-local administrator session reuse while preserving independent fixture applications, live authorization checks, and separate credentials for identity-specific scenarios.

Do we have a high-confidence way to reproduce the issue?

Current main visibly signs the same administrator credentials in during every fixture creation; the magnitude of the cost comes from author-reported measurements.

Is this the best way to solve the issue?

The narrow wrapper shares authentication without bypassing request authorization, preserves existing fixture ownership, and avoids overlapping fixture edits in related work.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 5a2cb363d5b2.

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Kevin: Raw commit 8adfd86 adds tests/integration/postgres-agent-provisioning.test.mjs:243 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8adfd86e96a1; files: tests/integration/postgres-agent-provisioning.test.mjs)

Review metrics

Metric Value Why it matters
Patch footprint Production +0/-0; tests +26/-1 A single fixture-local wrapper reduces repeated authentication setup without adding production seams or changing assertions.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This is a limited test-performance improvement with no changed user-facing runtime behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (1 earlier review cycle)
  • reviewed 2026-10-19T20:35:05.781Z sha b8db7da :: needs maintainer review before merge. :: none

Reviewed October 19, 2026, 5:16 PM ET / 21:16 UTC (Revision 2).

@freeqaz

freeqaz commented Oct 19, 2026

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@freeqaz
freeqaz merged commit dd92bd6 into main Oct 19, 2026
43 of 44 checks passed
@freeqaz
freeqaz deleted the test-deslop-1019c branch October 19, 2026 21:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant