Skip to content

refactor: move exec policy writes off the Gateway thread - #167115

Merged
steipete merged 11 commits into
mainfrom
dbasync/w6execpolicy
Oct 8, 2026
Merged

steipete merged 11 commits into
mainfrom
dbasync/w6execpolicy

Conversation

@steipete

@steipete steipete commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Exec-policy edits, allowlist usage recording, and agent removal perform synchronous SQLite work on the Gateway thread, while plugin launch guards open write transactions just to check current policy.

User Impact

Policy mutations and agent-policy cleanup use the shared-state writer. Policy revocation still blocks execution immediately before launch or retry, including changes made through a foreign connection. Released synchronous Plugin SDK contracts remain supported.

There are no schema, stored-data, durability, retention, permission, or update-migration changes. The retained final SELECT intentionally makes steady usage plus its guard cost 9 statements instead of 8, while MAIN falls from 8 to 1. Cold authorization also pays once-per-handle reader admission (557→560 total). These explicitly permitted authority costs are counted, not claimed as savings.

Why This Change Was Made

Typed mutations capture their physical source before yielding, share the existing writer FIFO, and reread policy and deletion authority inside synchronous transactions. Host authority is rechecked at transaction and commit admission. Policy edits end the preceding authorization batch; independent cancellation scopes cannot share its failure. Cron uses are fenced before commit, and failed or uncertain work cannot revive revoked uses. Gateway policy RPCs retain requester authority even when clients omit expectedOwnerId.

Preparation admits a read-only handle through the existing reader pool. The final guard runs one indexed current-policy SELECT without a transaction or per-call freshness/schema PRAGMAs. Physical identity, lifetime, integrity, and transaction exclusion still apply; retired readers require fresh preparation. Raw native and foreign writers prevent substituting cached policy facts. The v2026.9.8 synchronous pre-spawn guard and policy readers remain T1; retirement requires the next Plugin SDK major, removal of raw synchronous writers, and complete revocation publication. Doctor retains its native migration adapter; released opaque approval guards retain their named native kernels.

Landing validation

Landing head: d90e5d7312a6ac71e695c31144c92b08df16f486. Main was integrated in merge commits b64be50807ac, 62189a4dd1dd, 51e60184ef749, and a6e5fd509defb. Resolutions retained both reader test groups and worker-access documentation sections, regenerated the inventory, preserved the renamed Gateway media-test route, and adopted main's shared all-thread administrative SQL observer from #167239. Main's newer-schema admission diagnostics remain intact. No SQL-path implementation changed during conflict resolution; the paired SQL and published-driver proof below remains applicable.

Fresh P2 review of the integrated policy change and a separate P2 review of the final test repair are clean. The released SDK audit was also checked against v2026.9.9 and v2026.10.1-beta.1: changed mutation callables remain internal, while synchronous policy readers and prepareExecAuthorization(source): () => void retain their signatures. The original formal SDK report and its explained transitive fingerprints are retained below.

Local validation:

  • Reader, policy, authorization, plugin and cron-grant proof: 143 tests passed (791.84 s including cold worker compilation).
  • Remaining CLI/Gateway callers and import checks: 220 tests passed (434.93 s). The explicit runtime-process graph and wrapper source-closure checks passed.
  • Relocated archive policy/SQLite-worker proof passed. The complete archive suite had one unrelated failure: its highlighter initialization counter remained zero although rendered highlighting was correct. The failing assertion and highlighter build/runtime owners are unchanged from main; no baseline reproduction or rerun was used. The remainder of that single portable-shell case was not reached.
  • Core production types, all 27 selected core test graphs, and madge passed on the earlier integrated head; later conflict-only resolutions used focused proof. A stale local Ghostty patch initially caused an onCopy type error; refreshing this checkout's frozen dependencies resolved it. Focused type checks and formatting passed again for the test repair.
  • Subsequent conflict-only integration proof passed all 26 administrative CLI/socket cases with the shared all-thread observer (414.93 s including worker compilation), then all 49 reader-cache cases (55.47 s). No SQL measurement or full-suite repetition was needed.
  • The repair's Node run passed seven offline/socket cases and four CI runtime-qualification tests (179.88 s total); Bun passed all 25 administrative CLI cases (77.11 s). These are local wall times, not GitHub billed seconds. No new test cases or test-runtime limits were added.

