Skip to content

fix: avoid redundant database permission updates - #146492

Merged
steipete merged 2 commits into
mainfrom
codex/swarm-database-permissions
Sep 13, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/swarm-database-permissions

Conversation

@steipete

@steipete steipete commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Related: #130741

What Problem This Solves

Agent database writes repeatedly rewrote filesystem permissions even when the database, sidecars, and private directory already had the required modes.

User Impact

Agent activity avoids redundant filesystem metadata writes while continuing to repair permission drift before committing database changes. Existing private modes, custom-directory ownership, and Windows behavior are preserved; no configuration or migration is required.

Why This Change Was Made

The existing permissions owner now reads current POSIX modes before applying changes. Permission-read or repair failures still roll back the transaction, and transient sidecars may disappear during the check without failing a valid write.

Evidence

The regression fails on the original implementation because an ordinary write makes four redundant permission changes; the updated owner makes none when modes already match. The tests also exercise special-bit and sidecar mode drift, rollback on permission errors, and disappearing sidecars.

Final focused tests passed: 20 permission, lease-owner, and incognito tests, plus three selected existing tests for custom directories, nested permission repair, and SQLite pragmas. One existing Windows-only test was skipped on macOS; the remaining tests in the large database suite were excluded by the explicit name filter. This slice establishes fewer metadata writes and unchanged permission behavior; it does not claim the full Swarm latency target.

The full canonical changed gate and independent P1 review pass. Existing permission-failure fixtures now create actual mode drift before injecting a repair failure; all rollback and runtime-publication assertions remain intact. Those original failures reproduced, then the repaired cases and four permission siblings passed. Exact-head CI passed before the patch-identical refresh onto current main; the native workflow will verify the final head before landing.

@clawsweeper

clawsweeper Bot commented Sep 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.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Sep 12, 2026
@steipete
steipete marked this pull request as ready for review September 12, 2026 21:28
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 12, 2026
@clawsweeper

clawsweeper Bot commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 12, 2026, 5:53 PM ET / 21:53 UTC (Revision 2).

ClawSweeper review

What this changes

The branch avoids redundant POSIX permission updates for agent databases, adds transaction-level regression coverage, and carries the TLS shutdown registration correction.

Merge readiness

✅ Ready for maintainer review

The permission optimization remains useful and is absent from current main and v2026.9.4. No actionable correctness or security defect was found; the TLS prerequisite is already merged.

Priority: P2
Reviewed head: adc052e64b1673093009dd6a96e17582c24dc982

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with meaningful regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository classification identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported transaction tests cover the permission owner; no end-to-end latency improvement is claimed or independently established.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository classification identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported transaction tests cover the permission owner; no end-to-end latency improvement is claimed or independently established.
Evidence reviewed 7 items Current main still performs redundant updates: The fetched main revision unconditionally calls chmod for the private directory and database file candidates; it has no mode-equality guard.
Latest release comparison: v2026.9.4 contains the same unconditional permission updates, so the optimization is not already shipped in the supplied latest release.
Permission and rollback contracts preserved: The new comparison includes special permission bits, retains unconditional Windows chmod, and preserves custom-directory handling and ENOENT tolerance. The unchanged transaction owner invokes permission repair before commit, excluding nested and incognito transactions.
Findings None None.
Security None None.

How this fits together

OpenClaw’s per-agent SQLite databases hold sessions and other agent state. Their permission owner protects the database directory and sidecar files during opening and before transaction commit.

flowchart TD
  A[Database open or agent write] --> B[Existing permission owner]
  B --> C[Check directory ownership policy]
  C --> D[Read current POSIX mode]
  D -->|Already correct| F[Continue database operation]
  D -->|Mode differs| E[Apply private permissions]
  B -->|Windows| E
  E -->|Success or vanished sidecar| F
  E -->|Permission error| G[Fail open or roll back write]
  D -->|Read error| G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +6, Tests +92. Total +98 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 2 12 6 +6
Tests 1 94 2 +92
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 106 8 +98

Review metrics

None.

Technical review

Best possible solution:

Keep permission checks fresh at the existing database owner while skipping metadata writes only when POSIX modes already match.

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

Yes, from source: an ordinary outer agent write calls the permission sweep, and current main unconditionally reapplies matching modes. Runtime reproduction was not performed in this read-only review.

Is this the best way to solve the issue?

Yes. The guard stays in the existing permission owner, preserves failure and platform behavior, and needs no schema, configuration, or migration change.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded database hot-path improvement that removes unnecessary filesystem metadata writes while preserving permission repair.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository classification identifies maintainer-authored work, so the external-contributor proof gate does not apply. Reported transaction tests cover the permission owner; no end-to-end latency improvement is claimed or independently established.

Evidence

What I checked:

  • Current main still performs redundant updates: The fetched main revision unconditionally calls chmod for the private directory and database file candidates; it has no mode-equality guard. (src/state/openclaw-agent-db-permissions.ts:24, 5270db64d8d0)
  • Latest release comparison: v2026.9.4 contains the same unconditional permission updates, so the optimization is not already shipped in the supplied latest release. (src/state/openclaw-agent-db-permissions.ts:24, 3a9d69db306c)
  • Permission and rollback contracts preserved: The new comparison includes special permission bits, retains unconditional Windows chmod, and preserves custom-directory handling and ENOENT tolerance. The unchanged transaction owner invokes permission repair before commit, excluding nested and incognito transactions. (src/state/openclaw-agent-db.ts:498, adc052e64b16)
  • Focused regression coverage: The complete test file covers zero redundant chmod calls, permission drift including special bits, rollback after stat/chmod failure, and a disappearing sidecar. Existing tests also protect custom parent-directory modes and outer-transaction repair. The captured PR body reports focused passing tests and changed checks; this read-only review did not execute them. (src/state/openclaw-agent-db.permissions.test.ts:88, adc052e64b16)
  • TLS prerequisite and actual merge scope: GitHub REST confirms fix(gateway): register TLS renewal with sidecar owner #146412 merged as b405e7f. Raw test-merge parents match the pinned base followed by the PR head; comparison against that base leaves only the permission implementation and tests, with no TLS delta. (src/gateway/server-startup-finish.ts:416, b405e7f64410)
  • Area-history routing: Current-main history records Peter Steinberger on both the database module split and recent database admission work. These support routing relevance, not a claim that either commit introduced the redundant updates. Following older history encountered an unavailable historical object, so introduction remains unverified. (src/state/openclaw-agent-db.ts, 7f5a5231dca1)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (1 earlier review cycle)
  • reviewed 2026-09-12T21:36:07.855Z sha adc052e :: needs maintainer review before merge. :: none

@steipete
steipete requested a review from a team as a code owner September 12, 2026 22:13
@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Sep 12, 2026
@steipete
steipete force-pushed the codex/swarm-database-permissions branch from dd53c05 to fd91f2d Compare September 12, 2026 22:44
@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui scripts Repository scripts and removed gateway Gateway runtime labels Sep 12, 2026
@steipete
steipete force-pushed the codex/swarm-database-permissions branch 2 times, most recently from 569ef25 to b5df578 Compare September 12, 2026 23:23
@steipete
steipete force-pushed the codex/swarm-database-permissions branch from b5df578 to 24d55d5 Compare September 12, 2026 23:58
@steipete
steipete merged commit 17cd8ee into main Sep 13, 2026
185 of 187 checks passed
@steipete
steipete deleted the codex/swarm-database-permissions branch September 13, 2026 00:43
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 13, 2026
* fix: avoid redundant database permission updates

* test: exercise auth permission repair after mode drift
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling app: web-ui App: web-ui maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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