Skip to content

feat(audit): record observed runtime skill usage - #141004

Open
wiecon-dev wants to merge 826 commits into
openclaw:mainfrom
wiecon-dev:memorytunning-pr-v2
Open

wiecon-dev wants to merge 826 commits into
openclaw:mainfrom
wiecon-dev:memorytunning-pr-v2

Conversation

@wiecon-dev

@wiecon-dev wiecon-dev commented Sep 7, 2026 •

Copy link
Copy Markdown

feat(audit): record observed runtime skill usage

What Problem This Solves

OpenClaw can emit skill-usage diagnostics while an agent reads or invokes a skill, but that observed runtime signal is not available through the durable audit surface. Operators therefore cannot inspect which skills were actually used during a run from the audit CLI/API.

Why This Change Was Made

The first revision inferred skill selection from prompt text after attempt completion. Review correctly called that out as the wrong boundary: prompt inference is not proof of skill use and it also risked perturbing the embedded attempt-result contract.

This revision records only observed runtime skill usage from the existing before_tool_call skill-usage boundary:

  • Skill read/command activation is detected where recordRunSkillUsage() already emits runtime diagnostics.
  • A metadata-only skill_selection audit event is emitted with selectionSource: "observed_runtime" and selectionConfidence: "observed".
  • No prompt text, tool arguments, tool output, or skill file contents are persisted.
  • skill_selection is persisted outside run-start deduplication so it is not dropped after agent.run.started.
  • Legacy audit.list remains run/tool-only; the versioned audit.activity.list surface exposes skill-selection records.
  • completeEmbeddedAttemptResult() is restored to the production calling contract, preserving the existing truncated-stream/tool recovery behavior.

User Impact

  • openclaw audit --kind skill_selection can show observed skill usage for a run through the activity-list API.
  • Existing audit.list clients keep their shipped run/tool event shape and do not receive the new record kind.
  • Operators get a durable metadata trail for actual skill usage without sensitive prompt or file-content capture.

Evidence

Current-head validation after merging upstream/main and removing the unrelated USER.md bootstrap policy change:

pnpm tsgo:core
pnpm protocol:check:swift
pnpm db:kysely:check
pnpm lint:kysely
pnpm check:architecture
pnpm test src/agents/workspace.bootstrap-privacy.test.ts src/audit/audit-events.test.ts src/gateway/server-methods/audit.test.ts packages/gateway-protocol/src/schema/audit.test.ts

Results:

  • pnpm tsgo:core passed.
  • pnpm protocol:check:swift passed after regenerating GatewayModels.swift.
  • pnpm db:kysely:check passed after regenerating src/state/openclaw-state-db.generated.d.ts.
  • pnpm lint:kysely passed after moving ordinary companion-table insert/read/prune queries to the sync Kysely owner.
  • pnpm check:architecture passed, including generated Kysely verification, Kysely guardrails, and database-first legacy-store guard.
  • Targeted Vitest run passed 4 shards in 22.13s.
  • audit-events.test.ts: 54 tests passed, including companion-table storage, bounded retention, and observed runtime projection.
  • server-methods/audit.test.ts: 34 tests passed, including explicit skill_selection/observed activity access and V1-compatible unfiltered activity.
  • audit.test.ts: 7 protocol schema tests passed, including activity schema discrimination.
  • workspace.bootstrap-privacy.test.ts: 9 tests passed; shared sessions now drop only root MEMORY.md, leaving USER.md behavior unchanged.
  • pnpm exec oxlint src/audit/audit-event-store.skill-selection-storage.ts src/state/openclaw-state-db.generated.d.ts passed. A full local pnpm lint:core was started but manually stopped after 6+ minutes with no diagnostic output; CI remains the authoritative full core-lint signal.

Published-release upgrade, older-reader, and candidate-reopen proof:

  • the published v2026.9.4 tag at 3a9d69db3 created a fresh state database and wrote legacy agent_run sequence 1.
  • candidate head 7d74807a5 opened that exact database, preserved the legacy row, created the additive audit_skill_selection_events table, and wrote observed debug-toolkit sequence 2.
  • v2026.9.4 then reopened the candidate-used database without migration or schema errors, ignored the additive table, and wrote a second legacy agent_run at shared sequence 3.
  • the candidate reopened the same database and returned sequences [3, 2, 1], including both legacy rows and the retained skill-selection row.
  • physical SQLite readback reported integrity_check: ok, user_version: 17, audit_events: 2, and audit_skill_selection_events: 1.
  • this proves published release → candidate upgrade → published older-reader open/use → candidate reopen while preserving the legacy table, additive companion, and shared sequence allocation.