CI run 37816488133 on 62189a4dd1dd exposed two real test-owner gaps: the administrative CLI fixture and node socket-policy fixture invoked the new worker owner from threaded projects. Commit 57314601865bd routes both through the existing host-owned fork project, preserves administrative CLI Bun coverage, and awaits socket worker cleanup. The final shared observer verifies worker SQL and valid offline custody for every pairing and policy operation, alongside persisted-state and no-replay checks. The same run's chat-outbox-recovery.e2e.test.ts failure was a 30-second screenshot timeout in an unchanged mocked-Gateway UI flow, unrelated to exec policy. ClawSweeper's earlier routing findings are addressed. A later CI run on a6e5fd509defb found the expected Bun qualification list had not included the newly qualified CLI suite. Commit d90e5d7312a6a adds that one expected entry; its focused qualification case passed in 5.20 s. Current required CI is tracked separately; older runs are not claimed as current-head success.

Evidence

Original paired/package proof head: 63d8523e65f09eca17bbd6da5d80fd51cdad8e3c; comparison base: d327a36593da472032d1d7349b0e62652da815d0. Measurements use 643a199eb9847c95b0cd42755960401f2df8b488; the final commit adds only four fixture lines, and production equivalence is verified.

Static inventory: T1 797→794, targeted sites 6→3, total counted primitive sites 2,531→2,527. Retained synchronous authority/SDK sites remain T1. Fresh Codex P2 reviews are clean for production and the final fixture correction.

Validation ran on an isolated Hetzner ccx33 host with CI=1. Times below are measured remote command wall seconds, not a claim about GitHub billed seconds.

Proof Result Remote CI wall seconds
Six focused reader/store/authorization/plugin suites, pnpm test <files> --maxWorkers=1 120 cases covered: 119 initially passed; the one cold-admission fixture assertion was corrected and its targeted rerun passed 78.6 + 28.9
Four negative controls Each expected assertion failed for its intended cause; exact original bytes restored and verified 32.5 / 34.3 / 33.3 / 29.0
Relocated-worker archive test, pnpm test test/scripts/worker-deploy-build-plugin.test.ts --maxWorkers=1 -t 'reads exec environment and commits authorization through SQLite workers in a relocated archive' Passed 66.5
Final CLI/agent/Gateway caller suites Passed 221 tests across seven files on the final head 145.1
node scripts/check-changed.mjs --base d327a36593da472032d1d7349b0e62652da815d0 Passed, including source/test types, lint, schema and storage guards 2,944.0
pnpm check:madge-import-cycles / pnpm deadcode:full Passed 24.9 / 167.3
pnpm check:database-worker-ratchet --base d327a36593da472032d1d7349b0e62652da815d0 / inventory on both refs Passed; T1 did not rise 4.9 / 4.7
pnpm plugin-sdk:api:diff --base d327a36593da472032d1d7349b0e62652da815d0 --head 63d8523e65f09eca17bbd6da5d80fd51cdad8e3c Report generated and reviewed as described below 439.8
Candidate package build Passed 503.9
Published 2026.9.8 driver × candidate update cell Passed; actual update 542.3 s 649.9

The focused suites cover foreign-connection denial immediately before spawn, physical-source replacement, FIFO, transaction-local deletion guards, rollback, independent cancellation, maintenance ownership, cron revocation and accepted/unknown work settlement. The sole focused failure included five permitted one-time reader-admission reads inside a zero-SQL observer. The four-line fixture correction admits that reader before observation, leaving writer startup and the original three-operation ordering test intact.

SDK comparison: 0 entrypoint additions/removals and 0 direct exported declaration changes; 131 reachable fingerprints changed across five whole-module fallback sections. This is not an empty diff. The renderer conservatively retains whole transitive modules for unindexable declarations; the changes include private mutation/store/config declarations. Inspection of current and v2026.9.8 SDK barrels, runtime fields, root exports and package subpaths found no changed mutation callable exposed publicly. The synchronous policy readers and (source) => () => void prepareExecAuthorization contract remain intact. Review digest: 02fd5b751352089655b35e8f002ff551e2696432835c808afd7087616d2ac5f2.

