Skip to content

fix(cli): reject blank audit bounds - #137335

Merged
Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
Alix-007:alix/fix-audit-empty-filters-20260903
Sep 11, 2026
Merged

Patrick-Erichsen merged 1 commit into
openclaw:mainfrom
Alix-007:alix/fix-audit-empty-filters-20260903

Conversation

@Alix-007

@Alix-007 Alix-007 commented Sep 3, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes audit CLI bounds that silently accepted explicit blank values. openclaw audit --after "" removed the time boundary and queried a broader result set; an empty --limit silently selected the default page size. The same issue affected --before and the --explain decision limit.

Why This Change Was Made

The audit parsers now distinguish omission (undefined) from present-but-invalid input. Blank timestamps reach the existing timestamp error, and blank limits reach the existing strict positive-integer bounds. This keeps validation at the canonical audit command owner with no new parser or policy branch.

User Impact

Operators and scripts now get an explicit error when a shell-expanded audit bound is empty, instead of unknowingly querying a wider time range or larger page. Omitted values and valid timestamps/limits keep their existing behavior.

Evidence

Exact-head proof receipt

  • Product head SHA: 0cffbf8ea24063f4665493d0a2fee10cc8c8ae6f
  • Current-main RED baseline: a4ad6c76a4d19ec47394f0a1905c749252d308c1
  • Production entry: openclaw audit --after "" --json
  • Canonical owner exercised: parseAuditTimestamp, parseAuditLimit, and parseAuditDecisionLimit in src/commands/audit.ts
  • Decision surface: list --after/--before/--limit and explain-mode --limit, all before audit.activity.list or audit.run.inspect.
  • Recorder/readback boundary: real source CLI structured output shows whether the command stops locally or reaches Gateway method authorization.
  • Acceptance RED: the same empty --after command on current main reached gateway audit.activity.list requires credentials, proving the empty timestamp was silently omitted.
  • Acceptance GREEN: exact head returns --after must be an ISO timestamp or Unix milliseconds before any Gateway call. Tests cover empty/whitespace timestamps plus list and explain limits.
  • Legal control: exact head with --after 1234 --limit 1 reaches audit.activity.list Gateway authorization, proving valid bounds still proceed.
  • Cleanup: runs used isolated temporary state/config paths. Empty-input runs created zero state files; valid-control transient files remained inside the isolated directory and all temporary directories were removed.

Inspectable RED -> GREEN terminal trace

<EMPTY> denotes the actual empty argv token. Node v24.15.0; verified 2026-09-03T13:52:34Z (RED) and 2026-09-03T13:47:26Z (GREEN).

$ git rev-parse HEAD
a4ad6c76a4d19ec47394f0a1905c749252d308c1
$ node --import ./scripts/tsx.mjs src/entry.ts audit --after <EMPTY> --json
{
  "ok": false,
  "error": {"type":"cli_error","message":"gateway audit.activity.list requires credentials before opening a websocket"}
}
exit=1

The RED reaches Gateway authorization. At the product head:

$ git rev-parse HEAD
0cffbf8ea24063f4665493d0a2fee10cc8c8ae6f
$ node --import ./scripts/tsx.mjs src/entry.ts audit --after <EMPTY> --json
{
  "ok": false,
  "error": {"type":"cli_error","message":"--after must be an ISO timestamp or Unix milliseconds."}
}
exit=1
state_files=0

Valid-value control:

$ node --import ./scripts/tsx.mjs src/entry.ts audit --after 1234 --limit 1 --json
{
  "ok": false,
  "error": {"type":"cli_error","message":"gateway audit.activity.list requires credentials before opening a websocket"}
}
exit=1

Verification

  • Exact-head focused test: node scripts/run-vitest.mjs run src/commands/audit.test.ts -t 'rejects invalid|explicit empty|keeps decision and run discovery queries bounded|converts ISO' — 21 passed, 19 skipped.
  • Full affected suite before the final mechanical main refresh: src/commands/audit.test.ts — 40 tests passed; the final rebase did not touch either changed file.
  • oxfmt --check on both changed files — passed at exact head.
  • git diff --check upstream/main...HEAD — passed.
  • Fresh autoreview of the unchanged patch — clean, patch is correct with confidence 0.99.

Scope and risk

  • Production LOC: +3/-3 (net 0).
  • Test LOC: +14/-0 (net +14).
  • Existing-solutions preflight: reuses existing audit timestamp validation and parseStrictPositiveInteger; no new library, plugin, workflow, or parsing system.
  • Sibling coverage: both list timestamps, the normal list limit, and the explain-mode decision limit; omitted/default and valid controls remain covered.
  • Not tested: an authenticated live audit query, because the changed path stops before RPC. The valid control reaches the exact Gateway authorization boundary.
  • Config/default, protocol/schema, authorization, storage, migration, and upgrade impact: none. Explicit blanks that previously acted as omission now fail fast.

@clawsweeper

clawsweeper Bot commented Sep 3, 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 commands Command implementations size: XS labels Sep 3, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 3, 2026
@clawsweeper

clawsweeper Bot commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 10, 2026, 8:22 PM ET / September 11, 2026, 00:22 UTC (Revision 4).

ClawSweeper review

What this changes

Reject explicitly blank audit timestamps and limits before querying the Gateway, while preserving omitted defaults and valid values.

Merge readiness

⛔ Blocked before merge - 1 item remains

The fix remains necessary on current main. No blocking defects were found, the supplied CLI proof covers the changed boundary, and a write-access reviewer has explicitly accepted the compatibility change.

Priority: P2
Reviewed head: 0cffbf8ea24063f4665493d0a2fee10cc8c8ae6f

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, maintainable correction with convincing CLI proof, useful regression coverage, and no blocking findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The supplied exact-head source-CLI trace demonstrates local rejection of an empty timestamp before the Gateway credential boundary, with baseline failure and valid-value controls; focused tests supplement list/explain-limit coverage.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The supplied exact-head source-CLI trace demonstrates local rejection of an empty timestamp before the Gateway credential boundary, with baseline failure and valid-value controls; focused tests supplement list/explain-limit coverage.
Evidence reviewed 9 items Introduced change and actual merge result: The pinned introduction changes only three omission guards and adds blank-input regression cases. The inspected test merge records the pinned main parent followed by the exact PR head; its production delta against main is the same three guards.
Current-main and released behavior: Both fetched main and v2026.9.3 retain the falsy guards: blank timestamps become absent bounds, and empty limits select defaults. The proposed correction is therefore still missing from both inspected revisions.
Caller, owner, and parsing contracts: The audit registration forwards argument strings unchanged. The command validates both activity timestamps and the selected list/explain limit before calling its Gateway query helper. Existing parseStrictPositiveInteger rejects blank strings. This path uses OpenClaw-owned parsing and RPC contracts; no Codex runtime or protocol dependency signal applies.
Findings None None.
Security None None.

How this fits together

The audit CLI turns operator filters into bounded requests for activity records or execution explanations. Its parsers validate arguments before the Gateway request and subsequent terminal or JSON output.

flowchart TD
  A[Operator audit arguments] --> B[CLI argument validation]
  B --> C{Bounds valid or omitted?}
  C -->|Blank or invalid| D[Local validation error]
  C -->|Valid or omitted| E[Bounded Gateway request]
  E --> F[Activity or execution records]
  F --> G[Terminal or JSON output]
Loading

Before merge

  • Resolve merge risk (P1) - Existing scripts that pass empty shell-expanded bounds will now fail until they omit those flags; the approving write-access reviewer explicitly accepted this compatibility change.
Agent review details

Security

None.

PR surface

Source 0, Tests +14. Total +14 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 3 0
Tests 1 14 0 +14
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 17 3 +14

Review metrics

Metric Value Why it matters
Production versus test growth Production net 0; tests net +14 The repair reuses existing validators and adds boundary regression coverage without expanding production code.
CLI compatibility surface 3 existing flags tightened across 4 contexts; 0 flags added Both timestamp flags and list/explain limits distinguish explicit blanks from omission.

Merge-risk options

Maintainer options:

  1. Proceed with the accepted validation change (recommended)
    Retain explicit blank rejection and the recorded compatibility acceptance; scripts requesting defaults should omit the affected flags.

Technical review

Best possible solution:

Retain the net-neutral correction in the existing parsers, preserving documented defaults and valid-input behavior under the accepted compatibility scope.

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

Yes. Current-main guards demonstrably treat explicit blanks as omission, and the supplied baseline CLI trace corroborates that path; this review did not execute target code.

Is this the best way to solve the issue?