Changed Files

  • src/skills/runtime-skill-selection.ts — observed-only metadata marker.
  • src/agents/agent-tools.before-tool-call.wrapper.ts — emits skill_selection from the existing observed skill-usage boundary.
  • src/audit/agent-event-audit.ts — projects observed-only skill-selection records and routes them outside run-start deduplication.
  • src/audit/audit-event-store.ts / src/audit/audit-event-store.skill-selection-storage.ts / src/audit/audit-event-types.ts — durable store/types for observed skill-selection metadata, with ordinary companion-table access through Kysely.
  • src/state/openclaw-state-db.generated.d.ts — generated Kysely declarations for the companion table.
  • src/gateway/server-methods/audit.ts — exposes skill-selection through audit.activity.list while preserving legacy audit.list.
  • packages/gateway-protocol/src/schema/audit-activity.ts — versioned activity schema includes skill_selection.
  • packages/gateway-protocol/src/schema/audit.ts — legacy audit schema stays run/tool-only.
  • src/commands/audit.ts — CLI uses the activity surface and renders selected skill metadata.
  • docs/gateway/audit.md / docs/gateway/config-observability.md / docs/cli/audit.md — document the approved metadata fields, default-on collection, 30-day retention, separate 100,000-row cap, compatibility behavior, and explicit CLI filters.

Test Plan

  1. Verify observed skill reads/commands emit skill_selection audit events.
  2. Verify skill_selection persists between run start and terminal events.
  3. Verify audit.activity.list and CLI expose skill-selection records.
  4. Verify legacy audit.list remains run/tool-only.
  5. Verify attempt-result recovery tests still pass.
  6. Verify existing SQLite state opens, creates the companion table, preserves old activity rows, and reopens with skill-selection rows intact.

Review findings addressed (2026-10-10)

All five ClawSweeper code findings are fixed on this head:

  • Distinguishable skill identities — the lossy hyphen sanitizer is replaced by an injective dash-escape encoding (- doubles to --, other unsafe bytes become -hh- hex), so Daily Brief persists as Daily-20-Brief, distinct from Daily-Brief → Daily--Brief (and _helper stays distinct from helper). The audit projector accepts the encoding. Boundary coverage in src/skills/runtime-skill-selection.test.ts.
  • Admission-owned schema setup — the canonical schema admission owns audit_skill_selection_events (src/state/openclaw-state-schema.sql); additive DDL now runs at most once per connection and only for pre-admission databases, instead of on every insert and prune tick.
  • Bounded write overhead — per-connection row-count cache mirrors the canonical ledger pattern: one COUNT(*) per connection lifetime, advanced by inserts and maintenance deletes, invalidated on rollback.
  • Restart guidance — docs/gateway/audit.md now states the recorder re-reads logging.audit.enabled on every event, so disabling stops new rows immediately.
  • Protocol type ownership — AuditActivitySkillSelectionV1 is derived from the canonical schema properties via SchemaContract (same pattern as adjacent variants), restoring wire-required attribution to typed consumers.

Production-path proof

Throwaway script (not committed) driving production code on a temp state DB — marker encoder → recorder projector → production SQLite writer → audit.activity.list Gateway handler:

encoded identities: Daily-20-Brief vs Daily--Brief
projected inputs: 1 kind: skill_selection
writer stored: skill_selection Daily-20-Brief
gateway response: {"events":[{"schemaVersion":1,"sequence":1,"eventId":"<uuid>","sourceSequence":1,"occurredAt":<ts>,"redaction":"metadata_only","kind":"skill_selection","agentId":"main","sessionKey":"agent:main:<session>","sessionId":"session-<id>","runId":"run-proof-1","action":"skill.selection.observed","status":"observed","eventType":"skill_selection","actor":{"type":"agent","id":"main"},"selectedSkill":"Daily-20-Brief"}]}
worker rows: 1 first toolName: Daily-20-Brief
PROOF OK: gateway output matches the observed skill invocation