The 104,161,138-byte candidate tarball has SHA-256 b289ae6bfe48cd8468108010765550cf732bea74a95965393a424064ca8c5bfc. The published-driver cell verified candidate commit 63d8523e65f09eca17bbd6da5d80fd51cdad8e3c and build ID 2026.9.8-63d8523e65f0-2026-10-08T09-11-20.660Z, readiness 200, durable/incognito post-update checks and service stop. Every cell step exited 0. Both package versions are 2026.9.8, so the commit/build ID supplies the candidate identity.

Remote admission took about 73 minutes, with backed-off fleet-limit retries after one AWS provisioning failure. Missing rg, Corepack activation, Buildx and refreshed Docker group membership were repaired on the isolated host; early environment failures did not run the update workload. No product exception or baseline expansion was added. The census limitations and measurement scope are explicit below; no completed GitHub CI result is claimed before PR publication.

Current-base shared-workload sanity pair

One alternating M,C pair on the same Hetzner ccx33 host, Node 24.21.0, using the shared workload unchanged. This is the acceleration-rule sanity check after the retained three-pair series below; the only integration conflict was generated inventory, which was regenerated; executable owner files had no conflicts. Values are one-run phase samples with degenerate ranges; warmed values average ten turns. Every phase passes and wall ratios are 0.970–1.026. No full paired rerun is required.

Phase Baseline all-thread Candidate all-thread Delta Baseline MAIN Candidate MAIN Baseline requests Candidate requests Wall ratio
01.boot 2742 [2742–2742] 2736 [2736–2736] -6 1859 [1859–1859] 1853 [1853–1853] 60 [60–60] 60 [60–60] 1.000
01.boot + 01.connect 3102 [3102–3102] 3095 [3095–3095] -7 1925 [1925–1925] 1919 [1919–1919] 108 [108–108] 108 [108–108] 1.002
01.boot + 01.connect + 02.first-turn 6877 [6877–6877] 6869 [6869–6869] -8 2018 [2018–2018] 2012 [2012–2012] 493 [493–493] 491 [491–491] 1.000
01.connect 360 [360–360] 359 [359–359] -1 66 [66–66] 66 [66–66] 48 [48–48] 48 [48–48] 1.018
02.first-turn 3775 [3775–3775] 3774 [3774–3774] -1 93 [93–93] 93 [93–93] 385 [385–385] 383 [383–383] 0.999
03.warmed-turn 1435 [1435–1435] 1430 [1430–1430] -5 6.5 [6.5–6.5] 6.5 [6.5–6.5] 300.1 [300.1–300.1] 299.4 [299.4–299.4] 0.996
04.second-session 4969 [4969–4969] 4937 [4937–4937] -32 103 [103–103] 103 [103–103] 886 [886–886] 880 [880–880] 1.021
05.control-plane 43 [43–43] 43 [43–43] +0 0 [0–0] 0 [0–0] 5 [5–5] 5 [5–5] 0.997
05.control-plane + 06.cron 2041 [2041–2041] 2027 [2027–2027] -14 52 [52–52] 52 [52–52] 218 [218–218] 214 [214–214] 1.000
06.cron 1998 [1998–1998] 1984 [1984–1984] -14 52 [52–52] 52 [52–52] 213 [213–213] 209 [209–209] 1.000
07.compaction 843 [843–843] 840 [840–840] -3 44 [44–44] 44 [44–44] 92 [92–92] 92 [92–92] 0.970
07.compaction + 08.shutdown 1910 [1910–1910] 1906 [1906–1906] -4 441 [441–441] 441 [441–441] 197 [197–197] 197 [197–197] 0.996
08.shutdown 1067 [1067–1067] 1066 [1066–1066] -1 397 [397–397] 397 [397–397] 105 [105–105] 105 [105–105] 1.026

