Skip to content

feat: add an opt-in usage-ranked tool index - #197128

Merged
jalehman merged 6 commits into
mainfrom
feat/usage-ranked-tool-index
Nov 13, 2026
Merged

jalehman merged 6 commits into
mainfrom
feat/usage-ranked-tool-index

Conversation

@jalehman

@jalehman jalehman commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Large tool catalogs can crowd frequently used tools out of the bounded Code Mode index and Tool Search directory.

User Impact

Adds an off-by-default Labs option, agents.defaults.experimental.usageRankedToolIndex, that gives frequently and recently used OpenClaw tools priority in those indexes. Protected core tools remain included, selected entries retain canonical rendering order, and ranking never grants tool access. Empty/off cold starts preserve the existing output.

Operators can inspect, bootstrap, or clear learned usage with openclaw tools usage status|import|reset. The matching Gateway methods require operator.admin. This is limited to the built-in harness; the MCP directory and Codex harness are unchanged.

Why This Change Was Made

  • Count successful, actually executed native calls by catalog ID, not dispatch or Code Mode wrappers. Exclude errors, cancellations, running/pending work, client handoffs, and incognito sessions.
  • Accumulate in memory per run. For canonical agent transcript stores, admission and count deltas share the existing transcript actor transaction, FIFO, and final live-authority grant; they add no separate usage writer request. Custom/shared stores and late completions use the existing retained settlement writer. Scores use a 14-day half-life.
  • Let the existing session prompt-state owner freeze ranking in its checkpoint. Only session/reset, committed compaction, model/route, or harness/surface boundaries refresh it; normal turns and configuration refreshes preserve the surviving order. Child sessions inherit a filtered preference, not authority.
  • Reserve 20% of each index's character budget for recently discovered tools without usage history. Unused reserve returns to ranked entries.
  • Import the configured transcript store independently of the canonical counter database, including custom/shared stores. Preserve disjoint coverage intervals and exclude inherited history, duplicate nested dispatches, and live-managed runs. Size-omitted nested results are reported as unknown outcomes, not inferred to be successful.

Config inventory: the core count increases by exactly one (2,645→2,646) for the explicitly approved Labs setting; channel/plugin counts and hashes are unchanged. The inventory was regenerated, not hand-edited.

Storage/update behavior: agent schema 41→42 adds an initially empty STRICT agent_tool_usage table, with SQLite backup/rollback coverage and a PostgreSQL migration. Usage rows contain IDs, scores, and timestamps—not arguments, results, or per-call records. Existing metadata holds bounded import windows and 90-day run-participation receipts. Expired usage is excluded from reads and physically pruned on writes and hourly maintenance, even with the lab disabled. Retention skips closed Gateway admission and drains with its lifecycle owner. Reset fences pending writes without rewriting frozen prompts or transcripts. Crashes/failed flushes can lose unflushed counts; import does not replay live-managed runs.

Evidence

All execution proof ran in isolated workspaces and state, on the Mac Studio or on AWS Crabbox. No live Gateway or operator database was modified.

Upgrade compatibility from v2026.11.3 (Mac Studio, Crabbox)

Build of 039a1f3fac69 (rebased onto origin/main e3502d33aa08). Run on the Mac Studio through Crabbox (CRABBOX_CONFIG=~/.config/crabbox/studio.yaml, lease studio-usage-ranked-tool-index, run run_56d0c35d8d2eceb904d0c3020b794513). The test used one isolated state directory (OPENCLAW_STATE_DIR, HOME and OPENCLAW_CONFIG_PATH under ~/crabbox-work/urti-proof/up-state), Gateway port 18941 bound to loopback, and a synthetic OpenAI Responses provider on 127.0.0.1:18942 that scripts Code Mode tool calls. No live Gateway, credentials or operator data were involved. I used the synthetic provider rather than a real model, because the ranking checks need deterministic tool calls.

Before the upgrade, on v2026.11.3 (npm install [email protected], OpenClaw 2026.11.3 (847611d)):

  • Config: synthetic openai provider with models gpt-a/gpt-b, agents.defaults.model.primary, tools.codeMode.enabled, the Responses endpoint, plus openclaw config set agents.defaults.timeoutSeconds 900. config validate passed.
  • Sessions with history: hist-a (sessions_list ×3 and session_status ×1 through Code Mode, then a follow-up turn; 16 history messages), hist-b (sessions_list ×1) and hist-c (plain chat).
  • Automation: openclaw cron add --name urti-nightly --cron "0 3 * * *" --message "synthetic nightly automation", alongside the built-in heartbeat-main job.
  • Databases: agent openclaw-agent.sqlite at user_version=27, state openclaw.sqlite at 22.
  • Gateway stopped, then the standard pre-upgrade backup ran: openclaw backup create --verify produced a verified archive (2026-11-12T13-26-26.862-08-00-openclaw-backup.tar.gz, 24.5 MB).

Upgrade. openclaw doctor --fix --non-interactive ran with the PR build, as candidate Doctor does in openclaw update. It exited 0, saved pre-migration SQLite backups for both databases (*.pre-startup-migration-ff67a46b-….bak), and migrated the agent database 27→42 (agent_tool_usage present) and the state database 22→39. The PR Gateway then started on the same directory with no errors.

Everything loads intact. Results were captured through the running Gateway (config get, sessions.list, chat.history, cron list --all) and compared with the v2026.11.3 capture:

Data v2026.11.3 → PR build
4 settings (timeoutSeconds, primary model, Code Mode, Responses endpoint) identical
Session list (keys, session IDs, models) identical
hist-b, hist-c history identical (message-by-message digest)
hist-a history all 16 earlier messages preserved in order; the 2 new messages are the post-upgrade turn
urti-nightly automation identical name, schedule, enabled state and message

