Skip to content

refactor(storage): reduce duplicate reads around final authority guards - #167571

Merged
steipete merged 8 commits into
mainfrom
dbasync/t1guards
Oct 9, 2026
Merged

steipete merged 8 commits into
mainfrom
dbasync/t1guards

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Related: #166703

What Problem This Solves

Final permission and lifecycle checks must observe native and foreign-process writes immediately before privileged effects; earlier worker migrations left duplicate preparation reads around those checks.

User Impact

The affected operations retain live permission and lifecycle checks while avoiding duplicate preparation reads. No schema migration, configuration, durability, retention, permission change, or operator action is required.

Why This Change Was Made

Workshop joins source permissions, lifecycle revision, and the accepted transcript anchor into one current statement. Sandbox completion checks its captured generation inside the existing worker transaction, and guarded remote-shell commands check authority at native launch. Worktree GC reuses its prepared census and makes one live owner-state decision at final admission. ClickClack hydrates indexes in its existing session queues, prepares descriptive facts asynchronously, and preserves fresh binding/revocation checks for visibility and mutations.

Released synchronous SDK signatures remain available. The new async session reader is optional. Short cross-owner authority reads remain live until native/foreign writers can publish complete revocation facts; their retirement path is the next Plugin SDK major, documented in worker-access.md.

Evidence

Reviewed head: 65baafdd29e6a4ef15972d866ea8571e9f4286dc. Fresh P2 reviews were scoped-clean. ClawSweeper review completed on this exact head at 2026-10-09T07:36:24.272Z with zero code findings. The original sandbox recreation finding is fixed.

SQL disposition: five valid remote alternating pairs replace the invalid earlier local comparison. Changed-path first/warmed SQL and requests are identical in every sample. Warmed median +0.126% is entirely unchanged-owner variance within the explicit 0.5% allowance. Raw first-turn +44 and combined startup +13 remain visible below: these are attributed unchanged startup/maintenance work, not a literal numerical pass. Under the latest landing instruction to fix PR-caused increases and otherwise land, this qualifies; no consolidated guard adds warmed statements. Later conflict integrations preserve the final guard SQL, so no redundant full series was run.

Published-driver update passed on AWS Linux/x64: released 2026.9.9 updated to the exact reviewed commit, all command exit records are zero, /readyz returned 200, the running build is 65baafdd29e6a4ef15972d866ea8571e9f4286dc, and durable/incognito post-update checks passed. The recorded run 42a8d8aa-c6be-4567-b849-55b84d935003 finished with status succeeded. The full canonical cell took 482.884 s, including 387.480 s for the update command, with its original 1125 s budget unchanged. Package build/integrity passed in 463.8 s; tarball SHA-256 6ba28d08dc7708e8aa727b102521933aeabd412a55207a8c18ec0a218ff4f839.

The earlier local Linux/arm64 Docker cell remains a failed observation: exit 124 after 1095.99 s while activation was beginning, despite successful candidate admission, Doctor, canary startup and previous-Gateway verification. It was CPU/I/O active, not OOM-killed. This remote pass does not claim to fix that local timing limitation. Recovery first encountered a lossy host upload, then a dependency-install quota in /tmp; the final build used the same source/lockfile under the advertised /work filesystem, without raising quotas or weakening timeouts. The original local package SHA-256 was 4b895c7aac03d31c1f7308a896e8066910ae1c3dda8775dd84b8d94386367de7; it was not used by the final rebuilt AWS cell. A non-fatal startup gzip warning (365.2 KiB versus 364.7 KiB) is retained, not suppressed.

Landed through the native admin route as 83ce1401d658f4c723063a9900ba5af9bcbb5adb. Native receipt verification and the landing-parent audit matched parent 94c0f0d589ab60ffd91d51fb1a433231961e2562; independent security and current authority passed admission. The CI exception below retains failed and cancelled coverage honestly. Final main also contained incidental helper extraction #167646 in ClickClack service-open.ts; the inspected, conflict-free composition preserves those helpers and this PR's worker preparation and live guards.

Repairs and integration

ClawSweeper identified an actual Docker/Podman recreation bug: registry updates preserve the original timestamp/workspace, but completion reconstructed those immutable fields and rejected the successful recreation. Commit d24cfbb0712d6154398fd84fe2f2359e2d436e60 carries the captured fields forward without changing the strict worker predicate or adding SQL. Both engine regressions failed with Sandbox runtime generation changed before the fix; Docker recreation and registry suites then passed 41 tests in 810.26 s wall, including 315.6 s worker compilation. The real-registry boundary is necessary because mocks hid this contract.