These decreases are observed background variation, not claimed exec-policy savings: the shared workload does not exercise policy edits, removal/restore, usage writes or exec launches. Native SQL errors are zero; SQL census conservation is exact, with no missing contexts or duplicate sends. Both sides retain two unresolved boot transport targets (workerEnvironments.snapshot, userProfiles.catalog) and two unmatched sends/receives, still counted. Warmed request linkage has no such gap.

Current-base direct owner operations and exact attribution

One alternating M,C owner pair. Warm rows are within-process medians [min–max] over three operations; cold and foreign-deny rows are single observations. These are owner-entry-point measurements, not complete Gateway/CLI turn timings. The APIs and returned final guards execute for real, and persisted usage/denial are checked. All threads and helper processes are counted; native SQL errors are zero. Database requests include actual broker open/command sends. Cold raw IPC totals 1,652→1,656 contain 1,650→1,654 esbuild/tsx messages; every excluded loader stack was verified. Actual cold database transports are 2→2.

Flow Baseline all-thread Candidate all-thread Baseline MAIN Candidate MAIN Baseline DB requests Candidate DB requests
01+02.authorization-first-complete 557 [557–557] 560 [560–560] 2 [2–2] 6 [6–6] 2 [2–2] 2 [2–2]
01.authorization-first 555 [555–555] 559 [559–559] 0 [0–0] 5 [5–5] 2 [2–2] 2 [2–2]
02.final-first 2 [2–2] 1 [1–1] 2 [2–2] 1 [1–1] 0 [0–0] 0 [0–0]
03+04.authorization-warm-complete 8 [6–8] 4 [4–4] 2 [2–2] 1 [1–1] 1 [1–1] 1 [1–1]
03.authorization-warm 6 [4–6] 3 [3–3] 0 [0–0] 0 [0–0] 1 [1–1] 1 [1–1]
04.final-warm 2 [2–2] 1 [1–1] 2 [2–2] 1 [1–1] 0 [0–0] 0 [0–0]
05.policy-update 7 [7–7] 7 [7–7] 7 [7–7] 0 [0–0] 0 [0–0] 1 [1–1]
06.final-after-foreign-deny 4 [4–4] 1 [1–1] 4 [4–4] 1 [1–1] 0 [0–0] 0 [0–0]
07.remove-and-restore 22 [22–22] 18 [18–18] 22 [22–22] 0 [0–0] 0 [0–0] 2 [2–2]
08.record-allowlist-use-complete 8 [8–8] 9 [9–11] 8 [8–8] 1 [1–1] 0 [0–0] 1 [1–1]
09.plugin-prepare-cold 9 [9–9] 6 [6–6] 9 [9–9] 6 [6–6] 0 [0–0] 0 [0–0]
10.plugin-final-warm 6 [6–6] 1 [1–1] 6 [6–6] 1 [1–1] 0 [0–0] 0 [0–0]
11.plugin-final-after-foreign-deny 8 [8–8] 1 [1–1] 8 [8–8] 1 [1–1] 0 [0–0] 0 [0–0]
Flow All-thread statements Attribution
Cold authorization + final guard 557 → 560 Add five one-time MAIN read-handle admission statements; remove one worker coordination read and one MAIN data_version probe. Net +3; not claimed as a cold saving.
Warm authorization + final guard, interleaved policy writes 8 [6–8] → 4 [4–4] Remove one worker machine-state coordination SELECT and one MAIN data_version per operation. The latter two baseline repetitions also execute worker schema_version and user_version; candidate avoids those two probes. Thus per-operation reductions are 2, 4, 4, median4.
Policy update 7 → 7 Same seven statements move MAIN→worker: BEGIN IMMEDIATE, COMMIT, two data_version, machine-state coordination SELECT, policy SELECT, policy UPSERT. DB transports0→1.
Final guard after foreign deny 4 → 1 Remove MAIN data_version, schema_version, user_version; retain current policy SELECT and deny result.
Agent policy removal + restoration 22 → 18 Remove two data_version, one machine-state coordination SELECT, one policy SELECT, one full deletion-journal SELECT, and one table_info(agent_deletion_journal) (−6); add worker schema_version + user_version after the foreign seed (+2). Net−4. Two individual operation-id guards become two batched agent-id/operation-id guards, no single-agent count saving. MAIN22→0; DB transports0→2.
Complete allowlist usage + final guard 8 [8–8] → 9 [9–11] Normal worker mutation remains8 statements, plus one final MAIN policy SELECT. First candidate operation has two extra worker probes (schema_version, user_version) after the preceding foreign seed; later operations9,9. No final-read PRAGMAs. DB transports0→1.
Plugin preparation 9 → 6 Remove BEGIN IMMEDIATE, COMMIT, two data_version, one machine-state coordination SELECT (−5); add schema_version and user_version (+2), net−3.
Plugin warm final guard 6 → 1 Remove BEGIN IMMEDIATE, COMMIT, two data_version, one machine-state coordination SELECT; keep exactly one indexed current-policy SELECT.
Plugin final guard after foreign deny 8 → 1 Remove BEGIN IMMEDIATE, ROLLBACK, two data_version, schema_version, user_version, one machine-state coordination SELECT; keep indexed current-policy SELECT, which still refuses execution.