heartbeat-main's payload is rewritten by main's existing heartbeat migration (Doctor's "heartbeat migration backups" step). The cron capture from main e3502d33aa08 on the same snapshot is byte-identical to the PR's.

Lab off: no recording, prompt unchanged. I restored the v2026.11.3 snapshot and ran the same Doctor and the same first turn in upgraded session hist-a, once with main e3502d33aa08 and once with the PR. Instructions, the full tool schemas (10,697 B) and the Code Mode index (21 rows, 38 omitted) were byte-identical. The 50 KB input differed only in the Docs: checkout path and the minute in the turn timestamp. A further lab-off turn calling sessions_list twice left tools usage status at enabled: false, rowCount: 0.

Lab on: ranking from pre-existing history. After openclaw config set agents.defaults.experimental.usageRankedToolIndex true and a Gateway restart:

  • openclaw tools usage import --agent main --since 90 --dry-run --json reported applied: false with 2 candidate rows: sessions_list 6.0 (3 + 1 from v2026.11.3 history, plus 2 from the lab-off turn) and session_status 1.0. status still reported rowCount: 0.
  • tools usage import --agent main --since 90 applied the same 2 rows, and status then showed them.
  • In a new session, the Code Mode index grew to 31 rows (28 omitted) and now lists sessions_list and session_status, which the cold 21-row index omitted. Rows keep canonical order. status --session shows the frozen snapshot orderedToolIds: [sessions_list, session_status].
  • Pre-existing v2026.11.3 session hist-c got the same ranked index and the same frozen snapshot on its first turn with the lab on.
  • The agent database stayed at 42 throughout.

Downgrade.

  • v2026.11.3 on the upgraded directory: the Gateway refuses to start and Doctor refuses to run, both before touching anything. The first incompatibility it reports is main's state database (39 > 22): "Gateway refused startup because 1 OpenClaw database schema(s) are newer than this build … Run a build at least as new as the writer …, or stop the service and restore your pre-upgrade backup created with openclaw backup create."
  • Main e3502d33aa08 (agent schema 41) on a copy: startup is refused with "agent database for agent main … uses schema 42; this build supports 41".
  • In both cases the database versions were unchanged afterwards. Rolling back means restoring the verified pre-upgrade backup, the same as for any other schema bump.

Logs observed in the upgraded Gateway, not caused by this PR: the skill-workshop agent_end warning "Plugin invocation scope is closed" appeared 3/3 tool-call turns on both main and the PR on the same upgraded state, plus macOS-only config watcher and scratch-root notices.

Rebased head 73448cf482e9

The current head is 73448cf482e9, on origin/main 4efd662cc2c6. Two generated-only rebases followed the 039a1f3fac69 gate run:

  • Onto 2a1914519f65: the config baseline and Gateway predicates were regenerated.
  • Onto 4efd662cc2c6: package.json schemaVersions now keeps main's new state: 40 alongside the PR's agent: 42. Main's agent schema is still 41.

On 73448cf482e9, local checks passed:

  • pnpm tsgo:all, config:docs:check, gateway:validators:check, db:kysely:check, db:postgres:check and sqlite:sessions-schema:check.
  • 42 focused test files: both conflicted files' consumers, the ranking, Tool Search, Code Mode and tool-usage tests, and every non-PostgreSQL src/state migration test.

The upgrade proof above ran on the 039a1f3fac69 build. Neither later rebase touched PR runtime code.

The first rebase, onto origin/main e3502d33aa08 (136 commits ahead of 544e5c37f780), produced the head that the AWS gates and Studio proofs below ran on. Its conflicts:

  • docs/.generated/config-baseline.sha256: regenerated (pnpm config:docs:gen). Core count is main's +1, for the Labs setting.
  • src/agents/tool-search-directory.ts: kept main's run-granted exclusion (fix: narrow unconfigured GitHub tools in the built-in harness #197594's run-granted tool directory) and the PR's ranked native rows. Both isCoreCodingSurfaceToolName and isRunGrantedCoreToolId are imported, and main's new buildRunGrantedToolDirectory now filters with the PR's NativeToolDirectoryRow type. tsgo caught a predicate mismatch here that Vitest did not, and it is fixed in the same commit.
  • src/agents/embedded-agent-runner/run/attempt-system-prompt-prepare.ts: kept main's buildRunGrantedToolDirectory import and runtime-context listing alongside the PR's ToolUsageRankingSnapshot input to prepareToolPrompt.
  • Agent schema: main is still at 41 (openclaw-schema-versions.ts), so the PR's 42 still follows main's latest. No renumbering was needed.

Gates on AWS Crabbox lease cbx_e47e618961fa (real git checkout at the exact head):

  • Passed: pnpm check:madge-import-cycles, pnpm tsgo:all, pnpm config:docs:check, pnpm gateway:validators:check and pnpm protocol:check.
  • 56 focused test files passed. They cover both conflicted files' consumers (attempt-system-prompt, attempt-tool-search-prompt, attempt-session-runtime-prepare, attempt-prompt-phase), Tool Search directory/MCP/discovery, tool-usage-ranking, Code Mode, tool-search executor, the tool-usage Gateway/session tests, the CLI policy tests, the wrapper-inventory tests and every src/state migration test.
  • pnpm check:changed --base e3502d33aa08 (run run_f9115a2a559fe176dd0cca7c7d7d3946): typecheck, lint (848 s) and 37 lanes passed, including the dead-export scan, which main has fixed since the previous head. Only the Plugin SDK surface budget failed (entrypoints 163 > 162, exports 3888 > 3867, callable 2243 > 2236, wildcard reexports 1 > 0). pnpm plugin-sdk:surface:check on a clean e3502d33aa08 worktree on the same box fails with identical numbers, and this PR does not touch the Plugin SDK.

CI follow-ups