Merge commits 4c09f2c2d248b08846d787264b0fb7f351398e73, fb69da5c0fc628d8c83237eee9ebbb31c2e128ea, and 3f93a03c5425b14e76e0853638580189bdcc17e9 resolve actual main conflicts and the already-fixed dependency audit. They preserve append metadata reuse from #167291 and projection-anchor optimization from #167238. Overlapping cleanup #167563 removed a session-patch suite; its deletion stays intact, and the async-read/native-replacement regression now lives in the session-list suite with compiled-worker preload. No rebase was used.

CI also exposed malformed ClickClack capacity fixtures containing empty objects. Commit 65baafdd29e6a4ef15972d866ea8571e9f4286dc supplies valid typed bindings without changing production code or assertions. Both focused cases and all 35 contract tests pass: 213.14 s command wall, 0.306 s actual tests (earlier CI cases 0.245 s).

Correctness, compatibility, and check coverage

Regression coverage exercises foreign permission changes, lifecycle resets, replacement, deletion, transcript rewrites, allowed appends, sandbox reservation replacement/revocation, broker launch admission, worktree activity/placement changes, ClickClack cold-index visibility, FIFO hydration, cross-runtime revocation, accepted-work settlement, and native replacement through the async reader.

Original owner/sibling proof passed 74 tests in 256.12 s and 182 in 641.38 s; final lane ClickClack proof passed 72 tests in 401.93 s wall. Landing integration proof passed 27 Workshop/transcript tests in 669.94 s, then 30 in 1022.33 s after projection integration (including worker builds). The moved async-read suite passed 2 tests in 177.90 s. All focused commands used one worker. Seconds-long costs here include actual SQLite worker/admission contracts and shared compilation; test assertions were not weakened.

Core production/test and extension production/test typechecks passed, with affected lanes repeated after integrations. Runtime-process build graph, PR wrapper closure, get-reply imports, and transcript-reconcile imports passed. Original Knip, check-changed, and source ratchets passed. These results are reused only for unchanged inputs.

Two later local failures are independently inherited from main: Madge's prepared-model-catalog-fingerprints.ts ↔ prepared-model-catalog-worker.ts cycle, and the history-reader chain session-entry-read.worker.ts → session-accessor.sqlite-entry-list.read.ts → session-accessor.sqlite-exact-read.ts introduced by #167520. Reported inputs match the integrated baseline and inspected main ab5fd51b5e826fdcf3344e4838963ca656be649d. Exact-head CI lint passed: check-lint, both core shards, all three extension shards, and check-additional-extension-package-boundary. Local and Linux/arm64 supplemental lint preparation hit the same 300 s SDK-declaration tooling limit; these are not claimed as passing lint runs. The earlier remote focused core lint also passed on the measured repaired candidate. No redundant retry is needed because current CI supplies the actual lint proof.

Released SDK audit against v2026.10.1-beta.1 and v2026.9.9: synchronous api.runtime.agent.session.getSessionEntry and remote-shell helper/callback shapes are unchanged; getSessionEntryAsync is optional. Released transcript admission/version validators retain their compatibility record and type test. Anchor, GC policy and ClickClack store changes are internal. Local SDK API diff passed in 426.62 s, digest d20dba0b: no entrypoints/direct exported symbols added or removed; 131 reachable-surface changes were reviewed for optional additions and internal helper/type cleanup.

Retained cross-owner final-guard debt: src/agents/worktrees/owner-protection.ts:56 reads current session authority before shared-state GC mutation; placement checks remain at :96 and :103. These short checks remain counted, with complete revocation publication/next SDK major as the retirement path. No zero-host-SQL assertion is imposed on them. The diff adds zero new OPENCLAW_* names.

CI exception

CI run 37886053166, attempt 1 tested this head via merge da4895c9db565760cb277bc7f206f8dab4c06c6f, with ordered parents main a134038ad7fbf939038ada4dde61c0fa7eb02e33 and the reviewed head. Its tree matches the derived merge exactly. Two remaining roots qualify under the explicitly authorized untouched/unrelated exception:

  • Reply authority job: two cases expect one initial projection-lane reply and observe zero at reply-tool-authority.worker.test.ts:157, before route binding, foreign update, or any changed guard.
  • Effort scopes job: server.sessions.effort-scopes.test.ts:24 fails its model fixture setup with Unknown provider "openai", before effort mutation or changed owners.

All 24 causal source inputs matched the tested baseline and main inspected at 2026-10-09 05:14 UTC. Recent main CI was green: no matching failed main run or local reproduction is claimed. Source and call-path inspection independently exclude this PR. After that inspection, main commit a73ef559b23a6325f0ea39cc90dac22eaf50a916 repaired the reply-authority fixture by observing both cold and prepared worker lanes. The target main already contains that repair; under the explicitly authorized untouched/unrelated admin route, no source-changing CI retry or branch refresh is needed to carry it into the final merge. The effort-scopes failure remains independently unrelated. The aggregate CI gate failed and 29 sibling jobs were cancelled by the successful fail-fast monitor; those cancellations are incomplete coverage, never passing proof. Complete native evidence binds each root, all 108 terminal jobs, checkout/source/log hashes, and cancellation provenance. Security-fast, dependency review, and security-sensitive review are green; native admission will revalidate current security and authority. No rerun was used to obtain green.

Additional owner observation

Three alternating remote Sandbox pairs include actual worker SQL. First creation decreases 52→31 all-thread statements; warmed creation 50→29. MAIN creation statements decrease 35→14, with requests unchanged at 2→2. First/warmed final guards remain 8→8 / 7→7, guarded transport 7→7, and foreign-revocation checks 7→7. All observed phases have zero SQL failures and duration ratios below 1.5. This shows removed work around creation while preserving live final authority.

Workshop/GC and ClickClack have completed correctness and MAIN-only observations, but their separate all-thread owner probes remain an explicit limitation. Vitest clears NODE_OPTIONS, so earlier samples did not observe child-worker SQL. Corrected instrumentation passes both MAIN/child calibration (each 8 native calls, 2 prepares, 7 successful statements, zero failures), but two baseline owner attempts hit the unchanged 120 s no-output watchdog and exited 143 (165 s and 289.75 s wall). The first produced no workload evidence; the second emitted a partial ok:false receipt during shutdown covering Workshop and idle/retired GC with actual worker SQL. It is not a completed baseline sample, and no paired candidate or ClickClack sample ran. The second attempt used the supported native worker prebuild, which succeeded in 111.9 s. No timeout, test assertion, or production code was weakened. Further optional observation stopped after the repeated tooling failure; no complete Workshop/GC or ClickClack all-thread totals are claimed. The separate required five-pair full Gateway measurement is independently calibrated and complete.

Statement and request proof

The previous local comparison was invalid because two warmed positions exceeded the 1.5 duration-ratio bound. It is superseded by the complete remote report below, not counted as passing evidence.

Five alternating pairs on Blacksmith Testbox tbx_01m4fezcpspq9jsvbaha6zcgfw. Base b0c330d27df4a528f65185cc3e509284d1b218d9, candidate d24cfbb0712d6154398fd84fe2f2359e2d436e60.

All ten full workloads passed: 13 top-level turns, child completion, control RPCs, cron, compaction and graceful shutdown. All 20 MAIN/worker calibrations passed 8 native calls, 2 prepares, 7 successful statements, 0 failures. No sample was discarded.

Maximum phase duration ratio: 1.017; no window exceeds 1.5. Full all-thread/MAIN/request phase table, including all 10 warmed positions:

