Skip to content

perf(auth): unblock session writes during health preparation - #170807

Merged
steipete merged 2 commits into
mainfrom
steipete/perf-micro-direct-reservation-holds-20260919
Oct 13, 2026
Merged

steipete merged 2 commits into
mainfrom
steipete/perf-micro-direct-reservation-holds-20260919

Conversation

@steipete

@steipete steipete commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Auth health bookkeeping reserved every candidate agent database before asynchronous credential reads chose the actual owner. Read-only child startup and row loading therefore held the agent writer FIFO even when the eventual health update belonged to shared state. Session writes queued behind this unrelated preparation.

User Impact

Session writes can continue while auth health preparation reads credentials or awaits provider observations. No operator action or migration is required.

Why This Change Was Made

Keep the existing auth preparation FIFO and captured execution/lifecycle authority, and reserve only the selected database when health recording is ready. Ready writes retain FIFO, fresh credential/removal checks, worker rereads, live transaction/commit grants, publication, and accepted-work cleanup. Delete the speculative reservation helper and candidate writer map. No schema, stored-shape, config, retention, or updater migration changes; 61 fewer production lines.

Evidence

ABBA in an isolated Linux benchmark sandbox, using the real markAuthProfileFailure entry point, synthetic credentials/state, and a follower agent writer. Each leg ran eight calls; the first cold call is excluded from the medians below. The same checkout, dependencies, and command were used throughout; only the two production files changed.

Leg Follower admission wait Main-thread active time Auth completion
A1 baseline 2073.258 ms 21.905 ms 2074.291 ms
B1 candidate 0.612 ms 15.998 ms 1446.814 ms
B2 candidate 0.747 ms 19.492 ms 2028.588 ms
A2 baseline 1532.319 ms 18.978 ms 1533.350 ms

Across 14 warmed calls per variant, median follower admission wait falls from 1694.604 ms to 0.694 ms (99.96% reduction). Main-thread active time is 20.169 → 17.324 ms, neutral within host noise. Auth completion remains dominated by the unchanged off-thread child work (1.4–2.1 s across leg medians); no health-completion speedup is claimed.

Live diagnostics identify the main-thread direct hold and following session-write backlog but do not label the caller. This synthetic auth entry point reproduces the blockage without a large scan, VACUUM, or migration. Other direct reservation families (transcript/actor reads and writes, auth saves, and small side-data stores) are outside this scoped fix. Post-deployment attribution is still unmeasured.

Proof

  • pnpm test src/agents/auth-profiles/usage.write-admission.test.ts --maxWorkers=1: 16 passed; 264.61 s Vitest / 286.87 s wrapper wall time, including a cold worker-artifact preparation (132.667 s) on the saturated host.
  • Cold-read regression permits an unrelated database writer before the real auth read completes. Ready-write FIFO, owner revocation/relocation, profile removal, shared ownership, publication, and Windows capture remain covered.
  • On unchanged baseline production code, the cold/current-owner regression fails at expect(writerEntered).toBe(true): the follower stays behind the unfinished read. Candidate passes that same assertion. Baseline selected run: 1 failed / 15 skipped, 169.35 s Vitest / 199.60 s wrapper (126.862 s worker preparation).
  • pnpm test src/agents/auth-profiles/usage-lifecycle.test.ts src/agents/auth-profiles/usage.inherited-owner.test.ts src/agents/auth-profiles/usage.test.ts --maxWorkers=1: 51 passed across three focused sibling files (144.19 s infra / 58.17 s agents-support Vitest durations, plus 91.439 s worker preparation; 328.57 s total wrapper wall time).
  • Formatting on changed files and syntax lint passed. Default changed-file lint unexpectedly requested plugin declaration compilation and timed out; full type-aware lint/typecheck and broader gates are delegated to PR CI.
  • independent subagent review (autoreview route unavailable): no actionable P0–P2 findings. Autoreview preflight refused the requested provider because it did not match operator config; no configuration was changed.
  • No Testbox/Crabbox leases allocated under the lane validation rule. Benchmark host is used only for measurement.
  • Initial CI run 38366924243 passed all node lanes, production types, lint, docs, architecture guards, and UI checks. Its only underlying failure was TS2322 in the changed test fixture: the factory's broad return type lost its guarantee that the named credential exists. The factory now declares that existing shape explicitly; independent review found no actionable issue in this test-only correction. Production and measured behavior are unchanged.
  • After that fixture correction, the same focused admission command passed all 16 tests again: 459.64 s Vitest / 517.33 s wrapper wall time, including 182.680 s worker preparation. Changed-file formatting and syntax lint passed again.
  • Full PR CI on corrected head 1bdefc090055a3d9bb03d41e8c6ed5ef1bf4d557: run 38369846448 succeeded with all 40 planned jobs green, including production/test types, lint, all selected node lanes, docs, architecture guards, UI E2E, and openclaw/ci-gate; 625 s elapsed. Applicable security and quality checks also passed.