The five cold MAIN admission reads are exactly PRAGMA data_version, PRAGMA schema_version, PRAGMA user_version, SELECT type, name, tbl_name, sql FROM main.sqlite_schema WHERE type IN ('table', 'index', 'trigger'), and select "value_json" from "config_machine_state" where "state_key" = ?. The removed worker coordination query is SELECT value_json FROM config_machine_state WHERE state_key = ? LIMIT 1. The retained final read is select "raw_json" from "exec_approvals_config" where "config_key" = ?.

A separate local M,C pair on the same production bytes measured complete usage plus guard at 8 [8–8]→9 [9–9], MAIN 8→1, worker requests 0→1, with zero native SQL errors. Instrumented operation medians were 3.389 ms [2.367–5.169]→34.028 ms [21.583–186.118]. The earlier six-pair single-operation comparison on the prior revision was 8.698×. These async-worker versus in-thread microbenchmark timings are informational, explicitly not duration gates or latency-improvement claims.

Historical three-pair whole-workload measurements and attribution — earlier source

These retained results are historical regression evidence, not final-head proof. Baseline 9ef85029b0d270b57838c84c612ea4f70d145249; candidate evidence carrier ce533a3eb9e2cce64b63008f06a3ebb9709becc4, tree 7de4989e8704025e2eee6857a7445ed4636df50c, source-patch SHA-256 b45b8bd1dbffe95389b56e48d1f142ef33d200a1a24fa9b10cae72e7d8db6b8f. Three alternating M,C pairs on one AWS c7a.2xlarge host, Node 24.21.0 / SQLite 3.53.4, using the unchanged shared workload with a private census observer copy. All six runs passed; native SQL errors were zero.

Values are medians [min–max] across three runs. Each warmed sample first averages the ten warmed turns. All-thread counts include helper processes and workers; request counts include open/close transport sends. Every phase duration ratio is ≤1.5.