Phase All-thread M All-thread C MAIN M MAIN C Requests M Requests C Duration ratio
01.boot 2334.00 [2330.00–2335.00] 2334.00 [2331.00–2334.00] 1945.00 [1945.00–1945.00] 1945.00 [1945.00–1945.00] 58.00 [58.00–58.00] 58.00 [58.00–58.00] 1.008
01.connect 345.00 [296.00–349.00] 297.00 [296.00–319.00] 60.00 [55.00–60.00] 55.00 [55.00–68.00] 55.00 [44.00–55.00] 44.00 [44.00–45.00] 1.001
02.first-turn 2666.00 [2641.00–2705.00] 2710.00 [2702.00–2722.00] 72.00 [72.00–83.00] 83.00 [72.00–85.00] 291.00 [289.00–302.00] 301.00 [300.00–302.00] 1.015
03.turn-01 1119.00 [1116.00–1119.00] 1119.00 [1118.00–1120.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 206.00 [206.00–206.00] 206.00 [206.00–206.00] 0.990
03.turn-02 1125.00 [1107.00–1132.00] 1116.00 [1114.00–1132.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 209.00 [204.00–211.00] 207.00 [206.00–211.00] 1.011
03.turn-03 1119.00 [1115.00–1125.00] 1118.00 [1115.00–1131.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 206.00 [206.00–209.00] 206.00 [206.00–211.00] 1.017
03.turn-04 1117.00 [1114.00–1126.00] 1118.00 [1115.00–1120.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 208.00 [206.00–208.00] 206.00 [206.00–209.00] 0.983
03.turn-05 1108.00 [1105.00–1115.00] 1108.00 [1107.00–1115.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 206.00 [206.00–208.00] 206.00 [206.00–208.00] 0.996
03.turn-06 1114.00 [1107.00–1122.00] 1115.00 [1113.00–1121.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 208.00 [206.00–210.00] 208.00 [208.00–210.00] 0.995
03.turn-07 1108.00 [1101.00–1114.00] 1114.00 [1108.00–1116.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 206.00 [204.00–208.00] 208.00 [206.00–208.00] 1.011
03.turn-08 1111.00 [1107.00–1116.00] 1108.00 [1107.00–1117.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 208.00 [206.00–208.00] 206.00 [206.00–209.00] 0.978
03.turn-09 1120.00 [1117.00–1123.00] 1124.00 [1118.00–1125.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 209.00 [207.00–211.00] 209.00 [208.00–211.00] 0.997
03.turn-10 1118.00 [1107.00–1126.00] 1118.00 [1110.00–1125.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 206.00 [206.00–208.00] 206.00 [206.00–208.00] 1.007
03.warmed-mean 1115.10 [1113.70–1119.10] 1116.50 [1114.70–1118.90] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 207.20 [206.60–207.80] 207.30 [206.80–207.80] 0.999
04.second-session 3870.00 [3868.00–3876.00] 3874.00 [3867.00–3885.00] 72.00 [72.00–75.00] 72.00 [72.00–72.00] 654.00 [652.00–656.00] 654.00 [654.00–657.00] 0.999
05.control-plane 34.00 [34.00–40.00] 34.00 [34.00–41.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 5.00 [5.00–8.00] 5.00 [5.00–8.00] 0.984
06.cron 1251.00 [1246.00–1255.00] 1252.00 [1245.00–1254.00] 44.00 [44.00–44.00] 44.00 [44.00–44.00] 182.00 [180.00–183.00] 182.00 [180.00–183.00] 0.994
07.compaction 748.00 [747.00–750.00] 750.00 [747.00–751.00] 42.00 [42.00–42.00] 42.00 [42.00–42.00] 91.00 [91.00–92.00] 91.00 [91.00–92.00] 0.953
08.shutdown 346.00 [346.00–347.00] 346.00 [346.00–357.00] 164.00 [164.00–164.00] 164.00 [164.00–164.00] 39.00 [39.00–39.00] 39.00 [39.00–41.00] 0.822
done 0.00 [0.00–0.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 0.00 [0.00–0.00] 1.000

Raw first-turn arithmetic is not green: 2666→2710 (+44,+1.650%). Startup combined median is 5333→5346 (+13,+0.244%). The warmed median is 1115.1→1116.5 (+1.4,+0.126%); every delta SQL/request group is in unchanged owners. Foreground first-turn after separately identifying maintenance/catalog work is 2562→2557. These numbers remain visible for applying the coordinator’s latest PR-attributable-work rule; they are not silently normalized to a pass.

Startup combined Per-run sums Median
main 5333, 5346, 5336, 5321, 5318 5333
candidate 5352, 5341, 5335, 5346, 5353 5346
Phase Changed-path SQL M→C Changed-path requests M→C
01.boot 0→0 0→0
01.connect 0→0 0→0
02.first-turn 38→38 0→0
03.turn-01 22→22 0→0
03.turn-02 22→22 0→0
03.turn-03 22→22 0→0
03.turn-04 22→22 0→0
03.turn-05 22→22 0→0
03.turn-06 22→22 0→0
03.turn-07 22→22 0→0
03.turn-08 22→22 0→0
03.turn-09 22→22 0→0
03.turn-10 22→22 0→0
03.warmed-mean 22→22 0→0
04.second-session 79→79 0→0
05.control-plane 0→0 0→0
06.cron 22→22 3→3
07.compaction 0→0 0→0
08.shutdown 0→0 0→0

The changed-path totals above are direct/correlated observed stacks, with raw worker IDs, request keys and nanosecond timestamps retained. All first/warmed median delta groups have an empty changed-path intersection. Original three-pair and final five-pair archives are retained.

First-turn statement delta by request group (median-supplying runs, preserving the exact +44 total):

  • task-worker:workers.placementProjection: +3.
  • task-worker:sessionRows.sharedFacts: -1.
  • sqlite-broker:cron.planStartup: +7.
  • unattributed: +13.
  • sqlite-broker:pluginState.entries: +2.
  • readonly-process:pluginCatalog.read: -26.
  • task-worker:agentDatabaseDeletion.snapshot: +9.
  • sqlite-broker:deliveryQueue.mediaRetentionSnapshot: +9.
  • sqlite-broker:pluginState.sweep: +6.
  • task-worker:generatedHtmlProvenance.list: +2.
  • sqlite-broker:deliveryQueue.pruneTombstones: +7.
  • sqlite-broker:managedImages.entries: +3.
  • task-worker:session-store-projection: +3.
  • sqlite-broker:bootstrap.prune: +4.
  • sqlite-broker:open: +1.
  • sqlite-broker:cron.loadMutable: +3.
  • task-worker:channelIngress.failedHealth: -1.

Warmed statement delta by request group:

  • task-worker:session-exact-entries: -0.5/turn.
  • task-worker:session-row-facts: +1.4/turn.
  • task-worker:sessionRows.sharedFacts: +0.3/turn.
  • task-worker:exec-approvals.read: -0.1/turn.
  • readonly-process:auth-profile-rows: +0.3/turn.

The +13 native first-turn group is startup/plugin lifecycle lease acquire/release work; its raw stack reaches runGatewayPostReadyStartupMaintenance. Delivery media snapshot/tombstone cleanup and managed-image/provenance cleanup reach server-maintenance.ts; cron startup/load and health snapshot work also occur in the baseline. Catalog differences are the same 26-statement existing read-only admission batch appearing twice or three times; retain this as timing/admission variance, not a guard saving. Full SQL strings and caller stacks are in evidence-5pairs/attribution-median-groups.json.gz.

Observed native SQL failure records: 8; details in sql-final-report.json.

Native lock diagnostics are retained rather than treated as successful statements: 7 connect-phase BEGIN IMMEDIATE refusals at unchanged releaseOpenClawStateLeaseBestEffort / plugin-startup maintenance (2 baseline, 5 candidate), plus 1 candidate second-session attempt in the unchanged audit writer. All workload outcomes completed; no fix of these pre-existing concurrency paths is claimed.

Size and remaining boundary

Static T1 owner-file sites decrease 784→783 against the original lane base; these are not dynamic statement counts. Production +469/−307 (net +162), tests +692/−90 (net +602), docs +40/−2 (net +38). Growth supplies worker preparation, composable authority queries and meaningful revocation regressions, with no new storage/schema owner. Rare ClickClack cold admission can add worker requests; this is not represented as a universal all-thread reduction. Negative unbound visibility retains a current binding point read, and title backfill retains native authority checks after its worker scan.

Combine Workshop session permission and transcript-anchor validation, reuse GC preparation, and evaluate each final owner predicate once. Preserve synchronous foreign-commit checks and route guarded sandbox commands through the existing native launch boundary.

Prepare ClickClack descriptive reads in workers while retaining live visibility checks, and document the remaining guards and their SDK retirement contract. Schemas, durability, retention, permissions, and update behavior are unchanged.
@clawsweeper

clawsweeper Bot commented Oct 9, 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 docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling extensions: clickclack size: XL labels Oct 9, 2026
@github-actions

github-actions Bot commented Oct 9, 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: 65baafdd29e6a4ef15972d866ea8571e9f4286dc
  • Maintainer: @steipete
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/sandbox/backend.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/docker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/registry.kernel.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/registry.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/agents/sandbox/remote-shell-transport.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 9, 2026
@clawsweeper

clawsweeper Bot commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reduces repeated database reads for background learning, sandbox commands, checkout cleanup, and ClickClack discussions while preserving current permission checks.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful owner-directed optimization with recorded runtime and upgrade proof, meaningful boundary coverage, and no remaining actionable finding.
Proof confidence 🐚 platinum hermit (4/6) The maintainer-authored PR is outside the ordinary contributor proof gate. Recorded Gateway workloads exercise the runtime, and the published 2026.9.9 updater reaches this exact head with readiness and durable/incognito checks passing. Inspected final-effect regressions cover revoked and replaced authority; no material unresolved authority violation was identified. Stored formats and schemas remain unchanged, and the successful upgrade resolves the previous compatibility-proof gap.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Performance · Worth it: Yes
Reason: The existing area owner proposes reducing repeated storage work without changing settings or permissions. Recorded sandbox savings and reuse of existing workers justify the bounded production growth.

Merge readiness

✅ Ready for maintainer review

This PR contains useful, owner-directed work that remains distinct from current main. The earlier sandbox recreation finding is resolved, and no additional actionable code defect was identified.

Priority: P2
Reviewed head: 65baafdd29e6a4ef15972d866ea8571e9f4286dc

Before merge

None.

Findings

None.

Agent review details

How this fits together

OpenClaw workers prepare session and runtime facts from SQLite databases. Learning, sandbox execution, checkout cleanup, and discussion operations consume those facts and check current authority before performing effects.

flowchart TD
 A[Session and runtime databases] --> B[Worker preparation]
 B --> C[Learning and runtime operations]
 A --> D[Current authority checks]
 C --> D
 D --> E{Authority still valid?}
 E -->|Yes| F[File, command, checkout, or channel effect]
 E -->|No| G[Refuse stale operation]
Loading

Technical review

Best possible solution:

Keep preparation with existing workers and retain live effect-boundary checks until the documented versioned SDK cutover can replace them safely.

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

Not applicable to a behavioral bug report: this is an internal optimization supported by recorded calibrated SQL measurements and inspected owner-boundary regressions.

Is this the best way to solve the issue?

Yes: consolidating preparation within existing owners while retaining fresh final checks avoids introducing a competing authority cache or storage path.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main necessity: Current main still uses the earlier sandbox completion predicate and lacks the optional asynchronous session reader. The central consolidation is not already implemented there. (src/agents/sandbox/registry.kernel.ts:213, f8e594e461ef)
  • Earlier sandbox finding resolved: Docker and Podman completion preserve the registry's original workspace and creation timestamp. The added real-registry regressions cover recreation; the body records that both failed before the repair. (src/agents/sandbox/docker.ts:560, 65baafdd29e6)
  • Final authority remains current: Workshop combines current permissions, lifecycle, and accepted transcript identity in one statement. Sandbox completion checks the captured generation inside the worker transaction; guarded commands launch synchronously after their authority check. Worktree cleanup retains fresh session and placement checks. (src/config/sessions/session-accessor.sqlite-transcript-anchor.ts:34, 65baafdd29e6)
  • Forbidden and stale-authority regressions: Inspected tests verify unchanged Workshop file bytes after foreign permission changes, reset, replacement, deletion, or rewrite; refusal of replaced sandbox reservations; and absence of command effects when launch authority is revoked. ClickClack tests cover cold visibility, replacement, revocation, and FIFO hydration. These tests were inspected, not executed during this read-only review. (src/skills/workshop/experience-review.test.ts:125, 65baafdd29e6)
  • Accepted SDK compatibility scope: The existing area owner's PR preserves released synchronous signatures, adds only an optional descriptive reader, and documents retained native guards and their next-major retirement path. The body records SDK comparison against v2026.9.9 and v2026.10.1-beta.1. This accepted scope does not require another product decision. (src/plugins/runtime/types-core.ts:408, 65baafdd29e6)
  • Published-driver upgrade completed: The fully inspected body records released 2026.9.9 updating to this exact head on Linux/x64, all command exit records zero, readiness HTTP 200, matching running-build identity, and passing durable/incognito checks. Run identity: 42a8d8aa-c6be-4567-b849-55b84d935003. The earlier local timeout remains disclosed. Captured body SHA-256 f84546d04472dbc2fcbeebd0f05d1d22c1c4f9df1594847e7f2482d5228c875f was independently matched. (65baafdd29e6)

Likely related people:

  • Peter Steinberger: Raw commit 8e4eb78 adds src/agents/worktrees/owner-protection.ts:27 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8e4eb78fa20b; files: src/agents/worktrees/owner-protection.ts)

PR surface

Source +162, Tests +602, Docs +38. Total +802 across 34 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 20 469 307 +162
Tests 13 692 90 +602
Docs 1 40 2 +38
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 34 1201 399 +802

Review metrics

Metric Value Why it matters
Production versus tests production +469/−307; tests +692/−90 Production growth supplies worker preparation and composable authority checks without adding a storage owner; tests cover revocation and lifecycle boundaries.
Plugin runtime capability 1 optional method added; 0 synchronous methods removed The descriptive asynchronous reader expands the SDK while preserving released synchronous callers.

Labels

Label changes:

  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded storage efficiency improvement without an established urgent user regression.
  • merge-risk: 🚨 compatibility: The optional plugin reader and guarded transport changes affect compatibility-sensitive contracts; the area owner explicitly preserves released signatures and documents the accepted retirement boundary.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (7 earlier review cycles)
  • reviewed 2026-10-09T02:29:03.682Z sha 9b4b5fe :: blocked before merge. :: [P1] Carry the captured generation through Docker and Podman completion
  • reviewed 2026-10-09T03:13:00.067Z sha d24cfbb :: blocked before merge. :: none
  • reviewed 2026-10-09T03:38:53.483Z sha fb69da5 :: blocked before merge. :: none
  • reviewed 2026-10-09T04:30:15.635Z sha 3f93a03 :: blocked before merge. :: none
  • reviewed 2026-10-09T05:01:00.980Z sha 65baafd :: blocked before merge. :: none
  • reviewed 2026-10-09T06:14:45.747Z sha 65baafd :: needs changes before merge. :: none
  • reviewed 2026-10-09T06:44:25.796Z sha 65baafd :: needs maintainer review before merge. :: none

Reviewed October 9, 2026, 3:36 AM ET / 07:36 UTC (Revision 8).

Carry the registry creation timestamp and workspace through Docker and Podman setup completion. This preserves the admitted generation without another database read and avoids cleaning up a successfully recreated container. The worker still rejects genuine reservation replacements.
@clawsweeper clawsweeper Bot added rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Oct 9, 2026
@steipete steipete changed the title improve(storage): reduce duplicate reads around final authority guards refactor(storage): reduce duplicate reads around final authority guards Oct 9, 2026
Preserve main projection-snapshot anchor reads and the consolidated final-authority query. Conflict resolution retains both query paths without additional SQL; focused Workshop, append metadata, and anchor worker tests pass.
Keep main deletion of the redundant session-patch suite and move the native-replacement read regression into the existing session-list suite. Prepare compiled workers at collection; both session-read tests pass.
Async binding-index hydration reads stored binding metadata before checking capacity. Populate both boundary fixtures with typed bindings so they exercise capacity and reclamation rather than malformed data; preserve all existing assertions.
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 9, 2026
@clawsweeper clawsweeper Bot added the rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. label Oct 9, 2026
@steipete
steipete merged commit 83ce140 into main Oct 9, 2026
160 of 193 checks passed
@steipete
steipete deleted the dbasync/t1guards branch October 9, 2026 07:41
@steipete

steipete commented Oct 9, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 10, 2026
…ds (openclaw#167571)

* perf(storage): consolidate final authority guards

Combine Workshop session permission and transcript-anchor validation, reuse GC preparation, and evaluate each final owner predicate once. Preserve synchronous foreign-commit checks and route guarded sandbox commands through the existing native launch boundary.

Prepare ClickClack descriptive reads in workers while retaining live visibility checks, and document the remaining guards and their SDK retirement contract. Schemas, durability, retention, permissions, and update behavior are unchanged.

* fix(storage): retain authority across prepared reads

* fix(sandbox): retain registry generation when recreating containers

Carry the registry creation timestamp and workspace through Docker and Podman setup completion. This preserves the admitted generation without another database read and avoids cleaning up a successfully recreated container. The worker still rejects genuine reservation replacements.

* test(clickclack): seed complete bindings for capacity checks

Async binding-index hydration reads stored binding metadata before checking capacity. Populate both boundary fixtures with typed bindings so they exercise capacity and reclamation rather than malformed data; preserve all existing assertions.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation extensions: clickclack gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. security-sensitive-changed size: XL 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