Head 6aa74a2f8959 (rebased onto origin/main d30e45c3f48e; generated predicates.js regenerated). Its CI failures on 73448cf482e9 and this head:

  • server-maintenance.telemetry.test.ts, PR-caused, fixed in test: keep tool usage retention out of the telemetry maintenance fixture. The PR schedules a tool-usage-retention maintenance job, and in the worker-free telemetry fixture it tried to launch the registry-listing worker ("tool usage retention failed: Worker-free Gateway fixture attempted to launch a worker"). The fixture now stubs pruneRegisteredAgentToolUsage, as it already does for the other storage sweeps; retention keeps its own scheduler test in server-maintenance.test.ts. The CI red was timing-dependent and did not reproduce locally before the fix. After it, both maintenance test files pass under Node and the pinned Bun fork on the Mac Studio, and locally.
  • help-exit.process.test.ts (precomputed root help): fixed on main. fix(cli): restore lightweight help and cleanup test startup #197936 (d30e45c3f48e) replaced the static node:tls import in src/cli/one-shot-exit.ts. On this rebased head the file passes on the Mac Studio under Node and Bun.
  • extensions/codex/src/node-app-server.runtime.test.ts ("gates native resource readiness…"), inherited on Linux. The command proof returns exitCode: 1, stdout: "" instead of worker-command-proof. It fails identically on clean 4efd662cc2c6 and d30e45c3f48e worktrees on Linux, while the PR head passes it on the Mac Studio (Node and Bun). This PR touches no Codex files; the shard is selected by changed-core dependency.
  • test/scripts/eager-import-closure.test.ts (PR wrapper inventory), inherited. It reports six missing packages/openclaw-id-protocol/src/* imports reached through src/gateway/openclaw-id/tunnel-principal.ts (main's OpenClaw ID work, feat(openclaw-id): link your OpenClaw ID so your owner devices connect as you #197628/feat(openclaw-id): member roles are opaque names in the protocol #197697). The same test fails identically on a clean origin/main 02f29597c107 worktree; none of those files are touched here.

Full CI on 6aa74a2f8959: 208 checks passed (including all PostgreSQL conformance shards) and 43 were skipped. Two test jobs failed, both inherited (above), which also fails the openclaw/ci-gate aggregate: checks-node-changed-extensions-bundle-1-3 (the Codex runtime test) and checks-node-compact-small-8 (the PR wrapper inventory). The telemetry and help-exit failures from earlier heads did not recur. CI was not rerun.

native-hook-relay.test.ts 120 s timeout: not reproduced. Run on the Mac Studio (darwin-arm64), whole file, interleaved main e3502d33aa08 / PR head, 25 runs per cell:

Runtime main PR head Target test duration (min / median / max) main · head
Node 24.22.1 25/25 pass 25/25 pass 157 / 161 / 163 ms · 158 / 160 / 163 ms
Pinned Bun fork openclaw-v1.4.4-20261026-191755ec11 25/25 pass 25/25 pass 158 / 162 / 167 ms · 158 / 161 / 188 ms

The CI failure was on a Linux x64 Bun shard. The Bun runs here used the same pinned fork tag (confirmed from the running process path), but on darwin-arm64. That's 0/100 failures in total, with no difference between main and the PR, so I recorded it as a non-reproducing CI timeout, not a PR defect.

Latency acceptance. On 2026-11-11 Josh reviewed the Studio latency benchmark and judged the overhead not meaningful (about +2 ms paired median, in his words), which settles the no-meaningful-overhead acceptance criterion. The instrumented 300-pair table below is kept as recorded.

Earlier rebased-head behavior proof (AWS Crabbox)

Proof build 9eac6b2e24a1 (runtime tree identical to 01679c308c1d; the later CI fixes change prompt finalization only for settled-tool runs and the tools CLI root), rebased onto origin/main 544e5c37f780. Both trees were built with pnpm build on AWS Crabbox lease cbx_43da335fa37d (c7a.8xlarge, eu-west-1). The run used one isolated Gateway (--port 18931 --bind loopback, its own OPENCLAW_STATE_DIR/HOME) and a synthetic OpenAI Responses mock on 127.0.0.1:18932 that scripts Code Mode exec calls. Turns went through POST /v1/responses. Status came from openclaw tools usage status --json [--session <key>]. No live Gateway, credentials or operator data were involved. The surface is Code Mode, whose 8,000-character index omits 37–38 of the 58–59 catalog tools on this config.

Feature off: same as main. The same config and state path ran against both builds, and the first provider request was compared byte for byte. tools was identical (16,830 B), and so was the Code Mode index (21 rows, 38 omitted). The rest of the 45,060 B input differed only in two checkout-path lines (Docs:/Source: pointing at the two worktrees). With the lab off on the head build, sessions_list was used three times and then a fresh session was opened. The index was unchanged, and tools usage status reported enabled:false, rowCount:0.

Feature on. The Gateway clock was shifted 20 days back (libfaketime, FAKETIME=-20d, for the Gateway and its CLI), and update_goal was denied:

Step Observed index / state
Session A, cold. sessions_list×3 + session_status×1 in one turn (5 requests) All 5 requests: 21 rows, 37 omitted, same index bytes (6c8dba94…). Neither tool listed. Snapshot orderedToolIds: []
Session A, next turn Same index bytes. Usage now sessions_list 3.00, session_status 1.00
New session B (fresh prefix) 31 rows, 27 omitted. Now lists sessions_list and session_status. Snapshot orderedToolIds: [sessions_list, session_status]
Session A after sessions.patch model gpt-a→gpt-b (prefix break) Index refreshed to B's selection. Snapshot re-read, newcomer first-seen times preserved
Gateway restart at the same faked clock rowCount: 2, scores 2.99997 / 0.99999 before and after (only decay over ~10 s)

Real clock, update_goal allowed again (newly added tool):

Step Observed
Restart, status Usage survived. Scores decayed by 20 days at the 14-day half-life: 1.1145 / 0.3715 (3×2^(−20/14))
Session A, same prefix Ranking stayed frozen (at still 20 days ago). The catalog refresh admitted update_goal as first-seen now, without rereading scores
Session A after a model change gpt-b→gpt-a (prefix break) 32 rows. update_goal (unused, now the only tool inside the 14-day newcomer window) entered the reserved newcomer slot. progress_card (unused, earlier id, first seen 20 days ago) left. Ranked tools stayed

The proof scripts (mock, config writer, driver) and raw logs are kept off-repo as task artifacts. Ports, state dirs and the lease were cleaned up after the run.

Rebase and gates. After the first rebase, check:changed found four PR-owned failures, and commit fix: classify tool usage SQL as worker-owned fixes them:

  • The database worker ratchet flagged 13 main-thread T1 calls in tool-usage.kernel.ts, plus 3 inherited in session-cold-storage-chunks.ts. Fix: reviewed worker/purge classifications, and tool-usage-read.worker.ts registered as worker-only.
  • The first-party mock-export ratchet flagged a mock without an isolation note.
  • The dead-export scan flagged two unused exports.

The second rebase, onto 544e5c37f780, resolved a conflict in attempt-session-runtime-prepare.ts with #197594: the GitHub publication tool-listing pin now refreshes the lazily prepared, ranking-aware prompt. That PR's new test was adapted to prepareSystemPrompt. Generated config baseline and Gateway predicates were regenerated (main's committed predicates.js lacked inheritedDefault). Agent schema 42 still follows main's 41; no renumbering was needed.

On AWS Crabbox (real git checkout at the exact head):

  • Passed: pnpm check:changed --base 544e5c37f780 lanes including typecheck-all and lint (914 s), pnpm tsgo:core:test after the test-type fix, pnpm protocol:check, pnpm gateway:validators:check, pnpm check:no-conflict-markers, the database-worker and mock-export ratchets, and targeted Vitest for the conflicted and ranking-owner files. The earlier Studio run passed all 33 PR test files.
  • Inherited red on main, unchanged by this PR: the Plugin SDK surface budget (identical failure on main), the dead export scripts/lib/mac-runtime-portability.mjs: auditMacAppPortability (from fix: bundle macOS native dependencies before signing #197383), and db:worker-inventory:check (stale on main; not a CI gate).

First full CI run (head 01679c308c1d). Six PR-caused failures were fixed in d627ff5e0f54 (fix: complete tool usage cutovers for CLI, prompt finalization, and CI inventories):

  • attempt-prompt-phase.test.ts (settled-turn finalization): the PR had switched the prompt-commit choice to inHistorySystemUpdates, so settled finalization, which has no active prompt series, committed a pending prompt. The commit now also requires the active series updater, restoring main's contract while ranking-only runs still persist the tool surface. Red under Node before, green after.
  • root-command-descriptions.test.ts: tools was a reserved, unregistered root and a root-help alias, but this PR registers it as a built-in command. tools is now a normal built-in root (it keeps its fast, plugin-free startup policy); only the legacy tool stays reserved. openclaw tools --help now shows the tools help instead of root help.
  • check:madge-import-cycles: the moved createHeldModelRun helper created a cycle between two spawn test-support files. It now lives in the leaf subagent-spawn.held-model-run.test-support.ts.
  • openclaw-agent-memory-revision-migration.test.ts: the v30→current migration now creates agent_tool_usage, so it joins the declared scope (as earlier version steps did).
  • eager-import-closure.test.ts and pr-worktree-provision.test.ts: src/state/openclaw-agent-tool-usage-schema.ts was missing from scripts/pr-lib/wrapper-components.txt.

Inherited from main, not caused by this PR: help-exit.process.test.ts > exits naturally after precomputed root help fails identically on clean 544e5c37f780 (src/entry.ts → src/cli/one-shot-exit.ts → static node:tls, from #197382; neither file is touched here). On AWS Crabbox lease cbx_8ed4d01ea875 (run run_ebde532cef8556f10fef50b0f986c57b), the fixed head passed check:madge-import-cycles, 42 focused test files (including every non-PostgreSQL migration test in src/state, both wrapper-inventory tests and the production spawn boundary), and check:changed --base 544e5c37f780 typecheck, lint (851 s) and ratchets. Only the main-inherited Plugin SDK budget and dead-export lanes remain red.

Full CI on d627ff5e0f54: complete. 215 checks passed (including all PostgreSQL conformance shards) and 49 were skipped. Two test jobs failed, which also fails the openclaw/ci-gate aggregate:

  • checks-node-compact-small-8: only the main-inherited help-exit.process.test.ts > exits naturally after precomputed root help failure described above.
  • checks-node-changed-compact-large-8: one 120 s timeout in src/agents/harness/native-hook-relay.test.ts > keeps replacement pending PermissionRequest approvals when stale approvals settle, while awaiting a session-entry write. It does not reproduce: the whole file passes locally at this head (97 tests in 49.5 s, Node and OPENCLAW_VITEST_RUNTIME=bun), and the PR does not touch that test or its entry-write path. CI was not rerun.

Transaction co-commit repair and current limitations

Publication status: the PR left draft so full CI could run. The measurements in this subsection were taken on pre-rebase head 6710d304b90a. Josh accepted the latency result on 2026-11-11 (about +2 ms paired median, not meaningful); see "Latency acceptance" above.

  • Every tool-usage kernel mutation declares the existing empty session write scope. Usage writes no longer invalidate unrelated retained session facts; a real replica regression fails without the scope and passes with it, retaining the session-mutation negative control.
  • Canonical transcript appends carry usage admission and count deltas inside their existing actor transaction. Removed the standalone begin operation and turn-end flush request. Generation checks, FIFO ordering, final live-authority checks, rollback, incognito exclusion, and the default-off flag remain intact. No schema, retention, permissions, or dependency changes in this repair.
  • The admitted logical-target binding is carried through both manager and direct-message append paths. A real logical-store regression covers both paths; it does not relax target matching. Custom/shared transcript stores retain canonical counter ownership and use the existing run-settlement writer. A crash before that foreign-store receipt may leave the run importable.
  • Imports exclude active recorders as well as durable live-run receipts. Independent read-only review found one verified P2: settlement could relabel captured pre-reset rows with a newer generation across an awaited import. The red/green regression now captures the generation with its rows before yielding. No other verified P0–P2 finding in that review.
  • Studio core types passed (1.42 s), the agents-sessions test graph passed (2.30 s), changed-file lint passed (7.02 s, zero warnings/errors), and changed-doc MDX passed (0.29 s). 100 tests across 10 affected files passed in 105.44 s. The real-spawn inheritance proof passed (1 selected / 106 skipped, 39.71 s). Final recorder proof passed 12 tests in 1.33 s, including the reset race. Commands use pnpm test <file> --maxWorkers=1. Hosted CI seconds remain pending.
  • The isolated Studio runtime build passed before the paired measurement. That build/measurement precedes only the subsequent regression-proven settlement-generation capture and nonbehavioral lint adjustments; it is not an exact-final-head full-build claim. Native content/format/freshness guards passed for this commit.

Whole-turn latency (accepted by Josh on 2026-11-11 as not meaningful). The unchanged copied localization controls ran two isolated Gateways against a shared local mock provider, randomized order with seed 0x197128, ten turns per session, 320 pairs with the first 20 discarded. Controls were verified byte-for-byte and the original workspace restored. This is actual Gateway RPC/agent execution, not external-provider latency.

300 measured pairs p50 p95
Lab off 156.20 ms 192.68 ms
Lab on 160.02 ms 219.01 ms
Paired on-minus-off +4.49 ms +65.26 ms

Both arms produced 320 canonical successful tool calls and 32 checkpoints; the off arm had no usage rows and the on arm had the expected decayed count. The measured interval had:

Worker requests per measured turn Off On
Non-audit writer requests 20.5033 20.5033
All writer requests 24.4800 24.4833
Standalone toolUsage.* requests 0 0
All worker requests 45.3867 45.4867

The one-request total writer difference is audit work; the 30 additional nonwriter requests are boundary ranking reads. Co-commit removed the separate per-turn usage writer requests, but this does not prove latency neutrality. The trace shows host reply-handling/scheduling stalls, but it does not identify their cause. This is an instrumented run: synchronous trace flushing and separate persistent Gateway processes prevent attributing the residual solely to the feature. Existing traces do not establish a Gateway GC, authority-handshake, or SQLite-commit cause. A discriminating follow-up would use an uninstrumented exact-candidate build, external timing, and reversed feature/process assignments with fresh state. Final performance acceptance remains outstanding.

Retained earlier repair proof

  • Generated-only rebase onto 26a4a89b304f: config count/hash and Gateway predicates regenerated; config docs check 7.05 s, validators check 4.70 s, core types 3.85 s. No current mergeability assertion from that historical check.
  • Helper inheritance consumes the matching admitted session entry's seed. Its real-spawn red/green regression preserves parent timestamp and deny filtering without reading live scores. Restored prompt checkpoints share one snapshot identity; ordinary turns do not rewrite them.
  • Earlier complete production-spawn suite: 107 tests / 240.15 s; eight sibling files: 84 tests / 71.94 s; runtime preparation: 19 tests / 34.72 s; full build: 190.49 s with an existing CSS-size advisory. These are retained historical proofs, not final-head full-suite/build claims.
  • The previous 510-pair trial measured +7.34/+86.24 ms paired p50/p95. The current 300-pair trial above supersedes it for this co-commit candidate, without claiming the tail acceptance gap is closed.

Retained initial feature proof

The following evidence covers the initial feature implementation; unchanged contracts were not rerun solely because the branch was rebased.

  • Core and UI type checks passed. Bounded lint passed with no warnings/errors; docs MDX sanity passed.
  • Worker-boundary proof covers import idempotence, disjoint windows, delayed append timestamps, live/off/live transitions, custom/shared transcript stores, reset fencing, and idle retention.
  • SQLite migration, rollback, scoped backup restoration, retained-content witnesses, and the preceding migration passed. Native PostgreSQL migration/receipt/decay/reset and preceding-migration checks passed with required search extensions installed only in the isolated fixture.
  • Independent source review completed; all confirmed findings were resolved. The final omitted-result finding was reproduced through the real transcript projection and fixed with a failing-then-passing regression.
  • Prompt/rendering tests cover frozen checkpoints, disable-without-boundary, inheritance, canonical order, protected tools, newcomer budget, catalog refreshes, and baseline bytes.
  • Recording, subscriber, nested executor, CLI, admin RPC, configuration, and Labs registry tests passed. The stream projection fixture now explicitly supplies the new optional subscriber facts; all 42 tests pass.
  • Synthetic overhead, 120,000 calls / 100 measured batches after 20 warmups: recording 55 ns p50 / 85 ns p95; worker flushes of 10 rows 0.63 ms p50 / 0.86 ms p95. No flush warnings.
  • Synthetic Labs browser proof verified the default-off row and exact opt-in config patch/acknowledgement. Before/after screenshots below were inspected and contain no private state.

The latency overhead was accepted by Josh on 2026-11-11; the upgrade-compatibility proof above covers v2026.11.3 state. Hosted CI results are recorded in the rebased-head section above.

Changed-test wall times and test-cost allocation

Commands were pnpm test <file> --maxWorkers=1; PostgreSQL files used the native conformance runner. Times include existing compiler/module/worker setup. The slower cold invocations are setup-dominated; the new database fixtures need the actual migration/worker boundary, rather than a mocked SQL helper. CI seconds: not yet available.

Test file Passing wall time
extensions/copilot/src/tool-bridge.test.ts 49.96 s
src/agents/code-mode.bridge.lifecycle.test.ts 20.69 s
src/agents/code-mode.test.ts 47.74 s
src/agents/embedded-agent-runner/run/attempt-nested-tool-activity.test.ts 14.73 s
src/agents/embedded-agent-runner/run/attempt-plan-completion.test.ts 16.38 s
src/agents/embedded-agent-runner/run/attempt-session-runtime-prepare.test.ts 11.08 s
src/agents/embedded-agent-runner/run/attempt-stream-prepare.test.ts 9.01 s
src/agents/embedded-agent-runner/run/attempt-tool-search-executor.commit.test.ts 7.31 s
src/agents/embedded-agent-runner/run/attempt-tool-search-executor.test.ts 6.59 s
src/agents/embedded-agent-runner/session-prompt-state.tool-usage.test.ts 2.13 s
src/agents/embedded-agent-runner/session-prompt-state.tool-usage.worker.test.ts 11.10 s
src/agents/embedded-agent-subscribe.tool-usage.test.ts 13.07 s
src/agents/tool-search-directory.test.ts 11.24 s
src/agents/tool-usage-ranking.test.ts 1.85 s
src/agents/tool-usage-recorder.test.ts 1.97 s
src/agents/tool-usage.test.ts 1.50 s
src/cli/tools-cli.test.ts 2.00 s
src/config/sessions/tool-usage-import.test.ts 1.38 s
src/config/sessions/tool-usage.test.ts 35.40 s
src/config/zod-schema.agent-defaults.test.ts 35.85 s
src/gateway/server-maintenance.test.ts 7.99 s
src/gateway/server-methods-list.test.ts 14.62 s
src/gateway/server-methods/tool-usage.test.ts 37.80 s
src/infra/database-engine/agent-port-descriptor.test.ts 10.52 s
src/state/openclaw-agent-active-event-facts-migration.test.ts 10.72 s
src/state/openclaw-agent-active-event-facts-migration.postgres.test.ts 31.36 s runner time
src/state/openclaw-agent-tool-usage-migration.test.ts 8.00 s
src/state/openclaw-agent-tool-usage-migration.postgres.test.ts 30.96 s runner time
ui/src/pages/labs/labs-registry.test.ts 2.12 s

The original 2,067-line allocation, the separate 335-line inheritance repair allocation, and the exact 400-line co-commit allocation cover this change's exact net test/fixture growth: storage and cross-backend migrations, provenance and recording, frozen prompt boundaries and rendering, and operator controls. The shared scalar is unchanged.

Labs screenshots

Before:

Labs before the usage-ranked tool index option

After, default off:

Labs with the usage-ranked tool index option, off by default

@clawsweeper

clawsweeper Bot commented Nov 11, 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 app: web-ui App: web-ui gateway Gateway runtime cli CLI command changes agents Agent runtime and tooling extensions: copilot size: XL labels Nov 11, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:feature Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed clawsweeper:intake:feature Preliminary submission classification; full source review pending. labels Nov 11, 2026
@clawsweeper

clawsweeper Bot commented Nov 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR adds opt-in usage ranking for bounded tool indexes, persistent usage counters, and administrative inspection, import, and reset commands.

Example: An oversized Code Mode catalog omits sessions_list despite repeated successful use.

  • Before: The reported cold index has 21 rows and omits sessions_list.
  • After: With ranking enabled, a fresh session includes sessions_list and session_status while the existing session retains its frozen index.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) Useful, source-consistent implementation with supplied product-path and stable-release upgrade proof; inherited CI failures remain a landing concern.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): Supplied output exercises isolated built Gateways through Responses and CLI entry points with a scripted provider, showing ranking, frozen prefixes, restart persistence, decay, and import; inspected Labs screenshots show the default-off control, and the verified runtime blobs are unchanged since the prior review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Feature · Worth it: Yes · Fix scope: Complete
User problem: Frequently used tools can remain outside bounded prompt indexes when a catalog is large.
Reason: The maintainer-authored direction provides an explicit default-off capability while preserving tool authority, cold-start output, and session prefix stability.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-approved feature remains absent from main, and this re-review found no actionable defect; the required CI gate still reports inherited failures.

Priority: P2
Reviewed head: 6aa74a2f8959a090290d480ac50e47857ad5c151

Before merge

None.

Findings

None.

Agent review details

How this fits together

The built-in agent runtime records successful native tool calls in agent storage; the existing session prompt owner freezes their ranking for Code Mode and Tool Search renderers, while administrative CLI commands use authenticated Gateway RPCs.

flowchart LR
  A[Successful native tool calls] --> B[Run usage recorder]
  B --> C[Transcript actor and settlement writer]
  C --> D[Agent usage storage]
  D --> E[Session prompt checkpoint]
  E --> F[Bounded tool indexes]
  G[Administrative CLI] --> H[Admin Gateway RPCs]
  H --> D
Loading

Technical review

Best possible solution:

Retain the opt-in implementation using the existing transcript, prompt-checkpoint, and worker owners, with the documented upgrade and rollback behavior.

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

This is a feature request; source and supplied Gateway output establish the overflowing-index scenario without a reviewer-run reproduction.

Is this the best way to solve the issue?

The implementation places recording, persistence, and frozen ranking with their existing owners, and the re-review did not establish a smaller complete alternative or an introduced defect.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Bounded Code Mode index keeps the original intent (c742cae: Expose exact tool identities and compact signatures without an initial discovery turn while keeping the prompt bounded.)
  • Tool Search directory fitting keeps the original intent (d2b9a75: Fit directory rows using exact character accounting and render once without changing catalog ownership.)
  • Session tool and prompt checkpoints keeps the original intent (1f7b2f1: Keep provider-visible tool definitions stable across ordinary and event turns while enforcing current execution authority.)
  • Reserved tools CLI root changes intended behavior with a stated reason (390a759: Keep mistaken Gateway tools RPC invocations off plugin startup; the PR explains registering a real built-in root while retaining its lightweight startup policy.)
  • Agent schema migration safeguards keeps the original intent (b6ed907: Add an empty companion table with scoped migration, content-preservation, and older-reader refusal contracts.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Verified review scope: GitHub’s complete prior-head tree compared with the checkout shows identical PR runtime blobs since 73448cf482e991a297b582ddeef8c2b5c0dd8e4f. Differences among introduced paths are regenerated predicates, the telemetry fixture stub, and a rebase-carried English label. (src/gateway/server-maintenance.telemetry.test.ts:51, 6aa74a2f8959)
  • Complete proof body inspected: The full body matches the captured SHA-256 f8305cbcf67b23c30fd4b2dc26a426b9cf22a739a1779f0a2ca8c3a7acc1ff0b. It records isolated Gateway ranking, frozen-prefix, restart, decay, import, and v2026.11.3 upgrade results. (6aa74a2f8959)
  • Visual evidence inspected: The prepared manifest contained unrelated OpenClaw ID images. Direct inspection of the PR’s actual linked before/after images confirms the added Labs row is off by default; the scratch filesystem rejected downloads, so the images were inspected from read-only network output. (ui/src/pages/labs/labs-registry.ts:53, 6aa74a2f8959)
  • Ranking preserves the catalog boundary: Selection iterates supplied catalog rows, enforces character budgets, preserves pinned entries and canonical rendering order, and cannot introduce an ID from the saved ranking alone. (src/agents/tool-usage-ranking.ts:51, 6aa74a2f8959)
  • Administrative authority: All three new Gateway methods require operator.admin; import and reset retain the existing mutation-authority and worker-write boundaries. The current-head security guard explicitly requires no additional SecOps approval. (src/gateway/methods/core-descriptors.ts:756, 6aa74a2f8959)
  • Remaining CI failures: Annotations identify the Codex worker-command proof failure and missing OpenClaw ID wrapper imports. The full PR body records identical failures on clean main worktrees; the aggregate failure is visible in https://github.com/openclaw/openclaw/actions/runs/43331029905. No diff-caused repair was established. (6aa74a2f8959)

PR surface

PR surface statistics unavailable: the file list is incomplete.

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Configuration addition 1 default-off Boolean agents.defaults.experimental.usageRankedToolIndex makes the approved capability an explicit opt-in.
Administrative API 3 operator.admin RPCs Status, import, and reset are administrative operations rather than new model-facing tools.
Persisted model Agent schema 41 → 42; 1 new table agent_tool_usage starts empty; SQLite and PostgreSQL migrations and stable-release upgrade evidence cover the new storage.

Labels

Label changes:

No label changes.

Label justifications:

  • P2: This is an optional improvement for oversized tool catalogs with limited default-off exposure.
  • 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 execution lanes are retired.

History

Review history (3 earlier review cycles)
  • reviewed 2026-11-11T08:15:53.291Z sha 944fc1d :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-12T18:07:05.796Z sha d627ff5 :: blocked before merge. :: none
  • reviewed 2026-11-12T22:45:21.423Z sha 73448cf482e991a297b582ddeef8c2b5c0dd8e4f :: needs maintainer review before merge. :: none

Reviewed November 12, 2026, 7:25 PM ET / November 13, 2026, 00:25 UTC (Revision 4).

@jalehman
jalehman force-pushed the feat/usage-ranked-tool-index branch 2 times, most recently from 0ce49ec to 05fd27e Compare November 11, 2026 15:23
@clawsweeper clawsweeper Bot removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. labels Nov 11, 2026
@jalehman
jalehman marked this pull request as ready for review November 12, 2026 07:55
@github-actions

github-actions Bot commented Nov 12, 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: 6aa74a2f8959a090290d480ac50e47857ad5c151
  • Maintainer: @jalehman
  • Repository role: admin

These security sensitive changes were made:

  • src/agents/harness/prompt-tool-policy.ts: Controls sandbox containment or tool execution authority. Check filesystem and network isolation, approval scope, and command allowlists.
  • src/gateway/methods/core-descriptors.ts: Controls Gateway authentication, pairing, or caller permissions. Check identity validation, scope checks, and revocation.

Carefully review these changes before merging.

@jalehman
jalehman force-pushed the feat/usage-ranked-tool-index branch from 6710d30 to 0710ddc Compare November 12, 2026 09:50
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Nov 12, 2026
@jalehman
jalehman force-pushed the feat/usage-ranked-tool-index branch from 0710ddc to 01679c3 Compare November 12, 2026 10:30
@jalehman

Copy link
Copy Markdown
Contributor Author

Current head d627ff5e0f54 is ready for review: rebased onto main, behavior proof on an isolated AWS Crabbox Gateway is in the PR body (feature off byte-identical to main; ranking change from repeated use; prefix stability and refresh; newcomer slot; restart persistence and decay).

CLI note: tools was reserved in 390a759 / cf43b92 to keep the Gateway tools.* RPC namespace off plugin startup. This PR registers tools as a built-in root (tools usage status|import|reset) with the same no-plugins / no-proxy startup policy, keeps singular tool reserved, and openclaw tools --help now shows the tools help instead of root help.

Remaining CI reds: checks-node-compact-small-8 (help-exit.process.test.ts) reproduces on clean main 544e5c3 (node:tls import in one-shot-exit.ts since #197382); checks-node-changed-compact-large-8 is a single 120s timeout in native-hook-relay.test.ts that passes locally and is in code this PR does not touch.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 12, 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. labels Nov 12, 2026
@jalehman
jalehman force-pushed the feat/usage-ranked-tool-index branch from 73448cf to 6aa74a2 Compare November 12, 2026 23:41
@jalehman

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Since 73448cf482e9, head 6aa74a2f8959 adds the following. There are no runtime changes beyond the rebase.

  • A rebase onto d30e45c3f48e, with the generated predicates.js regenerated.
  • A test-only fix: server-maintenance.telemetry.test.ts now stubs pruneRegisteredAgentToolUsage in its worker-free fixture.

The remaining red CI is inherited (Codex node-app-server.runtime.test.ts; eager-import-closure.test.ts OpenClaw ID wrapper inventory). The evidence is in the PR body.

@clawsweeper

clawsweeper Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@jalehman
jalehman merged commit 8a328bf into main Nov 13, 2026
265 of 269 checks passed
@jalehman
jalehman deleted the feat/usage-ranked-tool-index branch November 13, 2026 00:30
@jalehman

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 Nov 13, 2026
* feat: add an opt-in usage-ranked tool index

* fix: preserve tool ranking across admitted runs

* fix: co-commit tool usage with transcript writes

* fix: classify tool usage SQL as worker-owned

* fix: complete tool usage cutovers for CLI, prompt finalization, and CI inventories

* test: keep tool usage retention out of the telemetry maintenance fixture
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Nov 17, 2026
Absorb jump onto openclaw#129388 head 51ff02d (🌊 GO msg 1572279218795188426). Lane
checkpoint for review; not a presentation move, not Mode-B accepted.

Parents (first-parent ancestry preserved; no rebase, no squash):
  1st: 51ff02d  openclaw#129388 head (codeagent/85651-upstream-1ba243c8-gates)
  2nd: 9122a49  openclaw/openclaw main (dispatch pin)
  merge-base: 401a1de (single; upstream +2284)

Mechanics: diff3, 76 conflicted paths resolved per hunk (74 content, 2
modify/delete). Generated artifacts seeded from upstream, then regenerated
from the merged sources (postgres schema/catalogs, gateway validators,
config doc baseline, worker-access inventory). Per-file table in the lane
output.md.

Schema renumber (follows the 2026-11-09 ruling pattern of e4a5562):
  - upstream 8a328bf (openclaw#197128) takes agent schema 42 (agent_tool_usage)
  - session_recipient_authority moves to agent schema 43
    (OPENCLAW_AGENT_SCHEMA_VERSION 43) in the SQLite owner, PostgreSQL
    ladder (41 -> 42 tool usage -> 43 authority), backup scopes, witness,
    port descriptor pin and package schemaVersions
  - the fleet bridge classifies 38-42 by markers (authority, creation
    receipts, active event facts, tool usage, payload CHECK); jump 14's 42
    (upstream 41 + authority, no tool usage) runs upstream 42 + the
    idempotent authority step; other 42 shapes are refused before any write
  - Doctor keeps a full image for the below-marker jump-14 42
  - a PostgreSQL jump-14 42 store fails closed (fleet runs SQLite)

Semantic repairs needed by the composition (tsgo/test-graph):
  - fork's session-delivery codec admits upstream's mediaCandidate kind and
    agentTurn.reviewedTaskId; produced-delivery checks name agentTurn and
    mediaCandidate instead of "not systemEvent" (fork postCompactionDelegate)
  - worker readSessionDelivery rebuilt on the fork's load-result reader
  - fork-moved owner modules carry upstream's in-place edits
    (removalReason run_rekeyed/retention, requester_waiting outcome,
    async usage cost, continuation freeze inside the preparation IIFE)
  - continuation reset retention runs upstream's stopSessionResetWork
    (subagents then exec processes); retained-send stop cause derives from
    the cleanup reason
  - consumedContinuationTraceparent reads freshEntry (upstream removed
    entryForPatch with cron-continuation restore)
  - one requester-origin projector (upstream projectUserTurnRequesterOrigin)
  - fork commands enter the domain-command census and classifier
  - fork tests adapted to upstream's prepareSessionMaintenanceRequest and
    the fork's registerRun ownership contract

Co-Authored-By: Claude Opus 5.5 <[email protected]>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Nov 19, 2026
…'s 42 and 43

The 41bdde2 merge moved continuation's recipient-authority step from 42
to 44: upstream owns 42 (tool usage, openclaw#197128) and 43 (pending-input
endings, openclaw#200533) and is at 43. The pins follow, in the pure tree's own
shape (no bridge):

- owner suite: fresh, v18, v24, derived upstream 32-38, current-schema and
  double-apply rows read 44; the derived upstream schemas also drop 42's
  tool usage and 43's endings; captured upstream rows now 39-43 (new
  fixtures openclaw-agent-schema-v42.sql = blob 43b1886 at 6691aca,
  the last schema-42 commit, and v43.sql = blob 2a6bb45 at 703c82d,
  unchanged through 41bdde2); the double-apply row starts from captured
  43; a new refusal row: a 43 holding upstream's 42 is refused by upstream's
  own check (session_pending_inputs) before any write.
- Doctor suite: upstream 37-43 -> 44 inside the declared scope, re-run
  no-op, exact restore; stores below 43 are staged before pending-input
  first use (upstream's 43 scope names that AUTOINCREMENT table, so a
  present one takes a full image instead).

Revert-proofs (temporary edits, restored byte-exact):
- authority step removed: 15/22 owner rows and 7/7 Doctor rows red
  ("missing table session_recipient_authority"); fresh, current-44,
  PG-separator and the three refusal rows stay green;
- AGENT_RECIPIENT_AUTHORITY_SCHEMA_VERSION left at 42: exactly the captured
  upstream 42 and 43 rows and the 43-based double-apply row go red, with
  the same missing-table refusal. Upstream's real 42/43 stores need 44.

Owner 22/22, Doctor 7/7.

Refs openclaw#129388

Co-Authored-By: Claude Opus 5.5 <[email protected]>
maplel pushed a commit to maplel/openclaw that referenced this pull request Nov 24, 2026
)

* fix(plugins): portable plugin-state keys for PostgreSQL

Use an exclusive SQL lower bound for Doctor pagination instead of a NUL-suffixed cursor. Reject new NUL keys in test-only plugin-state fixtures while retaining legacy SQLite adoption reads.

Add real PostgreSQL Doctor regression coverage and register it in conformance and database-worker lanes. Refs openclaw#184862 openclaw#188642.

* test: account for rebased plugin-state coverage

* test(clickclack): import legacy revocations before adoption

(cherry picked from commit 395cac7)

Release adaptation: Only exclusive SQL lower bound in kernel and Doctor pagination; preserve legacy SQLite keys and public validation. Regression exercises real Doctor paging and inspected executed SQL bindings; no NUL-key fixture policy, schema or unrelated tests.

Follow-up dispositions: 8253356 fix: preserve child results after source lifecycle changes (openclaw#202708); f3f89c7 fix: show saved child results when completion delivery fails (openclaw#202664); c45faa8 fix: align CI tests with admitted tool calls (openclaw#202655); 5c9389a fix: make channels add report required plugin install failures (openclaw#202091); 52b9188 fix: show hosted model details in `models list` without a Gateway (openclaw#202490); d248a76 fix: show an outcome when kept child chats return no answer (openclaw#202423); 5148804 fix(discord): check a queued message's access again when its turn starts (openclaw#202330); 2470d62 fix: let setup use account models with a fresh catalog (openclaw#202019); 9fa0b92 fix: let PostgreSQL Gateways start with plugin-backed secrets (openclaw#201063); c180824 fix(plugins): Talk and plugin-loading requests fail on PostgreSQL Gateways (openclaw#201976); cb5cfb2 fix: keep a doubtful killed-update recovery on the repair path (openclaw#201361); 17c5fb0 fix(state): PostgreSQL state created before Template bootstrap deferral is refused as schema drift (openclaw#197425); b5c1277 fix: let resumed parents collect children stopped by restart (openclaw#201460); f920a7e chore(postgres): qualify cron completion during graceful shutdown (openclaw#201246); 1680f54 fix(openai): new ChatGPT subscription models missing until an OpenClaw release (openclaw#201130); 0d8820a fix(media): image descriptions use the ChatGPT OAuth route when OpenAI has no API key (openclaw#199299); ee3e16e test(agents): trim and fold low-value regression suites (openclaw#198916); b8029b4 test(agents): qualify PostgreSQL simple-completion acquisition (openclaw#200956); 703c82d fix(sessions): record queued input end causes and recover them across crashes (openclaw#200533); 23fca1a fix: let the next update continue after a killed update when nothing is left to repair (openclaw#200680); d565e17 fix(ci): retire deleted session fork test from inventory (openclaw#200611); 4cf12c6 chore(postgres): qualify prompt refresh and rebalance CI (openclaw#200488); d460273 fix(templates): release earlier Template-managed agents (openclaw#200303); ff75829 fix(update): --no-restart update fails when the Gateway restarts itself during Doctor's stop (openclaw#200181); 0b2ad60 chore(postgres): cover compaction watched-session prompts (openclaw#200117); b90c573 test: consolidate redundant coverage (198795 recut) (openclaw#198943); a042363 test: consolidate redundant coverage (198793, part 2) (openclaw#198936); 9bfad2b test: consolidate suites while retaining recovery owners (openclaw#198933); 4e9812c test: consolidate redundant coverage (198789, part 2) (openclaw#198932); 90814f5 fix(subagents): stops a finished sub-agent's chat being deleted before its parent reads the result; 799bc0b fix(ci): stabilize hourly fixtures and retire unused exports (openclaw#199851); e4a3093 perf(update): replace the candidate canary with a runtime contract check (openclaw#198268); a4cc2ad fix: undo cold-session compaction CPU and latency regressions (openclaw#199561); 55fec79 fix(agents): stop divergent mid-turn overflow recovery (openclaw#199636); 2c4413a fix: reduce Gateway stalls under filesystem pressure (openclaw#197510); 37d977f fix: output reducers are skipped in headless and Code Mode runs (openclaw#199434); c9ee264 fix(compaction): concurrent sessions wait for each other's summaries during compaction (openclaw#196550); 2471ddc feat: let agents review generated images before delivery (openclaw#198227); 21f7dc6 fix(github): publication fails with PostgreSQL session or state stores (openclaw#193749); 63d9e57 fix(ci): new PostgreSQL suites are omitted from conformance (openclaw#198390); 466a4b6 fix(telegram): steered answers quote the wrong input (openclaw#178124); 87b6f52 fix(delivery): resend routed Telegram finals after an ambiguous network failure (openclaw#192779); 68a839b fix: isolate held agent databases until explicit restoration (openclaw#198180); cff99b2 fix(agents): keep provider history append-only across runs (openclaw#197874); 8a328bf feat: add an opt-in usage-ranked tool index (openclaw#197128); 097e648 fix(ci): plan only executable infra tests (openclaw#197911); 76385fd fix(models): discovered models become "Unknown model" after restart or an ended sign-in (openclaw#197784); 89d4177 fix(plugin-state): guarded calls fail until Gateway restart after an unknown write outcome (openclaw#197790); baca36e fix(sessions): commit selected invitations with original messages (openclaw#184512); 699e538 fix(sessions): drain passive notices on sessions_send resumes; d6ded18 chore(ci): drop retired test-lines allocation records (2/3) (openclaw#197656); e0dd020 fix(agents): collect process results at suspended-run capacity; 4897740 feat(auth): preserve delegated OCE user profiles and permissions (openclaw#196856); 7197ce1 feat(templates): install bundled plugins through native management (openclaw#196349); 9c6ee9b feat: let Template automations start paused for onboarding (openclaw#196323); 79a6214 fix(message): retain local final replies in conversation history (openclaw#187795); caa978c feat(templates): open durable chat before verified setup (openclaw#196392); 78e73aa fix(sessions): cold PostgreSQL conversations fail after idle readers close (openclaw#189991); b6ed907 perf(sessions): persist active transcript facts for hydration (openclaw#193682); 1595dd2 feat(plugins): reauthorize accepted session work (openclaw#176886); b43ad0a fix(models): avoid reloading plugins on catalog refresh (openclaw#193903); 0947d02 fix(ci): avoid unrelated PostgreSQL runs and admit owned tests (openclaw#193870); 428ca7d feat(openclaw-id): add Gateway membership authority and publication behind the Labs flag (openclaw#192335); c718583 fix(update): repair refuses forever after a verified update fails a later step (openclaw#193132); 3f64174 fix: deliver background replies after a reload retires the turn registry (openclaw#193130); 982f3b1 fix(imessage): report Automation failures after Gateway updates (openclaw#186117); 31b28e9 fix(agents): wait for a peer OAuth refresh before failing request auth (openclaw#192906); cf50d4a feat(storage): support read-only PostgreSQL standby inspection (openclaw#192645); 82fd4e6 fix(agents): retain stale session target refusal reasons (openclaw#192681); 8ac4e19 fix(worktrees): reserve capacity on PostgreSQL (openclaw#192537); 718b349 fix: reduce session startup stalls under storage contention; 08f4a19 refactor(skills): move Skill Workshop into its bundled plugin (openclaw#192471); 837402a fix(clawrouter): keep upstream credit failures off the shared key (openclaw#192575); f38495f fix(plugins): reject late routing from canceled runs (openclaw#192492); dc5d61a improve(sessions): reduce unnecessary maintenance query rows (openclaw#192023); c4bf0dc fix(sessions): avoid extra maintenance scans for embedded archives (openclaw#184507); e44b3d6 fix(team-reports): recover after database connection loss (openclaw#192020); 991fb33 fix(logbook): recover after database connection loss (openclaw#192011); e6d0d2e fix(test): include omitted PostgreSQL conformance suites (openclaw#191962); da5ff0f fix(codex): reject native hooks from a previous run (openclaw#191788); 09f0b0b feat(plugins): add skill usage runtime for plugins (openclaw#191661); 00b2ff4 fix: parent sessions miss child approvals with a custom session store (openclaw#189827); be44b10 fix: stop completed session writes retaining request data (openclaw#191197); d40aa7c fix(sessions): replay creation requests across Gateway restarts (openclaw#190862); d894035 fix: await Doctor shared-state repair preparation (openclaw#190875); b515cc7 feat: fork threaded conversations with Telegram support (openclaw#190783); def6349 feat(plugins): plugins can run a hidden forked turn of a session with their own tools (openclaw#190950); d983e34 feat(plugins): plugin commands can continue the agent with a replacement prompt, on every channel (openclaw#190908); ea3f0b8 fix(ci): provision Node test prerequisites and retain Baseten routing (openclaw#191050); 29503e1 fix(update): Gateway stays stopped after the updater process dies mid-update (openclaw#188497); fc8c2d0 fix(update): preserve unfinished handoff artifacts (openclaw#190571); 7c26e8c fix(ci): cover PostgreSQL managed update handoffs (openclaw#190336); 4913d41 fix(ci): prevent truncated PostgreSQL target listings (openclaw#189509); 8925f62 fix(gateway): start restored PostgreSQL homes on the first attempt (openclaw#190291); 177fe32 feat(models): preserve inference capabilities in opt-in catalog v3 (openclaw#189678); 7faf32d feat: retain repository disk authority through recovery (openclaw#189106); a658df3 feat(database): capture externally quiesced SQLite migrations; 0f9e7f7 feat(database): capture exact SQLite migration capsules; 4fb684e feat(backup): add PostgreSQL local companion checkpoints; c89a101 fix(doctor): migrate auth profiles on PostgreSQL stores (openclaw#189639); 799de09 fix(ci): split oversized workspace and setup files (openclaw#189356); 21ee847 fix(acp): keep completed run conversations resumable (openclaw#189273); fce0e56 perf(sessions): open cold history without restoring archives (schema 39) (openclaw#188397)

Validation: Baseline1 NUL-binding assertion failure/21passing; candidate22/22passes (188693-green.log). Real SQLite Doctor path and generated SQL proved; no native PostgreSQL server execution claimed.

Co-authored-by: RomneyDa <[email protected]>
(cherry picked from commit 0895146d8c1493146f5c6461eee0b10c329bdd1e)
(cherry picked from commit f8ccaa70bc9773d6bbb569bc0e275eee0c544ead)
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 cli CLI command changes docs Improvements or additions to documentation extensions: copilot 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