Phase Baseline all Candidate all Δ Baseline MAIN Candidate MAIN Baseline requests Candidate requests Duration ratio
01.boot 2757 [2757–2757] 2756 [2756–2760] -1 1867 [1867–1867] 1867 [1867–1867] 60 [60–60] 60 [60–60] 0.859
01.connect 413 [401–429] 424 [423–424] +11 66 [66–66] 66 [66–66] 57 [56–57] 57 [57–57] 0.996
02.first-turn 4447 [4440–4471] 4466 [4454–4466] +19 102 [102–104] 102 [102–102] 374 [374–374] 374 [374–374] 0.984
03.warmed-turn 1514.1 [1513.7–1514.3] 1513.2 [1512.6–1513.3] -0.9 6.5 [6.5–6.5] 6.5 [6.5–6.5] 299.8 [299.8–299.8] 299.6 [299.6–299.8] 1.000
04.second-session 5233 [5194–5233] 5219 [5213–5230] -14 103 [103–103] 103 [103–103] 876 [876–877] 874 [872–874] 0.980
05.control-plane 45 [45–50] 45 [45–50] +0 0 [0–0] 0 [0–0] 5 [5–5] 5 [5–5] 0.995
06.cron 1442 [1439–1486] 1439 [1437–1458] -3 50 [50–50] 50 [50–50] 203 [203–207] 203 [203–207] 0.999
07.compaction 855 [848–858] 857 [855–858] +2 44 [44–44] 44 [44–44] 93 [92–93] 93 [93–93] 0.986
08.shutdown 1081 [1080–1084] 1084 [1078–1095] +3 403 [403–403] 403 [403–403] 105 [105–105] 105 [105–107] 1.003
Positive phase delta Attribution from median-count samples
Connect +11 (M3/C2) Unchanged cron mutation work +7, catalog admission +3, outbound delivery recovery +1. Boot+connect rises only +10/+0.315%, within the combined-window allowance.
First turn +19/+0.427% (M1/C2) +11 schema/admission probes: schema_version +3, user_version +3, data_version +1, table_info +2, catalog schema +1, operator-approval schema +1. +8 untouched fact reads: machine state +4, ACP +2, participant +1, watcher key +1. Requests stay 374; this is within the attributed ≤0.5% turn-noise allowance.
Compaction +2 (M1/C3) Scheduled WAL checkpoint envelope +4 and memory transcript-stats quarantine read +1, offset by outbound-delivery reader envelope −3.
Shutdown +3 (M3/C2) Existing placement-projection schema_version/user_version/machine-state read envelope.

Combined-window counts retain all work; each median is computed from per-run sums:

Window Baseline runs Candidate runs Baseline median Candidate median Δ
01.boot + 01.connect 3186, 3158, 3170 3183, 3180, 3180 3170 3180 +10
01.boot + 01.connect + 02.first-turn 7633, 7598, 7641 7637, 7646, 7646 7633 7646 +13
05.control-plane + 06.cron 1492, 1531, 1484 1487, 1503, 1484 1492 1487 -5
07.compaction + 08.shutdown 1935, 1932, 1939 1936, 1939, 1952 1935 1939 +4

Boot+connect+first turn increases by 13, so a decreasing deferred-startup combined window is not claimed. First-turn attribution uses the narrower noise-floor allowance. Compaction/shutdown increases each remain within the ≤10-statement non-turn allowance. No statement relocation is presented as a reduction.

Census conservation is exact, with zero missing SQL-context rows or duplicate sends. Each run retains two unresolved boot transport targets (workerEnvironments.snapshot, userProfiles.catalog) and two unmatched sends/receives. They remain counted; their originating caller is not claimed fully resolved. Catalog observations are attributed to unchanged owners, not assumed to be timers.

The shared workload does not execute policy edits, deletion rollback, usage writes, or exec launches. Its warmed −0.9 statement/−0.2 request difference is not claimed as an exec-policy saving. The current-base sanity pair is reported above.

Focused test commands
pnpm test src/infra/exec-approvals-store.read-worker.test.ts src/infra/exec-approvals-store.test.ts src/infra/exec-approvals-authorization.worker.test.ts src/node-host/plugin-exec-policy.test.ts src/state/openclaw-state-db-read-connection.cache.test.ts src/state/openclaw-state-db-read-connection.test.ts --maxWorkers=1
pnpm test src/infra/exec-approvals-store.test.ts --maxWorkers=1 -t 'does not batch authorizations across an intervening policy denial'
pnpm test src/agents/bash-tools.exec-cron-grant.test.ts src/agents/cli-runner/cli-native-tool-approval.test.ts src/node-host/invoke.test.ts src/gateway/server-methods/exec-approvals.test.ts src/gateway/server-methods/agents-mutate.test.ts src/cli/exec-approvals-cli.test.ts src/cli/exec-policy-cli.test.ts --maxWorkers=1

The corresponding remote CI=1 wall times are 78.6 s, 28.9 s and 145.1 s. GitHub CI will attach after publication; no completed hosted run is claimed.

@clawsweeper

clawsweeper Bot commented Oct 8, 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.

@github-actions

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

These security sensitive changes were made:

  • src/gateway/server-methods/exec-approvals.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-authorization.kernel.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-authorization.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-authorization.worker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-config.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-generated-migration.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-mutation.kernel.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-mutation.worker.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-sqlite.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals-store.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/infra/exec-approvals.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/node-host/plugin-exec-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.