Capture auth execution authority before preparation, but reserve only the selected agent database when recording is ready. Keep overlapping health preparations ordered and preserve fresh credential checks, FIFO ready writes, worker commit publication, and accepted-work settlement.
@clawsweeper

clawsweeper Bot commented Oct 13, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation agents Agent runtime and tooling size: S labels Oct 13, 2026
@steipete
steipete marked this pull request as ready for review October 13, 2026 08:05
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-13T08:10:09.676846Z 99b95a0 Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

⚠️ Security sensitive changes

This maintainer PR changes sensitive security components.

No secops approval is required. This comment is informational because the PR author has Maintain or Admin access.

  • Current SHA: 1bdefc090055a3d9bb03d41e8c6ed5ef1bf4d557
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/auth-profiles/usage-lifecycle.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.
  • src/agents/auth-profiles/usage-write.ts: Controls credential persistence, secret resolution, or redaction. Check storage permissions, credential scope, and exposure in logs or responses.

Carefully review these changes before merging.

@steipete
steipete merged commit 4dd4b8e into main Oct 13, 2026
130 of 132 checks passed
@steipete
steipete deleted the steipete/perf-micro-direct-reservation-holds-20260919 branch October 13, 2026 08:45
vincentkoc added a commit that referenced this pull request Oct 13, 2026
* commit '7ae69497bec4d9c37f170f046a3cbbf954ff19a7': (6238 commits)
  refactor(ui): replace Systems filters with native menu (#170786)
  fix(browser): browser open honors timeoutMs for its opening navigation (#170053)
  refactor: deslop old Apple shared/macOS and Control UI code (#170823)
  perf(memory): reuse pooled origin readers (#170795)
  fix(crabbox): preserve project snapshots across runtime updates (#170780)
  fix: prevent chat image loading from shifting messages (#170819)
  refactor(ui): use native menus for Secret Store actions (#170663)
  fix(gateway): keep chat metadata available during model reloads (#170805)
  fix: preserve diagnostics for unresponsive state lease heartbeats (#170835)
  fix(test): prepare runtime config for corpus revision proof
  test: give credential fixtures database ownership
  perf(auth): unblock session writes during health preparation (#170807)
  fix(ci): use smaller runners for selected Gateway client tests (#170821)
  fix: use same-commit plugins in development macOS builds (#170776)
  perf(github): share cached reads across sessions and searches (#170825)
  fix(projects): keep listings stable during unrelated session changes (#170824)
  fix(update): update repair fails after Doctor completes on busy macOS hosts (#170779)
  fix(heartbeat): suppress truncated NO_REPLY finals such as NO_R (#170190)
  perf(sessions): reduce read transaction overhead (#170745)
  refactor: simplify older plugin and package lifecycles (#170800)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 14, 2026
…w#170807)

* perf(auth): unblock session writes during health preparation

Capture auth execution authority before preparation, but reserve only the selected agent database when recording is ready. Keep overlapping health preparations ordered and preserve fresh credential checks, FIFO ready writes, worker commit publication, and accepted-work settlement.

* test(auth): preserve admission fixture credential type
vincentkoc added a commit that referenced this pull request Oct 18, 2026
* feat(qa): report scorecard evidence gaps

Distinguish catalog coverage, recorded attempts, and qualified evidence without changing scores or release gates.

Include the canonical compatibility migration-status correction from ec1fb60.

Co-authored-by: Patrick Erichsen <[email protected]>

* chore(qa): drop compatibility backport already on main

Keep the QA evidence-gap change scoped to its 13 paths. The canonical compatibility correction ec1fb60 and later refinements are already on main; restore the six branch preimages so the merge consumes that upstream owner state.

* chore(qa): integrate canonical worker settlement fixes

* commit '7ae69497bec4d9c37f170f046a3cbbf954ff19a7': (6238 commits)
  refactor(ui): replace Systems filters with native menu (#170786)
  fix(browser): browser open honors timeoutMs for its opening navigation (#170053)
  refactor: deslop old Apple shared/macOS and Control UI code (#170823)
  perf(memory): reuse pooled origin readers (#170795)
  fix(crabbox): preserve project snapshots across runtime updates (#170780)
  fix: prevent chat image loading from shifting messages (#170819)
  refactor(ui): use native menus for Secret Store actions (#170663)
  fix(gateway): keep chat metadata available during model reloads (#170805)
  fix: preserve diagnostics for unresponsive state lease heartbeats (#170835)
  fix(test): prepare runtime config for corpus revision proof
  test: give credential fixtures database ownership
  perf(auth): unblock session writes during health preparation (#170807)
  fix(ci): use smaller runners for selected Gateway client tests (#170821)
  fix: use same-commit plugins in development macOS builds (#170776)
  perf(github): share cached reads across sessions and searches (#170825)
  fix(projects): keep listings stable during unrelated session changes (#170824)
  fix(update): update repair fails after Doctor completes on busy macOS hosts (#170779)
  fix(heartbeat): suppress truncated NO_REPLY finals such as NO_R (#170190)
  perf(sessions): reduce read transaction overhead (#170745)
  refactor: simplify older plugin and package lifecycles (#170800)
  ...

* fix(gateway): preserve safe previews and no-op bindings

Clear only the matching pending binding operation after an authoritative unchanged settlement, preserving committed and unknown invalidation fences.

Include the canonical managed-media preview correction from 47ba0ae.

Co-authored-by: Peter Steinberger <[email protected]>

* merge(main): reconcile QA reporting with frozen main

* test(gateway): verify retained route authority after binding settlement

Co-authored-by: Patrick Erichsen <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 18, 2026
* feat(qa): report scorecard evidence gaps

Distinguish catalog coverage, recorded attempts, and qualified evidence without changing scores or release gates.

Include the canonical compatibility migration-status correction from 3f6d26f.

Co-authored-by: Patrick Erichsen <[email protected]>

* chore(qa): drop compatibility backport already on main

Keep the QA evidence-gap change scoped to its 13 paths. The canonical compatibility correction 3f6d26f and later refinements are already on main; restore the six branch preimages so the merge consumes that upstream owner state.

* chore(qa): integrate canonical worker settlement fixes

* commit '4ae87487b6eca95ac58a2f18de0e742b240772eb': (6238 commits)
  refactor(ui): replace Systems filters with native menu (openclaw#170786)
  fix(browser): browser open honors timeoutMs for its opening navigation (openclaw#170053)
  refactor: deslop old Apple shared/macOS and Control UI code (openclaw#170823)
  perf(memory): reuse pooled origin readers (openclaw#170795)
  fix(crabbox): preserve project snapshots across runtime updates (openclaw#170780)
  fix: prevent chat image loading from shifting messages (openclaw#170819)
  refactor(ui): use native menus for Secret Store actions (openclaw#170663)
  fix(gateway): keep chat metadata available during model reloads (openclaw#170805)
  fix: preserve diagnostics for unresponsive state lease heartbeats (openclaw#170835)
  fix(test): prepare runtime config for corpus revision proof
  test: give credential fixtures database ownership
  perf(auth): unblock session writes during health preparation (openclaw#170807)
  fix(ci): use smaller runners for selected Gateway client tests (openclaw#170821)
  fix: use same-commit plugins in development macOS builds (openclaw#170776)
  perf(github): share cached reads across sessions and searches (openclaw#170825)
  fix(projects): keep listings stable during unrelated session changes (openclaw#170824)
  fix(update): update repair fails after Doctor completes on busy macOS hosts (openclaw#170779)
  fix(heartbeat): suppress truncated NO_REPLY finals such as NO_R (openclaw#170190)
  perf(sessions): reduce read transaction overhead (openclaw#170745)
  refactor: simplify older plugin and package lifecycles (openclaw#170800)
  ...

* fix(gateway): preserve safe previews and no-op bindings

Clear only the matching pending binding operation after an authoritative unchanged settlement, preserving committed and unknown invalidation fences.

Include the canonical managed-media preview correction from f3260b9.

Co-authored-by: Peter Steinberger <[email protected]>

* merge(main): reconcile QA reporting with frozen main

* test(gateway): verify retained route authority after binding settlement

Co-authored-by: Patrick Erichsen <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Co-authored-by: Vincent Koc <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling docs Improvements or additions to documentation security-sensitive-changed size: S

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant