Repository navigation
fix(gateway): trim audit.list exact-match filter ids - #110847
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 10:36 AM ET / 14:36 UTC. ClawSweeper reviewWhat this changesThe PR trims whitespace from Merge readinessThis PR is still necessary: current Priority: P2 Review scores
Verification
How this fits togetherGateway audit RPC methods validate an operator request, build exact-match filters, and query OpenClaw's shared SQLite audit ledger. The returned page is projected into legacy audit events or versioned activity events and sent back to the authorized gateway caller. flowchart LR
A[Operator audit request] --> B[Gateway validation and authorization]
B --> C[Audit list handler]
C --> D[Normalize optional identifier filters]
D --> E[Exact SQLite audit query]
E --> F[Audit event page]
F --> G[Gateway response]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +7, Tests +107. Total +114 across 3 files. View PR surface stats
Review metricsNone. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge the handler-boundary normalization after the remaining required hosted checks pass, retaining the audit store's exact-match contract for non-gateway callers. Do we have a high-confidence way to reproduce the issue? Yes, from source: current main passes padded identifiers to exact SQLite equality predicates in Is this the best way to solve the issue? Yes. Normalizing at the gateway request boundary is the narrowest maintainable fix: it matches existing cursor behavior, reuses the canonical helper, covers both RPC methods, and avoids weakening direct store exact-match semantics or changing the protocol. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 133a8a627429. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
8539ea2 to
0e98519
Compare
|
@clawsweeper re-review Updated head + body with real SQLite audit-store proof (not mocked
|
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
0e98519 to
5000406
Compare
|
Maintainer end-to-end revalidation on the exact refreshed original contributor head
|
5000406 to
8dd2e18
Compare
|
Merged via squash.
|
…up-ownership-20260801 * origin/main: fix(gateway): trim audit.list exact-match filter ids (openclaw#110847) fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386) fix(ci): keep PTY tests observable and wait for completed turns (openclaw#117405) fix(plugins): resolve marketplace aliases without recursive cycles (openclaw#117440) fix: break command recovery import cycle (openclaw#116947) fix: clear offscreen command recovery fix: fence command recovery ownership fix: scope failed command recovery fix(plugins): fail closed on ambiguous uninstall targets (openclaw#117406)
* origin/main: fix(gateway): trim audit.list exact-match filter ids (openclaw#110847) fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386)
…up-ownership-20260801 * origin/main: fix(gateway): trim audit.list exact-match filter ids (openclaw#110847) fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386) fix(ci): keep PTY tests observable and wait for completed turns (openclaw#117405) fix(plugins): resolve marketplace aliases without recursive cycles (openclaw#117440) fix: break command recovery import cycle (openclaw#116947) fix: clear offscreen command recovery fix: fence command recovery ownership fix: scope failed command recovery fix(plugins): fail closed on ambiguous uninstall targets (openclaw#117406)
* origin/main: fix(gateway): trim audit.list exact-match filter ids (openclaw#110847) fix: harden plugin import-boundary guards and remove dead scanner (openclaw#117386)
What Problem This Solves
audit.list/audit.activity.listforwardedagentId,sessionKey, andrunIdinto exact store filters without trimming. A pasted filter like" main "produced a successful empty page even when matching events existed.Why This Change Was Made
Normalize those exact-match filters with
normalizeOptionalStringbeforelistAuditEvents, matching the same file's existing cursor.trim()behaviorand other gateway list filters.
User Impact
Before: Padded filter ids returned empty success results.
After: Leading/trailing whitespace is stripped so padded filters hit the
same rows as the canonical ids.
Evidence
src/gateway/server-methods/audit.ts,src/gateway/server-methods/audit.test.ts,src/gateway/server-methods/audit.trim.store.test.tsaudit.list/audit.activity.listhandlers →normalized filters →
listAuditEventsReal behavior proof
Behavior or issue addressed
agentId: " main "→ empty).audit.listwith the same padded filters returns the plantedagent.run.finishedevent after handler-side trim.Canonical reachability path
Real SQLite audit store (
recordAuditEvent) → Gateway handlerauditHandlers["audit.list"]→normalizeOptionalString→listAuditEvents(default
OPENCLAW_STATE_DIR) → respond with matching eventsShared helper / provider constraint check
Reuses
@openclaw/normalization-core/string-coercenormalizeOptionalString;no new config/env.
Real environment tested
Local trusted checkout; temp
OPENCLAW_STATE_DIR; real OpenClaw state SQLiteaudit table (not a mocked
listAuditEvents). Node viascripts/run-vitest.mjs.Exact steps or command run after this patch
Evidence after fix
Negative control:
listAuditEvents({ filters: { agentId: " main ", runId: " run-trim-1 " } })returns
[]. After-fix handler call with the same padded params returns theplanted
agentId: "main"/runId: "run-trim-1"event.Observed result after fix
Padded audit filter ids resolve through the production gateway handler against
a real stored audit event.
What was not tested
Live multi-operator Gateway WebSocket session against a long-lived production
state DB. Proof uses the production handler + real SQLite store under an
isolated state dir.
Fix classification
bugfix — exact-match filter paste/padding miss
AI Assistance
AI-assisted implementation and proof.
Maintainer validation on current main
The sole original contributor commit was refreshed onto clean upstream main after the canonical PTY progress and legacy gateway-startup CI fixes landed. Refreshed exact head
8dd2e18dc03c23bf0608265cca9371e4e3f69e73preserves @nocodet888-arch original authorship, authored timestamp, commit subject, and stable patch IDcb4cc62115731047916025980833023929e386c5.Maintainer proof runs the actual authenticated production
handleGatewayRequestdispatcher against a real isolated Kysely/SQLite audit ledger on both unpatched main and the contributor head:audit.list: padded exact-match agent/session/run IDs return 0 before -> 1 after.audit.activity.list: the same padded IDs return 0 before -> 1 after.operator.readremains FORBIDDEN; node-role calls remain denied.Existing detailed proof: #110847 (comment)
Full hosted CI on this exact contributor head is required before landing.