Yes. Correcting omission detection at the audit command owner reuses strict validation for all affected contexts; a new parser, Gateway change, or compatibility option would add unnecessary complexity.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This corrects bounded audit-query validation with limited operator-facing impact.
  • merge-risk: 🚨 compatibility: Previously tolerated explicit empty arguments now fail locally, which can affect existing shell scripts despite unchanged omitted defaults.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The supplied exact-head source-CLI trace demonstrates local rejection of an empty timestamp before the Gateway credential boundary, with baseline failure and valid-value controls; focused tests supplement list/explain-limit coverage.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied exact-head source-CLI trace demonstrates local rejection of an empty timestamp before the Gateway credential boundary, with baseline failure and valid-value controls; focused tests supplement list/explain-limit coverage.

Evidence

What I checked:

  • Introduced change and actual merge result: The pinned introduction changes only three omission guards and adds blank-input regression cases. The inspected test merge records the pinned main parent followed by the exact PR head; its production delta against main is the same three guards. (src/commands/audit.ts:68, 505c57b795e4)
  • Current-main and released behavior: Both fetched main and v2026.9.3 retain the falsy guards: blank timestamps become absent bounds, and empty limits select defaults. The proposed correction is therefore still missing from both inspected revisions. (src/commands/audit.ts:68, b8e2dbc7ca42)
  • Caller, owner, and parsing contracts: The audit registration forwards argument strings unchanged. The command validates both activity timestamps and the selected list/explain limit before calling its Gateway query helper. Existing parseStrictPositiveInteger rejects blank strings. This path uses OpenClaw-owned parsing and RPC contracts; no Codex runtime or protocol dependency signal applies. (src/cli/program/register.audit.ts:44, 0cffbf8ea240)
  • Documented bounds and defaults: The CLI reference specifies ISO timestamps or Unix milliseconds, activity limits of 1–500 with default 100, and explanation limits with default 50. It does not document blank values as a supported omission syntax. Public docs: docs/cli/audit.md. (docs/cli/audit.md:66, 0cffbf8ea240)
  • Regression and sibling coverage: The complete audit test module covers blank timestamp and list/explain-limit rejection before Gateway calls, omitted defaults, valid numeric/ISO inputs, maximum bounds, and older-Gateway fallback. The added tests exercise the existing command boundary without introducing production test seams. Tests were inspected, not executed during this read-only review. (src/commands/audit.test.ts:70, 0cffbf8ea240)
  • Real CLI before/after proof: The supplied body snapshot, sourceRevision a3befebce998ae968e1245c2a959dcb27dcd7a440ff3a426be46dcd8e30724ec, contains Node v24.15.0 source-CLI traces. An actual empty --after argument reaches Gateway credential validation on the baseline but produces the local timestamp error at the exact PR head; a valid --after 1234 --limit 1 control still reaches credential validation. This proves the changed pre-RPC behavior, not an authenticated audit query. (src/commands/audit.ts:68, 0cffbf8ea240)

Likely related people:

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

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (3 earlier review cycles)
  • reviewed 2026-09-03T14:04:41.641Z sha 0cffbf8 :: blocked before merge. :: none
  • reviewed 2026-09-08T13:57:07.933Z sha 0cffbf8 :: blocked before merge. :: none
  • reviewed 2026-09-11T00:09:03.358Z sha 0cffbf8 :: blocked before merge. :: none

@roboclaw-bot roboclaw-bot added the clawtributor-review Clawtributor pull request awaiting prioritized maintainer review label Sep 8, 2026
@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Sep 8, 2026
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

Preparing this PR for maintainer landing at 0cffbf8ea24063f4665493d0a2fee10cc8c8ae6f. Please refresh the completed review for the native landing gate; existing exact-head behavior evidence is in the PR body.

@clawsweeper

clawsweeper Bot commented Sep 11, 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:

@Patrick-Erichsen Patrick-Erichsen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The audit parser correction is ready to land. Reviewed head 0cffbf8ea24063f4665493d0a2fee10cc8c8ae6f: explicit blank timestamps and list/explain limits now fail before RPC; omitted and valid inputs preserve the existing behavior. Current main still has the three falsy guards. Reused the exact-head source-CLI RED/GREEN trace and 21 focused passes in the body, plus green CI and fresh independent source review. This is a trivial three-guard repair; no new runtime execution or authenticated audit query is claimed. The intended blank-input tightening is accepted. Fresh CI/review timestamps are being obtained for the native landing gate.

@Patrick-Erichsen
Patrick-Erichsen merged commit d30daf5 into openclaw:main Sep 11, 2026
217 checks passed
@Patrick-Erichsen

Copy link
Copy Markdown
Contributor

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

clawtributor-review Clawtributor pull request awaiting prioritized maintainer review commands Command implementations merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. 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. size: XS 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.

3 participants