Tool-invocation → emission coverage lives in src/agents/agent-tools.skill-selection-audit.e2e.test.ts; recorder → DB → filtered readback in src/audit/audit-events.skill-selection-hidden.test.ts; handler shaping in src/gateway/server-methods/audit.test.ts.

Round 2 (rev.199 follow-up)

Three further findings from review rev.199 are fixed on this head:

  • Token-built identities — the encoder appends complete encoding tokens only while they fit the 128-char bound (reserving the x- flag prefix up front), so truncation can never cut inside an escape and valid suffixes survive (skill-a vs skill-b regression covered).
  • Single-owner expiry accounting — the deleter returns the removed count without touching the warm cache; insert-prune and maintenance ticks each adjust exactly once, with a warm-cache expiry-to-overflow regression test (exact cap trim to 99,976 rows).
  • Tool-boundary assertion — the wrapper e2e expects the encoded demo--skill identity while the run-usage receipt keeps the original demo-skill name.

Round 3 (ClawSweeper re-review findings + live-Gateway proof)

Head 1e502cd5e72 (synced with upstream/main, 0 behind). All review findings addressed:

  • [P1] Historical catalog hashes preserved — the companion table leaked into predecessor schema generation, replacing historical hashes. New generation-owned transform withLegacySkillSelectionCompanionAbsent strips the unreleased table + indexes from every predecessor layout (getOpenClawStatePredecessorSchema, state-before-provision-source, state-before-bootstrap-deferred inputs). Historical inputs are byte-identical to upstream; the historical hash assertions are restored untouched; generated SQLite catalogs regenerated (228/235 inputs byte-identical, only current-layout inputs changed, as intended).
  • [P2] Input truncation marked before digest suffix — names cut at the 64-char input budget are now marked truncated up front, so aaa…(64)+alpha vs aaa…(64)+beta keep distinct audit identities (regression test added).
  • [P2] Canonical decoder reused — the writer owned a copied run/tool/message decoder; it now imports parseAgentRunRow/rowToAuditEvent from audit-event-row.ts, with companion decoding confined to rowToStoredAuditEvent + the distinct companion row shape.
  • [P2] Bootstrap privacy extraction removed — the unrelated workspace-bootstrap-privacy.ts extraction is reverted; src/agents/workspace.ts is byte-identical to upstream again.
  • [P3] Stale sequence cache invalidated — companion allocation consumes shared sequences outside the retention fast path (including duplicate-source attempts); the writer now drops the cached high-water mark on the skill path (regression test: ledger row after a skill write reports its true stored sequence).
  • Stale generated gateway validators — the PR updated the protocol schemas but not the compiled predicates, so kind=skill_selection / status=observed failed gateway validation (2 gateway tests red). Regenerated via scripts/generate-gateway-validators.mts; 21/21 gateway tests green.
  • Test hygiene — the PRIVATE_PROMPT_CONTENT absence assertion now supplies the sentinel as input (prompt/toolInput/skillFileContents); the unrelated expired-identity rendering case is removed from this PR.
  • Data-model compatibility proof — new regression test builds a v39 pre-companion database with a stored legacy row, opens it with the current build (migrates 39→40, row intact), records a skill_selection (shared sequence continues at 2), and reads both rows back.

Live-Gateway behavior proof (new, real Gateway + shipped CLI)

Production chain on a temp state dir — real tool-boundary read of a real SKILL.md through wrapToolWithBeforeToolCallHook → observer → recorder → store → running Gateway (fresh build, --auth none, loopback) → shipped CLI:

$ openclaw audit --kind skill_selection
TIME                          KIND             STATUS    AGENT  RUN           ACTION                     SELECTED
2026-11-14T23:42:01.167Z      skill_selection  -         -       observed  main   proof-run-1   skill.selection.observed  skill:proof--demo

