Skip to content

fix(audit): audit filters select wrong intervals when dates are invalid - #103433

Merged
steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/fix-audit-invalid-iso-timestamp
Jul 10, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
qingminglong:codex/fix-audit-invalid-iso-timestamp

Conversation

@qingminglong

@qingminglong qingminglong commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where operators querying openclaw audit could receive records outside the intended time window when --after or --before contained an impossible ISO calendar date, such as February 30.

Why This Change Was Made

Audit filters now use the existing strict absolute-time parser to validate ISO calendar dates before accepting the parsed timestamp. The command retains the existing local-time interpretation for ISO date-times without an explicit zone.

User Impact

Operators receive an immediate validation error for impossible audit filter dates instead of silently querying a shifted interval. Valid leap-day and timezone-less timestamps keep their existing behavior.

Evidence

  • Claim proved: impossible ISO calendar dates are rejected by the audit CLI before any Gateway request, while valid timezone-less audit filters still reach audit.list with the established local-time timestamp semantics.
  • Current-head real CLI proof at 099fbaa9c006a7347063e1bbc9c5cbc75286be77: ran the source-checkout CLI entry with isolated OPENCLAW_HOME, OPENCLAW_STATE_DIR, and a local loopback Gateway WebSocket responder.
$ node --import tsx src/entry.ts audit --after 2026-02-30T00:00:00Z --json --limit 1
exit=1
stderr:
Error: --after must be an ISO timestamp or Unix milliseconds.

$ node --import tsx src/entry.ts audit --after 2026-07-01T00:00:00 --json --limit 1
exit=0
stdout:
{
  "events": [
    {
      "id": "proof-event-1",
      "occurredAt": 1782864000000,
      "kind": "agent_run",
      "status": "succeeded",
      "agentId": "main",
      "sessionKey": "agent:main:main",
      "runId": "proof-run",
      "action": "proof"
    }
  ]
}

GATEWAY_AUDIT_LIST_CALLS=1
audit.list[0].params={"limit":1,"after":1782835200000}
  • Focused regression proof at 099fbaa9c006a7347063e1bbc9c5cbc75286be77: node scripts/run-vitest.mjs src/commands/audit.test.ts passed (4 tests).
  • Committed diff hygiene: git diff --check HEAD~1..HEAD passed.
  • Review proof: python .agents\\skills\\autoreview\\scripts\\autoreview --mode local passed with no accepted/actionable findings.

@openclaw-barnacle openclaw-barnacle Bot added commands Command implementations size: XS labels Jul 10, 2026
@clawsweeper clawsweeper Bot added 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. P2 Normal backlog priority with limited blast radius. labels Jul 10, 2026
@clawsweeper

clawsweeper Bot commented Jul 10, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 10, 2026, 8:49 AM ET / 12:49 UTC.

Summary
The branch adds strict calendar-date validation to audit --after and --before filters and adds parser regression coverage for impossible dates, leap days, and timezone-less timestamps.

PR surface: Source +1, Tests +7. Total +8 across 2 files.

Reproducibility: yes. Current main accepts and forwards JavaScript’s normalized timestamp for an impossible calendar date, and the exact-head CLI proof demonstrates the corrected rejection path.

Review metrics: none identified.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🐚 platinum hermit
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • none.

Risk before merge

  • [P1] The PR is behind current main, so maintainers should refresh or rebase and require checks against the resulting exact head before merge; no concrete three-way merge regression is currently visible.

Maintainer options:

  1. Decide the mitigation before merge
    Land the narrow shared-validator gate without adding another date parser or configuration surface, preserving the audit command’s existing numeric and timezone-less timestamp semantics.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No automated repair is needed; refresh the behind branch, rerun exact-head checks, and proceed through normal maintainer merge review.

Security
Cleared: The two-file parsing and test change adds no dependency, downloaded code, secret access, permission, install, publishing, or other supply-chain surface.

Review details

Best possible solution:

Land the narrow shared-validator gate without adding another date parser or configuration surface, preserving the audit command’s existing numeric and timezone-less timestamp semantics.

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

Yes. Current main accepts and forwards JavaScript’s normalized timestamp for an impossible calendar date, and the exact-head CLI proof demonstrates the corrected rejection path.

Is this the best way to solve the issue?

Yes. Reusing the established strict calendar validator as an acceptance gate is the narrowest maintainable fix and deliberately preserves the existing Date.parse result for supported timezone-less inputs.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against ea6aa1dc7591.

