Skip to content

perf(test): shorten the protected git reconcile wait in its postgres test - #3391

Merged
freeqaz merged 2 commits into
mainfrom
perf/reconcile-interval-option
Oct 24, 2026
Merged

freeqaz merged 2 commits into
mainfrom
perf/reconcile-interval-option

Conversation

@freeqaz

@freeqaz freeqaz commented Oct 24, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

bindRepositoryGitTransport reconciles a protected Git Driver on a fixed 1 s timer. postgres-external-protected-git waits for whole reconcile passes: the lost-rotation case has three "two more passes" waits plus waits for late settlement, so it spends about 10 s waiting out the timer.

Change

  • The wait between reconcile passes becomes a construction option (reconcileIntervalMs) of bindRepositoryGitTransport. The default stays 1 s. The worker passes no options, so production behaviour is unchanged, and no configuration or environment value reaches the option.
  • The existing test-only pendingLog argument moves into the same options object (common-logging.test.mjs updated).
  • postgres-external-protected-git binds the same loop with a 100 ms wait. Its pass-count assertions ("+2 passes", no installation attempt, no replay) are unchanged. With a shorter wait they observe more passes in the same steps.

Verification

postgres-external-protected-git before after
lost-rotation case, same host, 2 CPUs (full file) 24.8 s 14.2 s
lost-rotation case, same host, 4 CPUs 20.9 s 11.9 s
lost-rotation case, same host, 4 CPUs beside the lane's two heaviest neighbours 25.8 s 14.7 s
reconcile-bound waits in that case, same host 1.97 / 2.01 / 1.01 / 0.97 / 2.02 s 0.20 / 0.20 / 0.10 / 0.08 / 0.22 s
lost-rotation case, CI main 19.7 / 19.7 / 20.1 s; other PR runs today 19.6 / 23.5 / 23.0 / 24.4 s 20.3 / 16.1 s
file wall, CI main 74.4 / 74.0 / 74.3 s; other PR runs today 72.9 / 79.6 / 75.2 / 77.2 s 73.3 / 68.6 s

The case also waits for a controller-work retry with random jitter (postgres-work-queue.ts), so single CI samples of it vary by several seconds; the same-host pairs isolate the timer.

  • Mutant: the loop stops rescheduling after the first pass. The lost-rotation case fails (Timed out waiting for worker installs first material.).
  • Pinned at 2 CPUs: postgres-external-protected-git 20/20 (66.9-69.7 s); common-logging 20/20.
  • tsc --build tsconfig.json tests/tsconfig.json, eslint and prettier are clean on the touched files.
  • Internal review (higher effort, credential-proxy path): land with nits; the comment nit is applied.

Risks

  • This touches the credential-proxy composition (composition/repository-credentials/transport.ts). The production path keeps its 1 s cadence; only a test passes the option.
  • A faster loop in the test means more reconcile passes per step, which makes the existing no-effect assertions stricter, not weaker. Passes stay serial per binding.

…L test

bindRepositoryGitTransport reconciled a protected Git Driver on a fixed
1 s timer. postgres-external-protected-git waits for whole reconcile
passes (three "+2 passes" waits and the late-settlement waits in the
lost-rotation case), so it spent about 10 s waiting out that timer.

The wait between passes becomes a construction option. The worker
passes no options, so production keeps the 1 s cadence; no
configuration or environment value reaches it. The pending-log option
moves into the same options object. The test binds the same loop with
a 100 ms wait; its pass-count assertions are unchanged.
@freeqaz
freeqaz requested a review from a team as a code owner October 24, 2026 02:26
@clawsweeper

clawsweeper Bot commented Oct 24, 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@clawsweeper

clawsweeper Bot commented Oct 24, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR lets the protected Git integration test shorten reconciliation waits from 1,000 ms to 100 ms while preserving the worker default.

Example: The lost-rotation test waits for two additional reconciliation passes.

  • Before: Each completed pass schedules the next after 1,000 ms.
  • After: The test schedules the next after 100 ms; the worker still uses 1,000 ms.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful test optimization with preserved assertions and a passing PostgreSQL check, held by the added test-only production seam.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored test-performance change is outside the ordinary contributor proof gate; the supplied evidence is an in-process PostgreSQL journey and reported local timing, with no changed production authority boundary.
Patch quality 🦐 gold shrimp (3/6) 1 actionable review finding remain.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Contributors wait through repeated one-second reconciliation delays in the protected Git PostgreSQL integration test.
Reason: The maintainer-authored direction addresses measurable test latency without requesting a new operator setting or production behavior.