Carefully review these changes before merging.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation gateway Gateway runtime cli CLI command changes scripts Repository scripts commands Command implementations agents Agent runtime and tooling size: XL labels Oct 8, 2026
@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 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 2:40 PM ET / 18:40 UTC (Revision 6).

ClawSweeper review

What this changes

Moves execution-policy mutations and agent-policy cleanup to the shared database writer while retaining synchronous current-policy checks before command execution.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful and correct with real production-boundary measurements, preserved compatibility, and resolved earlier concerns; proof is narrower than a complete application execution campaign.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied isolated owner runs exercise actual SQLite worker transport, persisted mutations, and final launch guards, including refusal after foreign policy tightening; focused boundary coverage additionally verifies revocation before commit and stale deletion authority. Package update proof and unchanged serialization establish a no-migration case. Historical proof is identified by its original head, with later integration and test-only repairs supported by focused validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Refactor · Worth it: Yes
User problem: Policy edits and usage recording can occupy the Gateway thread while other requests need it.
Reason: The existing area owner supports this worker cutover, and measured production operations remove synchronous writes while preserving execution-policy semantics.

Merge readiness

✅ Ready for maintainer review

This PR remains useful and has no actionable blocking finding at the pinned head. Earlier test-routing and merge-conflict concerns are resolved, and the maintainer-authored work should remain open for landing.

Priority: P2
Reviewed head: d90e5d7312a6ac71e695c31144c92b08df16f486

Before merge

None.

Findings

None.

Agent review details

How this fits together

Execution policy controls which commands agents and plugins may launch. Gateway, CLI, and node requests update the shared SQLite policy; launch guards consume current policy immediately before execution.

flowchart TD
  A[Gateway and CLI policy requests] --> B[Captured requester and database authority]
  B --> C[Shared database writer]
  C --> D[Current policy and deletion checks]
  D --> E[Persisted execution policy]
  E --> F[Prepared live policy reader]
  F --> G[Final launch authorization]
  G --> H[Execute or refuse command]
Loading

Technical review

Best possible solution:

Keep policy mutations in the existing writer owner and preserve the live synchronous launch guard until the documented SDK retirement conditions are met.

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

Not applicable as a standalone bug report; current-main source confirms synchronous policy writes, and supplied production-owner measurements demonstrate the scheduling change.

Is this the best way to solve the issue?

Yes. The patch reuses the shared writer and reader lifecycle owners, migrates internal callers together, and retains the released synchronous policy boundary.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness. Added test files: 18.

Security

None.

Evidence

What I checked:

  • Introduced production changes: The pinned introduced delta routes typed policy mutations through the existing shared-state writer and checks live host admission at transaction and commit boundaries. (src/infra/exec-approvals-mutation.worker.ts:52, d90e5d7312a6)
  • Current main still needs the cutover: Fetched main still implements updateExecApprovals through a synchronous native transaction and initializes socket policy through that same path; the central change is not already implemented. (src/infra/exec-approvals-store.ts:424, b3b40e1615d5)
  • Direct production-owner proof: Read the full PR body through REST, including previously omitted proof. Its captured source identity is SHA-256 253bcd3f40afee554dffdb44cdcfefa99758376a756df539661eb6d062c02737. The isolated Node 24.21.0 owner run exercises real writer transport, persisted policy, usage, removal/restoration, and returned launch guards: policy updates move MAIN SQL 7→0, removal/restoration 22→0, and plugin final checks 6→1 while foreign denial still refuses execution. The broader workload is expressly not claimed to exercise these operations. (63d8523e65f0)
  • Authority and lifecycle coverage: Focused coverage exercises requester revocation before commit, superseded deletion operations, foreign-policy denial before spawn, independent cancellation, and refusal after reader close, quarantine, replacement, or maintenance retirement. (src/gateway/server-methods/exec-approvals.test.ts:193, d90e5d7312a6)
  • Compatibility and accepted authority costs: The existing policy row, serialization, projections, schema, and migration gate are preserved. The full body records a successful published 2026.9.8 updater × candidate package cell with readiness 200 and durable/incognito checks, plus stable SDK audits preserving synchronous readers and prepareExecAuthorization(source): () => void. The area owner's stated direction explicitly retains the final SELECT and acknowledges usage SQL 8→9 and cold admission 557→560 rather than claiming those as savings. (src/plugin-sdk/exec-approvals-runtime.ts:3, 63d8523e65f0)
  • Re-review continuity and current checks: The current source retains process-owned socket/administrative test execution and adds the missing Bun qualification expectation. REST reports the exact reviewed head open, mergeable, and clean. Paginated current-head checks contain no failed or unfinished run; CodeQL is neutral. The previous conflict-only next step no longer applies. (test/scripts/ci-run-node-test-shard.test.ts:1234, d90e5d7312a6)

Likely related people:

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

PR surface

Source +513, Tests +618, Docs +27, Other +1. Total +1159 across 48 files.

View PR surface stats
Area Files Added Removed Net
Source 21 979 466 +513
Tests 22 793 175 +618
Docs 2 344 317 +27
Config 0 0 0 0
Generated 0 0 0 0
Other 3 11 10 +1
Total 48 2127 968 +1159

Review metrics

Metric Value Why it matters
Production and test growth Production source +513 net lines; tests +620; test support −5 Growth supplies typed worker mutations and lifecycle-safe live readers, with boundary coverage for ordering, revocation, and cleanup.

Stored data model

Persistent data-model change detected: database schema: scripts/database-worker-inventory.mjs, migration/backfill/repair: scripts/database-worker-inventory.mjs, migration/backfill/repair: src/infra/exec-approvals-mutation.worker.ts, unknown-data-model-change: scripts/database-worker-inventory.mjs. Migration or upgrade compatibility proof is recorded; maintainers should verify it before merge.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is a bounded execution-policy scheduling improvement without evidence of an urgent user-facing outage.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.

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 (5 earlier review cycles)
  • reviewed 2026-10-08T09:55:03.649Z sha 63d8523 :: needs changes before merge. :: none
  • reviewed 2026-10-08T10:34:27.239Z sha 63d8523 :: needs changes before merge. :: none
  • reviewed 2026-10-08T11:30:49.652Z sha 63d8523 :: needs changes before merge. :: none
  • reviewed 2026-10-08T17:34:42.615Z sha 62189a4 :: needs changes before merge. :: [P2] Route the remaining worker consumers through process test owners
  • reviewed 2026-10-08T17:57:32.811Z sha 5731460 :: needs changes before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot closed this Oct 8, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 8, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Oct 8, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Oct 8, 2026
@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 8, 2026
@steipete

steipete commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Integrated main in b64be50. The only manual source resolution combined both test imports; main's newer-schema admission diagnostics are preserved. The generated worker inventory was regenerated. Fresh Codex P2 review is clean, core production types and import-cycle checks passed, and all 143 focused reader, policy, authorization, plugin, and cron-grant tests passed on the integrated tree.

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. labels Oct 8, 2026
@steipete

steipete commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Current head: 5731460. Both reported consumers now use the existing host-owned fork project. Administrative CLI Bun coverage is preserved and all 25 Bun cases pass. Node proof passes the socket no-replay case and offline owner cases; socket cleanup awaits worker settlement. The CLI observation now permits worker-only SQL while continuing to verify every observed native owner's PID, missing custody, persisted state, and no replay. Fresh P2 review is clean.

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 8, 2026
@steipete
steipete enabled auto-merge (squash) October 8, 2026 18:15
@steipete
steipete disabled auto-merge October 8, 2026 18:17
@steipete
steipete merged commit 9324ed6 into main Oct 8, 2026
162 checks passed
@steipete
steipete deleted the dbasync/w6execpolicy branch October 8, 2026 18:44
@steipete

steipete commented Oct 8, 2026

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…7115)

* refactor: move exec policy mutations to the shared writer

* test: complete exec policy worker fixtures

* perf: reduce final exec policy authority checks to one read

* test: admit the exec authority reader before measuring writes

* test: retain host ownership for exec policy consumers

* test: align Bun qualification coverage for policy CLI
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 commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. scripts Repository scripts 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