Label changes

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The exact-head terminal transcript directly demonstrates after-fix invalid-date rejection before gateway use and a successful valid timezone-less audit request with its transmitted parameters.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The exact-head terminal transcript directly demonstrates after-fix invalid-date rejection before gateway use and a successful valid timezone-less audit request with its transmitted parameters.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This fixes a bounded audit query correctness problem with limited blast radius and no evidence of data loss, security impact, or core-runtime failure.
  • 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. Sufficient (terminal): The exact-head terminal transcript directly demonstrates after-fix invalid-date rejection before gateway use and a successful valid timezone-less audit request with its transmitted parameters.
  • proof: sufficient: Contributor real behavior proof is sufficient. The exact-head terminal transcript directly demonstrates after-fix invalid-date rejection before gateway use and a successful valid timezone-less audit request with its transmitted parameters.
Evidence reviewed

PR surface:

Source +1, Tests +7. Total +8 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 2 1 +1
Tests 1 7 0 +7
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 9 1 +8

What I checked:

  • Current-main reproduction: Current main accepts every non-NaN Date.parse result and forwards the resulting after or before value directly in the audit.list request, allowing impossible dates to select a normalized interval. (src/commands/audit.ts:30, ea6aa1dc7591)
  • Patch behavior: The branch retains the numeric-millisecond path and original Date.parse result but requires the shared strict parser to validate an ISO string before accepting it. (src/commands/audit.ts:31, 099fbaa9c006)
  • Shared parser contract: The existing parser validates year, month, day, and time fields before parsing, explicitly preventing JavaScript calendar-date rollover while supporting padded ISO dates, datetimes, offsets, and timezone-less forms. (src/cron/parse.ts:23, ea6aa1dc7591)
  • Regression coverage: The branch covers a valid leap day, a timezone-less datetime, and an impossible February 30 input in the audit command parser tests. (src/commands/audit.test.ts:10, 099fbaa9c006)
  • Real behavior proof: The exact-head PR evidence shows the invalid date exits with the expected validation error before any gateway request, while a valid timezone-less filter reaches audit.list once with the expected local-time timestamp. (099fbaa9c006)
  • Current-main drift: The branch differs from current main only in the intended audit implementation and test files; no intervening audit or shared-parser change conflicts with the fix. (src/commands/audit.ts:10, ea6aa1dc7591)

Likely related people:

  • bladin: Current-main history attributes the commit that introduced both the audit command and shared absolute-time parser to this contributor, although that squash commit also contains concurrent unrelated work. (role: introduced current behavior; confidence: medium; commits: 80139d16bcbc; files: src/commands/audit.ts, src/cron/parse.ts)
  • obviyus: GitHub records this person as the merger of the current-main commit provenance associated with the newly introduced audit and parser files. (role: merger of introducing history; confidence: low; commits: 80139d16bcbc; files: src/commands/audit.ts, src/cron/parse.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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.

How this review workflow works
  • 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.
Review history (1 earlier review cycle)
  • reviewed 2026-07-10T10:51:59.205Z sha 099fbaa9c006a7347063e1bbc9c5cbc75286be77 :: needs real behavior proof before merge. :: none

@qingminglong

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Real behavior proof for head 099fbaa9c006a7347063e1bbc9c5cbc75286be77 is now in the PR Evidence section: impossible --after exits with the audit timestamp validation error, and a valid timezone-less timestamp reaches audit.list once with after=1782835200000.

@clawsweeper

clawsweeper Bot commented Jul 10, 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 repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed 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. labels Jul 10, 2026
@steipete steipete self-assigned this Jul 10, 2026
@steipete
steipete force-pushed the codex/fix-audit-invalid-iso-timestamp branch from 099fbaa to c2fc5e0 Compare July 10, 2026 15:48
@steipete

Copy link
Copy Markdown
Contributor

Land-ready verification for exact head c2fc5e0a4c4a14afa5c6dbeb08249a00cb326b51:

  • Sanitized AWS focused regression: pnpm test src/commands/audit.test.ts passed 1 file / 7 tests (run_49b3994f0a67). Coverage includes both --after and --before, plus a mocked local-vs-UTC negative control proving timezone-less input returns the original local Date.parse value.
  • Sanitized AWS changed gate: pnpm check:changed passed core/core-test typechecks, changed-file lint, policy guards, and import-cycle checks (run_4e4ce0e4d08f).
  • Installed Linux CLI proof: the repo-owned workspace-aware packer built and integrity-checked a tarball, npm installed it into a clean prefix, and the installed OpenClaw 2026.6.11 (c2fc5e0) binary rejected impossible dates for both flags while accepting the timezone-less form through to the gateway path (run_01c730cc9c7e).
  • Hosted exact-head checks: 66 passed, 31 skipped, 0 failed, 0 pending (97 total).

Known proof gaps: none.

@steipete
steipete merged commit cbfa7d4 into openclaw:main Jul 10, 2026
97 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 11, 2026
…id (openclaw#103433)

* fix(audit): reject invalid ISO timestamps in filters

* test(audit): cover strict date filter semantics

Co-authored-by: qingminlong <[email protected]>

---------

Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations 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.

2 participants