Merge readiness

⛔ Needs changes before merge - 1 item remains

Keep this PR open: the test speedup has value, but its new test-only production timing hook conflicts with the repository’s required test-audit guidance.

Priority: P3
Reviewed head: b0422f180eb07dfd09cf18c2341bdefcaf836377

Before merge

  • Keep test timing control out of the production binding (P2) - The new reconcileIntervalMs hook has only test callers, as both its documentation and the worker call site confirm. AGENTS.md mandates test-audit for changed tests, whose authoring gate explicitly directs tests away from injection hooks that no production caller needs. This optimization therefore adds a production seam contrary to the applicable test policy. Remove the interval option and control scheduling within the integration harness, preserving the real reconciliation loop and existing pass-count, withdrawal, and no-replay checks; the logging test already demonstrates test-owned timer advancement.

Findings

  • [P2] Keep test timing control out of the production binding — apps/controller/src/composition/repository-credentials/transport.ts:69-70
Agent review details

How this fits together

Worker composition binds the selected protected Git Driver to the prepared credential owner and repeatedly invokes its reconciliation operation until shutdown.

flowchart LR
  Worker[Controller worker] --> Binding[Transport binding]
  Test[PostgreSQL integration test] --> Binding
  Binding --> Driver[Selected protected Git Driver]
  Driver --> Owner[Prepared credential owner]
  Owner --> Database[PostgreSQL]
Loading

Technical review

Best possible solution:

Keep the production binding’s scheduling contract fixed and accelerate the integration scenario through test-owned timer control while retaining its real reconciliation and no-replay assertions.

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

This is a test-performance change rather than a reported product failure; source confirms the fixed waits, and the PR reports a local before-and-after timing comparison.

Is this the best way to solve the issue?

The scheduling default and consequential assertions are preserved, but moving timing control into the test harness better follows the required test-audit policy.

Full review comments:

  • [P2] Keep test timing control out of the production binding — apps/controller/src/composition/repository-credentials/transport.ts:69-70
    The new reconcileIntervalMs hook has only test callers, as both its documentation and the worker call site confirm. AGENTS.md mandates test-audit for changed tests, whose authoring gate explicitly directs tests away from injection hooks that no production caller needs. This optimization therefore adds a production seam contrary to the applicable test policy. Remove the interval option and control scheduling within the integration harness, preserving the real reconciliation loop and existing pass-count, withdrawal, and no-replay checks; the logging test already demonstrates test-owned timer advancement.
    Confidence: 0.88

Overall correctness: patch is incorrect
Overall confidence: 0.88

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • node --test tests/integration/common-logging.test.mjs
  • node --test tests/integration/postgres-external-protected-git.test.ts
  • pnpm lint
  • pnpm format:check
  • pnpm check:workspace

What I checked:

Labels

Label changes:

  • add P3: This is an integration-test performance improvement with no observed change to production cadence or user behavior.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • P3: This is an integration-test performance improvement with no observed change to production cadence or user behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🦐 gold shrimp.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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.

Reviewed October 23, 2026, 10:39 PM ET / October 24, 2026, 02:39 UTC.

@freeqaz

freeqaz commented Oct 24, 2026

Copy link
Copy Markdown
Collaborator Author

On the P2 finding (test-only timing option on the production binding): this design was chosen on purpose, and the alternatives were worse.

  • bindRepositoryGitTransport already takes a test-only construction argument, pendingLog, which common-logging.test.mjs injects with a fake clock. This PR moves the interval next to it in one options object. It does not add a second kind of seam. The worker passes no options, and no configuration or environment value can reach either one.
  • Owning the timer from the harness is not workable for this test. It is a real-time PostgreSQL journey with live HTTPS peers, Git child processes, pg pool timers and waitFor polling. Mocking setTimeout for the whole process (what the logging test does for its in-memory loop) would stall all of those. Patching the timer only for this module would mean patching production code from the test, which AGENTS.md rules out.
  • The assertions still exercise the real loop: every pass-count, no-replay and withdrawal check is unchanged.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 24, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 24, 2026
@freeqaz
freeqaz merged commit 3c78b66 into main Oct 24, 2026
56 checks passed
@freeqaz
freeqaz deleted the perf/reconcile-interval-option branch October 24, 2026 03:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P3 Low-risk cleanup, docs, polish, ergonomics, or speculative feature. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant