Repository navigation
fix(audit): preserve sequence range validation before numeric decoding - #139587
Conversation
Read the inserted sequence losslessly before the existing safe-integer guard so oversized audit sequences retain the domain error and transactional rollback. Keep duplicate handling and retention unchanged.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 9:15 PM ET / September 6, 2026, 01:15 UTC. ClawSweeper reviewWhat this changesThe PR reads newly inserted audit sequence numbers as text before validating their numeric range and corrects the regression fixture to bind a SQLite integer. Merge readiness✅ Ready for maintainer review The repair remains necessary: fetched main and the latest release still decode the inserted row ID before the audit range guard. No actionable defect was found in the proposed patch. Priority: P2 Review scores
Verification
How this fits togetherOpenClaw’s audit writer stores metadata about agent, tool, and message activity in a bounded SQLite ledger. Sequence numbers order those records for operator queries and pagination. flowchart TD
A[Activity metadata] --> B[Audit writer]
B --> C[Transactional ledger insert]
C --> D{New record returned?}
D -->|No| E[Duplicate ignored]
D -->|Yes| F{Sequence safely representable?}
F -->|No| G[Domain error and rollback]
F -->|Yes| H[Prune and return audit record]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +2, Tests 0. Total +2 across 2 files. View PR surface stats
Review metricsNone. Technical reviewBest possible solution: Keep lossless sequence decoding local to the audit insert while preserving the existing numeric contract and transactional rollback. Do we have a high-confidence way to reproduce the issue? Yes, from source: seed the audit sequence high-water mark with BigInt(Number.MAX_SAFE_INTEGER) and insert through recordAuditEvent; the old helper decodes the row ID before the guard. Tests were inspected, not executed during this review. Is this the best way to solve the issue? Yes. Returning the sequence as SQL text uses the existing synchronous query helper and repairs decoding at its owning store without changing global SQLite behavior. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 1d9ce1ac9ffa. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Merged via squash.
|
* origin/main: (302 commits) test(gateway): preserve held-work close failures (#139593) refactor(exec): share package argument scanning (#139560) fix(audit): preserve sequence range validation before numeric decoding (#139587) fix(transcripts): retain capture ownership through failed cleanup (#139572) refactor(models): share selector reference traversal (#139571) perf(agents): classify allowlists without intermediate sets (#138392) chore(release): update appcast for 2026.9.2 (#139575) fix(ci): synchronize cloud retries and board widget input (#139506) fix(plugins): explain SDK incompatibilities after core updates (#139458) fix(voice-call): retain installed WebSocket behavior under Bun (#139567) test(text): consolidate literal sanitizer cases (#139579) test(gateway): observe native drain without a lint exception (#139576) test(memory): consolidate visibility fixtures without policy defaults (#139569) fix(ui): show shimmer skeletons while loading Control UI (#139525) test(qa): make cleanup child logging deterministic (#139566) test(cli): keep Unix socket fixtures within path limits (#139565) fix: avoid slow incognito key checks in large session stores (#139528) feat(macos): open Gateway windows from the Gateways menu (#139522) test(workshop): isolate marker casing fixture identities (#139554) fix(process): require cleanup evidence before releasing owned work (#139517) ... # Conflicts: # scripts/release-check.ts
* commit '047587a542ce205ee78354fbd88ba8ec05c07844': (45 commits) chore(ui): refresh control ui locales (#139481) fix(slack): keep prototype-named emoji shortcodes intact (#136374) fix(gateway): deliver upgrade rejection responses under Bun (#139516) refactor(test): simplify catalog guards and fix native report fixture (#139496) fix(macos): prevent dashboard fixture loopback timeouts (#139556) fix(matrix): preserve selected reply targets inside threads (#139479) test(gateway): preserve held-work close failures (#139593) refactor(exec): share package argument scanning (#139560) fix(audit): preserve sequence range validation before numeric decoding (#139587) fix(transcripts): retain capture ownership through failed cleanup (#139572) refactor(models): share selector reference traversal (#139571) perf(agents): classify allowlists without intermediate sets (#138392) chore(release): update appcast for 2026.9.2 (#139575) fix(ci): synchronize cloud retries and board widget input (#139506) fix(plugins): explain SDK incompatibilities after core updates (#139458) fix(voice-call): retain installed WebSocket behavior under Bun (#139567) test(text): consolidate literal sanitizer cases (#139579) test(gateway): observe native drain without a lint exception (#139576) test(memory): consolidate visibility fixtures without policy defaults (#139569) fix(ui): show shimmer skeletons while loading Control UI (#139525) ...
* commit 'refs/openclaw/tasks/pr-135167-main': (2467 commits) refactor(ios): reuse shared integer conversion (#139581) fix(sessions): prevent database lock failures during reclamation (#139469) perf(test): reuse transforms within owned scheduler slots (#139553) test(agents): share sparse transcript input fixtures (#139589) chore(ui): refresh control ui locales (#139481) fix(slack): keep prototype-named emoji shortcodes intact (#136374) fix(gateway): deliver upgrade rejection responses under Bun (#139516) refactor(test): simplify catalog guards and fix native report fixture (#139496) fix(macos): prevent dashboard fixture loopback timeouts (#139556) fix(matrix): preserve selected reply targets inside threads (#139479) test(gateway): preserve held-work close failures (#139593) refactor(exec): share package argument scanning (#139560) fix(audit): preserve sequence range validation before numeric decoding (#139587) fix(transcripts): retain capture ownership through failed cleanup (#139572) refactor(models): share selector reference traversal (#139571) perf(agents): classify allowlists without intermediate sets (#138392) chore(release): update appcast for 2026.9.2 (#139575) fix(ci): synchronize cloud retries and board widget input (#139506) fix(plugins): explain SDK incompatibilities after core updates (#139458) fix(voice-call): retain installed WebSocket behavior under Bun (#139567) ...
openclaw#139587) Read the inserted sequence losslessly before the existing safe-integer guard so oversized audit sequences retain the domain error and transactional rollback. Keep duplicate handling and retention unchanged.
Related: #139428
What Problem This Solves
Audit insertion can throw a native SQLite rowid-conversion error before its existing supported-integer-range check runs. The full-suite profiling run exposed this at the largest safe JavaScript integer boundary.
Why This Change Was Made
Return the inserted sequence as SQLite text, then apply the existing Number conversion and safe-integer guard inside the same transaction. Preserve duplicate no-row handling, pruning, rereading, terminal binding, and rollback order. The regression fixture binds the high-water mark as an actual SQLite INTEGER.
User Impact
Oversized audit sequences receive the existing domain-specific rejection with the insert rolled back. No schema, retention, collection, reader-scope, or generic SQLite decoding policy changes. Net two production lines added; test LOC is unchanged.
Evidence
The original audit-owner test reproduced the native conversion failure with the INTEGER fixture. The unchanged named-error and zero-row rollback assertions pass after the repair. All 198 audit/writer-family cases and 12 transaction cases pass, including deduplication and retention behavior. Full changed checks, formatting/diff checks, deslop and fresh independent P2 review pass.
No runtime reduction is claimed; this repairs a correctness blocker for the campaign baseline.