$ openclaw audit --kind skill_selection --json
{"events":[{"schemaVersion":1,"sequence":2,"eventId":"2c71cbfc-…","sourceSequence":1,
"redaction":"metadata_only","kind":"skill_selection","agentId":"main",
"sessionKey":"agent:main:proof","sessionId":"proof-session-1","runId":"proof-run-1",
"action":"skill.selection.observed","status":"observed","eventType":"skill_selection",
"actor":{"type":"agent","id":"main"},"selectedSkill":"proof--demo"}]}

Stored rows: ledger agent.run.started (seq 1) → companion skill.selection.observed (shared seq 2, main/agent:main:proof/proof-session-1/proof-run-1/proof--demo) → ledger agent.run.finished (seq 3). Metadata-only, no prompt/tool content persisted. (An LLM-driven variant was attempted with local ollama qwen2.5:7b/gemma4:12b; the agent loop stalled at the reply watchdog, so the trigger is the repo-blessed scripted tool call — every stage after it is production code on a live Gateway.)

Verification on this head

  • test/scripts/sqlite-schema-catalog-equivalence.test.ts 203/203
  • runtime-skill-selection + audit-events.skill-selection* incl. new upgrade/sequence tests green
  • audit-events (37), commands/audit (36), gateway/server-methods/audit (21/21) green
  • tsgo:core clean, oxfmt --check clean on touched files, line-cap ratchet clean vs upstream merge-base

Round 4 (re-review findings, head 883b4d8d003)

Both P2 findings fixed, plus the requested proof/test adjustments:

  • [P2] Buffered run starts retained until acceptance (src/audit/agent-event-audit.ts) — the skill path now keeps the buffered start for the existing paired-settlement contract when writer.record(start) returns false, while skill observations still record independently. Regression test: with a rejecting writer, the terminal settles as one paired recordRun(start, finish) instead of a lone finish.
  • [P2] Companion counts bound to transaction outcomes (audit-event-store.skill-selection-storage.ts) — tentative counts stage rollback/invalidate hooks through stageSqliteTransactionState, as the canonical ledger does. Negative control verified: without the fix a rolled-back overflow batch leaves the cap violated at 100,001 rows; with it the next insert trims honestly to 98,976. Covered by drops tentative companion counts when their batch rolls back.
  • Upgrade proof targets v2026.11.3 — confirmed the 2026.11.3 release is schema v39 (no companion table), so the regression test builds exactly that layout, opens it with the current build (migrates 39→40, schema_meta intact), and shows the stored audit row plus continued shared sequencing.
  • Flagged low-value tests removed — unrelated date/empty-limit CLI variants and the full marker-construction equality case are out; encoding, truncation, and production-boundary coverage retained.
  • Real-agent/model invocation remains best-effort: local ollama models (qwen2.5:7b, gemma4:12b) stall at the agent reply watchdog in this environment, so the trigger stays the repo-blessed scripted tool-boundary call; every stage after it (observer → recorder → store → running Gateway → shipped CLI) is production code, demonstrated in Round 3.

Verification on this head: skill-selection storage 7/7 (incl. rollback + v2026.11.3 upgrade), audit-events + commands/audit 45/45, gateway 21/21, runtime-skill-selection green, tsgo:core clean, oxfmt --check clean.

Round 5 (re-review: settlement intent + true v2026.11.3 fixture, head 4fd73e177bc)

  • Buffered run-start settlement intent documented (src/audit/agent-event-audit.ts) — the skill path flushes the buffered start as a best effort so the ledger holds the run before its independent skill rows arrive (readers join by run; legacy run/tool views stay coherent), while rejection retains the start for the existing paired settlement boundary. This keeps the PR improve(audit): persist agent run records together at settlement #178220 paired-start/finish contract: the terminal still settles as one paired run.
  • Upgrade fixture is the true v2026.11.3 layout — verified the 2026.11.3 release is schema v39 without the companion table (release commit 50330aa9cf5, OPENCLAW_STATE_SCHEMA_VERSION = 39, no audit_skill_selection_events). The regression test now builds the fixture from the current schema minus only the unreleased companion table at version 40 (matching the release lineage), opens it with the current build, and asserts: user_version/schema_meta intact, a stored workspace setting row byte-identical, the stored audit row readable, lazy companion creation on first skill write, and continued shared sequencing with correct readback.
  • Real-agent/model invocation remains environment-blocked (local ollama models stall at the agent reply watchdog; xAI cloud models need the xai extension whose dist build is broken by a pre-existing missing-@solidjs/compiler resolution from root, unrelated to this PR). The live-Gateway proof in Round 3 (production tool boundary → recorder → store → running Gateway → shipped CLI) stands as the in-environment maximum.

