Skip to content

perf(state): reuse admitted paths for agent database validation - #169701

Merged
steipete merged 1 commit into
mainfrom
steipete/perf-micro-main-thread-sync-fs-20260919
Oct 12, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/perf-micro-main-thread-sync-fs-20260919

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Agent and session reads repeatedly resolve the database pathname even though their open connection already owns a canonical path. Retargeting a symlink can also make that still-open connection lose its validation receipt.

User Impact

Keeps validation bound to the database the connection actually opened and removes synchronous filesystem work from repeated validation reads. No schema, configuration, or update migration changes.

Why This Change Was Made

Reuse the canonical path already captured by the connection identity owner for validation lookup, lifetime binding, adoption, and publication. Existing shared revocation cells still govern validity. Path-only readers, new admission, explicit invalidation, and repair retain their current filesystem checks.

Production LOC: −7. No additional cache or invalidation lifecycle.

Evidence

  • Extended the existing symlink-retarget regression: an open alias retains its original receipt, the replacement keeps its own receipt, and revoking the original does not revoke the replacement. Fails on the old implementation and passes with this change.
  • pnpm test src/state/openclaw-agent-db-identity.test.ts src/state/openclaw-agent-db-validation-cache.test.ts --maxWorkers=1: 59 passed. Overall cold local wall time 214.74 s, including compiler preparation; test execution was about 55 s across the two existing files. No new test file or added fixture boot.
  • Changed-file oxfmt, repository oxlint, and git diff --check: passed. Independent autoreview: no actionable findings.
  • Linux isolated validation measurement, 100,000 warm integrity/canonical validation pairs: 4,266.2 → 42.4 ms elapsed; main-thread CPU 4,098.6 → 41.8 ms. Native realpath SELF 3,748.2 → 0 ms, or 37.48 → 0 ms per 1,000 pairs. No filesystem calls remain in those warmed getters.
  • Full synthetic Gateway baseline: 20 sessions × 5 turns, one agent database, 400 history reads and 100 session-list reads. The changed handle-bound lookups account for 492.6 ms of native realpath SELF. The candidate completed its load/profile window but the diagnostics helper was killed during cleanup, so it is recorded as a failed benchmark, not passing end-to-end proof. No whole-Gateway throughput claim.
Main-isolate native SELF in the changed validation paths Before After
Measured window (100 completed turns, 500 UI reads) 492.6 ms 0 ms
Normalized per 1,000 completed agent turns 4,926.2 ms 0 ms
Normalized per 1,000 UI reads 985.2 ms 0 ms

These normalize the same mixed-workload window; they are not exclusive per-request attribution. Remaining native filesystem SELF was 11,523.5 → 9,398.0 ms in these separate samples, dominated by other owners, including filesystem watcher guards. Contention and the candidate cleanup failure prevent attributing that overall difference to this patch.

Full typecheck, suites, and other broad gates are delegated to this PR's CI. No Testbox/Crabbox leases were allocated; the Linux rig was used only for measurements. No production Gateway was accessed.

Keep validation receipts bound to the physical connection when a filesystem alias is retargeted. Reuse the canonical path already captured at open instead of synchronously resolving it on every validation read. Preserve path-only admission, revocation, and repair checks.
@clawsweeper

clawsweeper Bot commented Oct 12, 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 P2 Normal backlog priority with limited blast radius. 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 12, 2026
@clawsweeper

clawsweeper Bot commented Oct 12, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses each open agent database connection’s captured canonical path for validation lookup and publication.

Example: An open /state/alias.sqlite connection points to /state/original.sqlite, then the alias is retargeted to /state/replacement.sqlite.

  • Before: Validation follows the retargeted alias and stops finding the original connection’s receipt.
  • After: The connection retains the original receipt; revoking the original leaves the replacement’s receipt valid.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused implementation with meaningful owner-level regression coverage; successful shipped-entry-point evidence is limited.
Proof confidence 🦐 gold shrimp (3/6) The supplied maintainer-authored designation exempts this PR from the external-contributor proof gate; completed evidence covers the real SQLite owner regression and isolated getter measurements, while the failed Gateway benchmark supplies no successful end-to-end claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes · Fix scope: Complete
User problem: Repeated session reads perform synchronous pathname resolution, and an open aliased connection can lose its validation receipt after retargeting.
Reason: The established feature owner proposes a smaller implementation that restores connection-bound identity and follows the recorded admission contract.

Merge readiness

✅ Ready for maintainer review

Keep open: this focused performance and receipt-identity repair remains necessary on current main, and no actionable correctness or security defect was found.

Priority: P2
Reviewed head: 4abf1a2c25a7e8587b16a43b2e243d5a42822cd1

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The submitted Gateway benchmark did not finish successfully, so it does not establish shipped-entry-point receipt retention or whole-Gateway throughput.
Agent review details

How this fits together

Agent database openers capture physical identity and canonical path; session readers consume validation receipts from the process-local cache, with shared cells carrying revocation.

flowchart TD
  A[Database opener] --> B[Captured connection identity]
  B --> C[Validation cache]
  C --> D[Session readers]
  E[Schema and lifecycle revocation] --> C
  F[New path admission] --> A
Loading

Technical review

Best possible solution:

Use the connection-owned canonical path for handle-bound receipts while retaining physical admission, path-only checks, and shared revocation.

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

Current-main lookup resolves the retargeted alias, finds the replacement receipt, and rejects its physical identity for the original connection; the extended regression exercises this exact path, though no tests were run during this read-only review.

Is this the best way to solve the issue?

Reusing the identity owner’s captured path fixes the lookup at its source and removes repeated filesystem work without introducing another state owner.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Canonical alias keying keeps the original intent (efd0653: Unify reader and writer receipt keys through filesystem aliases without rewriting configured or persisted paths.)
  • Physical validation and shared revocation keeps the original intent (694f9ae: Reuse successful physical validation across reopens while retaining replacement, registry, corruption, and lifecycle invalidation.)
  • Canonical receipt lifetime and promotion keeps the original intent (b5c9a25: Preserve healthy admission and shared revocation cells when concurrent checked openers converge.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 694f9ae adds src/state/openclaw-agent-db-validation-cache.ts:34 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 694f9ae3a81f; files: src/state/openclaw-agent-db-validation-cache.ts)

PR surface

Source -7, Tests +17. Total +10 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 18 25 -7
Tests 1 17 0 +17
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 35 25 +10

Review metrics

Metric Value Why it matters
Production versus test LOC Production net −7; tests +17 The implementation removes repeated resolution without adding another cache, and the test growth extends an existing lifecycle regression.

Labels

Label changes:

  • add P2: A focused improvement removes synchronous filesystem work and repairs receipt lookup after alias retargeting, with no demonstrated urgent widespread outage.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A focused improvement removes synchronous filesystem work and repairs receipt lookup after alias retargeting, with no demonstrated urgent widespread outage.
  • 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.

Reviewed October 12, 2026, 3:11 AM ET / 07:11 UTC.

@steipete
steipete merged commit e14e919 into main Oct 12, 2026
124 checks passed
@steipete
steipete deleted the steipete/perf-micro-main-thread-sync-fs-20260919 branch October 12, 2026 07:19
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 13, 2026
…claw#169701)

Keep validation receipts bound to the physical connection when a filesystem alias is retargeted. Reuse the canonical path already captured at open instead of synchronously resolving it on every validation read. Preserve path-only admission, revocation, and repair checks.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: S 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