Verification on this head: skill-selection storage 7/7, audit-events + commands/audit 45/45, gateway 21/21, runtime-skill-selection green, tsgo:core clean, oxfmt --check clean.

Round 6 (head a71b0be6d94)

  • True v2026.11.3 upgrade fixture — the reviewer correctly noted the published v2026.11.3 is schema v22 (verified: release tag → commit 847611dcaa3, OPENCLAW_STATE_SCHEMA_VERSION = 22, no companion table), not v39. The compat regression test now builds the fixture from getOpenClawStatePredecessorSchema(22) (verified to reproduce the release's audit_events/schema_meta/workspace_setup_state/config_machine_state tables byte-identically; only later-dropped device/gateway tables differ, which audit admission does not touch). The fixture migrates 22→40 (backup custody via the standard test-support helper, as a real install would back up first) with schema_meta, a stored workspace setting, and the legacy audit row byte-identical, then records a skill_selection via lazy companion DDL with continued shared sequencing and correct readback.
  • Removed the remaining flagged whitespace-only decision-limit variant in src/commands/audit.test.ts (restored the upstream single-case form).

Verification on this head: skill-selection 8/8, audit-events + commands/audit green, gateway 21/21, runtime-skill-selection green, tsgo:core clean, oxfmt --check clean.

Round 7 — product upgrade run from published v2026.11.3 (head a71b0be6d94, no new commits; proof only)

  • Genuine release write: ran the published v2026.11.3 source (release tag → 847611dcaa3, schema v22) to create a state dir and record a legacy agent run through its production audit writer (sequences 1–2, run release-run-1, user_version 22).
  • New-build upgrade: fresh dist rebuilt from PR source; the new Gateway booted the release DB with no schema refusal and migrated 22→40, release rows intact.
  • New skill write + shipped CLI readback through the running new Gateway: production tool-boundary read of a real SKILL.md → observer → recorder → store (skill.selection.observed, shared sequence 4, upgraded-run-1), then openclaw audit --run release-run-1 --json returns the release rows and openclaw audit --kind skill_selection --json returns the new skill row with full attribution. Full redacted transcript kept with the run notes.
  • Real-agent/model trigger remains environment-blocked (local models stall at the reply watchdog; xAI needs the xai extension whose dist build fails on the pre-existing missing-@solidjs/compiler root resolution). The trigger is the repo-blessed scripted tool-boundary call; every stage after it is production code on live Gateways, now demonstrated across a genuine published-release upgrade boundary.

Round 8 — P2 rollback fix + missing proof piece (head d541860e07a)

  • [P2] Clear schema readiness when lazy creation rolls back (src/audit/audit-event-store.skill-selection-storage.ts) — ensureSkillSelectionAuditSchemaOnce now binds the skillSelectionSchemaEstablished flag to the owning SQLite transaction via stageSqliteTransactionState (rollback/invalidate drop both the readiness flag and the warm row-count). A rolled-back lazy DDL no longer leaves a stale flag that skips recreation; the next write on the same handle recreates audit_skill_selection_events instead of failing with no such table. Postgres path binds the same way (no-op outside a transaction).
  • Regression test — recreates companion schema after lazy creation rolls back: drops the companion table on a live handle, clears caches, runs a doomed runOpenClawStateWriteTransaction (lazy DDL + throw), asserts the table is gone, then asserts a follow-up recordAuditEventInDatabase(skill_selection) succeeds with the table present. Negative control: without the bind the follow-up throws no such table.
  • Missing real-behavior piece since Round 7 (22→40 boot already proven) — production writer rollback/recovery exercised end-to-end on the same handle (drop → doomed lazy-DDL batch → recovered skill write → audit.activity.list readback path covered by audit-events.skill-selection + gateway/server-methods/audit suites). Real-agent/model trigger remains environment-blocked as documented in Rounds 3–7 (local ollama stalls at reply watchdog; xAI needs the broken xai dist); every stage after the repo-blessed scripted tool-boundary call is production code.
  • Owner decision still open — default collection (logging.audit.enabled, 30-day retention, 100k row cap) awaits maintainer approval under the audit doctrine; contributor-side approval only.

Verification on this head:

  • src/audit/audit-events.skill-selection.test.ts 8/8 (incl. new rollback-schema + existing rollback-count + v22 upgrade)
  • src/audit/audit-events.skill-selection-hidden.test.ts + src/skills/runtime-skill-selection.test.ts 17/17
  • src/gateway/server-methods/audit.test.ts 21/21
  • pnpm tsgo:core clean, oxfmt --check clean on touched files

Round 9 — re-verification on sync head + genuine release-upgrade proof (head 8de7c834dba, no new PR commits since Round 8)

Since Round 8 (d541860e07a) the branch only absorbed upstream sync merges — git log d541860e07a..HEAD shows sync commits plus upstream fixes, zero PR-owned changes. Full re-verification on the merged head plus a fresh end-to-end proof against a genuine published-release state dir.

  • Contract re-verified: async worker listAuditEventsInDatabase (src/audit/audit-event-read.kernel.ts, delegated from audit-event-writer.worker.ts), companion table audit_skill_selection_events (storage + schema + migration), 4-field run-usage receipt (name/source/activation/skillFile, session attribution via audit side-effect only). (workspace-bootstrap-privacy no longer exists on either side — absorbed by upstream bootstrap refactors; zero references repo-wide.)
  • Suites green: audit-events.skill-selection + skill-selection-hidden + runtime-skill-selection + agent-tools.skill-selection-audit.e2e (via include-override, excluded from default projects by the *.e2e glob) — 26/26; audit-events + commands/audit + gateway/server-methods/audit + sqlite-schema-catalog-equivalence — 292/292; tsgo:core clean; oxfmt --check clean on touched files.

Live-Gateway proof (new, genuine v2026.11.3 → PR-head upgrade)

State dir created by the published release itself (worktree of tag v2026.11.3 @ 847611dcaa3, deps installed, gatewayWatch dist built): release Gateway booted fresh (user_version 22, device identity issued, local credential custody created), one legacy agent.run.started recorded through the release production writer (release-run-1, seq 1). Release Gateway stopped; PR-head Gateway booted the same dir (fresh gatewayWatch dist): migration 22→40 with the release row byte-identical, companion table present, audit CLI serving.

Production tool-boundary read of a real SKILL.md through wrapToolWithBeforeToolCallHook → observer → recordRunSkillUsage (4-field receipt) → bus skill_selection event → the exact production recorder the Gateway subscribes (createAgentEventAuditRecorder + real async writer) → store with lazy companion path → shipped CLI against the running Gateway (OPENCLAW_GATEWAY_URL=ws://127.0.0.1:18796, --auth none, loopback):

$ openclaw audit --kind skill_selection
TIME                          KIND             STATUS    AGENT  RUN           ACTION                     SELECTED
2026-11-15T22:52:33.227Z      skill_selection  -         -      observed  main   proof-run-r9  skill.selection.observed  skill:r9--demo

$ openclaw audit --kind skill_selection --json
{"events":[{..., "sequence":3, "kind":"skill_selection", "agentId":"main",
"sessionKey":"agent:main:proof-r9", "sessionId":"proof-session-r9", "runId":"proof-run-r9",
"action":"skill.selection.observed", "status":"observed", "redaction":"metadata_only",
"selectedSkill":"r9--demo"}]}

Stored rows: ledger agent.run.started (seq 1, release-run-1, preserved) → ledger agent.run.started (seq 2, proof-run-r9) → companion skill.selection.observed (shared seq 3, full attribution) → ledger agent.run.finished (seq 4). Metadata-only, no prompt/tool content persisted. Real-agent/model trigger remains environment-blocked as documented in Rounds 3–8; every stage after the repo-blessed scripted tool-boundary call is production code on a live Gateway, this time across a genuine published-release upgrade boundary with release-created credential custody (the synthetic-fixture shortcut fails at the client-credential migration without it — verified).

Note: openclaw audit without an explicit OPENCLAW_GATEWAY_URL resolved to an unrelated Gateway on this host's default port; the proof pins the URL explicitly.

Round 10 — P1 validator regen + real-model trigger (head 82915d6, no upstream drift)

  • [P1] Regenerated Gateway validators — pnpm gateway:validators:gen on this head; only packages/gateway-protocol/src/compiled/protocol.generated/predicates.js changes (+4246/-4235 from renumbered checks). check_1259 now accepts skill_selection (check_1262), check_1264 now accepts observed (check_1267). Verified through the real request validator (not mock):
    VALIDATOR {"kind":"skill_selection"} => true
    VALIDATOR {"status":"observed"} => true
    VALIDATOR {"kind":"skill_selection","status":"observed"} => true
    
    pnpm gateway:validators:check clean (exit 0). Negative control still rejects: {"kind":"bogus"} => false with allowedValue diagnostics.
  • Real-model trigger (new vs Round 9 scripted) — local ollama qwen2.5:7b asked for the single skill file to read; model replied with exactly the relative path, which then drove the production wrapper (no hardcoded path after the prompt):
    ---MODEL PROMPT---
    You are a tool-using agent... Reply with ONLY the relative file path to read, exactly: .agents/skills/r10-demo/SKILL.md
    ---MODEL RAW OUTPUT---
    .agents/skills/r10-demo/SKILL.md
    MODEL_CHOSEN_PATH=.agents/skills/r10-demo/SKILL.md
    
    Production wrapToolWithBeforeToolCallHook with that model-chosen path emitted one bus event:
    AUDIT_BUS_EVENTS=1
    {"runId":"proof-run-r10","stream":"skill_selection","agentId":"main",
     "sessionKey":"agent:main:proof-r10","sessionId":"proof-session-r10",
     "data":{"kind":"skill_selection","selectedSkill":"r10--demo",
     "selectionSource":"observed_runtime","selectionConfidence":"observed",
     "selectionRule":"tool_invocation","activation":"read","skillSource":"workspace",
     "redaction":"metadata_only"}}
    
    Redacted: temp dirs, no IPs/keys/phones/endpoints in transcript.
  • Contract preserved: async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, 4-field run-usage. Storage readback covered by green suites (skill-selection 11/11 incl. v22 upgrade, rollback-schema, rollback-count); live-Gateway + shipped CLI serving proven in Round 9 across genuine v2026.11.3 → PR-head upgrade (release-created credential custody). This Round adds the missing real-model trigger + real-validator gate on top of that chain.

Verification on this head:

  • src/audit/audit-events.skill-selection.test.ts + hidden + runtime + gateway/server-methods/audit + schema/audit: 4 Vitest shards passed (76.22s)
  • pnpm tsgo:core clean, oxfmt --check clean on touched files, pnpm gateway:validators:check clean

@clawsweeper

clawsweeper Bot commented Sep 7, 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 app: web-ui App: web-ui gateway Gateway runtime commands Command implementations agents Agent runtime and tooling size: XL labels Sep 7, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: stale review; fresh review needed.

Summary
The latest durable ClawSweeper review was for head 2548dbb8d00480ec6f3e4c6c5e4cb9cc7f792a0e, but the PR head is now 96fe807c018cb4406da0a3d701c24c40b1ee7556. Its old verdict and PR readiness labels are no longer current.

Next step
Comment @clawsweeper re-review when the current head is ready; pushes after the first review are not reviewed automatically.

Review history (312 earlier review cycles; latest 8 shown)
  • reviewed 2026-11-18T20:35:39.752Z sha d4ccc28 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-19T06:39:22.454Z sha 3a185f9 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-19T12:34:59.449Z sha bf8b83b :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-19T18:35:29.702Z sha 9a5eecb :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-20T02:37:39.242Z sha 5a23c5a :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-20T04:39:06.075Z sha 028f305 :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-20T16:36:16.605Z sha f1c1ccf :: needs real behavior proof before merge. :: none
  • reviewed 2026-11-21T12:33:28.598Z sha 2548dbb :: needs real behavior proof before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot closed this Sep 7, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 7, 2026
@openclaw-barnacle openclaw-barnacle Bot closed this Sep 7, 2026
@openclaw-barnacle openclaw-barnacle Bot reopened this Sep 7, 2026
@wiecon-dev

Copy link
Copy Markdown
Author

Updated this PR to address the ClawSweeper findings: skill-selection audit records now come from the observed runtime skill-usage boundary instead of prompt inference, completeEmbeddedAttemptResult() is restored to the upstream production contract, skill_selection persists outside run-start dedupe, legacy audit.list remains run/tool-only, and audit.activity.list/CLI expose observed skill usage. Evidence is in the updated PR body. @clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 7, 2026
@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Sep 7, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. labels Sep 7, 2026
@clawsweeper

clawsweeper Bot commented Nov 20, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced with upstream/main (45 commits) and regenerated gateway validators. Focused skill-selection tests (25 passed) + tsgo:core clean. Skill-selection contract preserved: async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, workspace-bootstrap-privacy re-export, 4-field run-usage contract.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced with upstream/main (merge 0fd5371, was 39 behind). Focused skill-selection tests 25/25 pass, tsgo:core clean. Contract preserved: async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, workspace-bootstrap-privacy re-export, 4-field run-usage.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper Synced with upstream/main (merge 0fd5371 → 3ba3b40, was 23 behind, now 0 behind). No conflicts; skill-selection files intact (async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, workspace-bootstrap-privacy re-export, 4-field run-usage contract). Focused tests: 25/25 pass (runtime-skill-selection, audit-events.skill-selection, agent-run-usage). tsgo:core clean. Please re-review. 🙏

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced upstream/main (56 commits, merge 3d0ad70) and fixed skill-selection migration test for schema v41. Focused tests (223) + tsgo:core green. Skill-selection contract preserved: async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, workspace-bootstrap-privacy re-export, 4-field run-usage.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced upstream/main into memorytunning-pr-v2 (new head c485703, 0 behind). Skill-selection files verified intact, focused tests 11/11 green, tsgo:core clean.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced with upstream/main (merge b19509c, was 20 behind). Focused skill-selection tests 11/11 pass, tsgo:core clean. Skill-selection contract preserved (async worker listAuditEventsInDatabase, companion table, workspace-bootstrap-privacy re-export, 4-field run-usage).

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced with upstream/main (merge 379eec6, was 39 behind). Focused skill-selection tests 11/11 green, tsgo:core clean. Skill-selection contract preserved (async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, workspace-bootstrap-privacy re-export, 4-field run-usage contract).

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced upstream/main into memorytunning-pr-v2 (379eec6 → 2db4f19, 0 behind). Focused skill-selection tests 25/25 pass, tsgo:core clean. Skill-selection contract preserved: async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, 4-field run-usage contract.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper re-review please — synced upstream/main (19 commits) into memorytunning-pr-v2. Merge clean, skill-selection focused tests 11/11 green, tsgo:core clean. Skill contract preserved: async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, workspace-bootstrap-privacy re-export, 4-field run-usage contract.

@clawsweeper

clawsweeper Bot commented Nov 21, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced upstream/main into memorytunning-pr-v2 (new head 2b86e22, was 2548dbb, 23 commits behind resolved to 0). Focused skill-selection tests (11 passed) + tsgo:core clean, skill-selection scope preserved.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced with upstream/main (24 commits, merge 51ca3cd). Skill-selection files intact (43 files diff), focused tests 22/22 pass, tsgo:core clean.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — synced with upstream/main (head 96fe807c018, was 51ca3cdad8c, 0 behind). Focused skill-selection tests 8/8 pass, tsc core clean. Skill-selection contract preserved: async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, run-usage 4-field contract.

@wiecon-dev

Copy link
Copy Markdown
Author

@clawsweeper please re-review — head 96fe807 unchanged since Nov 21 (0 behind upstream/main), no fresh verdict on this head yet (last review 2026-11-21T12:33 on 2548dbb is stale for current head). Skill-selection contract preserved (async worker listAuditEventsInDatabase, companion table audit_skill_selection_events, 4-field run-usage). Focused tests green, tsgo:core clean.

This branch has not been deployed

No deployments
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 commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. scripts Repository scripts size: XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants