Skip to content

test(infra): add unit tests for SQLite number normalization - #98009

Merged
vincentkoc merged 2 commits into
openclaw:mainfrom
dwc1997:fix/sqlite-number-tests
Jul 1, 2026
Merged

vincentkoc merged 2 commits into
openclaw:mainfrom
dwc1997:fix/sqlite-number-tests

Conversation

@dwc1997

@dwc1997 dwc1997 commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

The normalizeSqliteNumber function handles SQLite's type system boundary where numeric columns may return number, bigint, or null. Without tests, the type conversion logic could silently break when the function is modified.

Why This Change Was Made

Add unit tests for normalizeSqliteNumber covering the full type boundary: number passthrough, bigint-to-number conversion, null/undefined handling, zero/negative values, NaN preservation, and safe integer range conversion.

User Impact

SQLite number normalization now has comprehensive test coverage at the type boundary, reducing regression risk.

Evidence

Direct behavior probe:

$ node --import tsx -e "import('./src/infra/sqlite-number.js').then(({ normalizeSqliteNumber }) => { const results = [{ input: '5 (number)', result: normalizeSqliteNumber(5), expected: 5 }, { input: '5 (bigint)', result: normalizeSqliteNumber(BigInt(5)), expected: 5 }, { input: 'null', result: normalizeSqliteNumber(null), expected: undefined }, { input: '-1 (number)', result: normalizeSqliteNumber(-1), expected: -1 }, { input: '0 (number)', result: normalizeSqliteNumber(0), expected: 0 }, { input: 'NaN', result: normalizeSqliteNumber(Number.NaN), expected: Number.NaN }]; console.log(JSON.stringify(results, (k, v) => typeof v === 'bigint' ? Number(v) : v, 2)); })"
[
  { "input": "5 (number)", "result": 5, "expected": 5 },
  { "input": "5 (bigint)", "result": 5, "expected": 5 },
  { "input": "null", "result": null, "expected": null },
  { "input": "-1 (number)", "result": -1, "expected": -1 },
  { "input": "0 (number)", "result": 0, "expected": 0 },
  { "input": "NaN", "result": null, "expected": null }
]

Targeted test:

$ node scripts/run-vitest.mjs run src/infra/sqlite-number.test.ts

 RUN  v4.1.8

 Test Files  1 passed (1)
      Tests  10 passed (10)
   Start at  23:10:32
   Duration  339ms

[test] passed 1 Vitest shard in 9.30s

Formatting:

$ npx oxfmt --check src/infra/sqlite-number.ts src/infra/sqlite-number.test.ts
Checking formatting...
All matched files use the correct format.
Finished in 53ms on 2 files using 8 threads.

Whitespace:

$ git diff --check

AI-assisted

Prepared with Codex. I reviewed the change and kept the PR focused on type boundary coverage.

@clawsweeper

clawsweeper Bot commented Jun 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 30, 2026, 2:20 AM ET / 06:20 UTC.

Summary
Adds a colocated Vitest test file for normalizeSqliteNumber covering number, bigint, null, zero, negative, NaN, and safe-integer cases.

PR surface: Tests +41. Total +41 across 1 file.

Reproducibility: not applicable. this is a test coverage PR rather than a bug report. Source inspection verifies the helper contract and caller inputs, while targeted test/CI output is the relevant validation 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:

  • [P2] Wait for the remaining broad CI jobs to finish before merge.

Risk before merge

  • [P1] Exact-head broad CI still had QA Smoke CI, checks-node-compact-large-whole-1, and checks-node-compact-small-whole-2 in progress at review time; maintainers should wait for required checks before merge.

Maintainer options:

  1. Decide the mitigation before merge
    Land the focused colocated tests after remaining exact-head CI is green, keeping normalizeSqliteNumber scoped to number | bigint | null.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Next step before merge

  • No ClawSweeper repair lane is needed; the remaining action is normal maintainer review plus exact-head CI completion.

Security
Cleared: The diff only adds a local Vitest test file and does not touch runtime code, dependencies, workflows, lockfiles, scripts, secrets, or package metadata.

Review details

Best possible solution:

Land the focused colocated tests after remaining exact-head CI is green, keeping normalizeSqliteNumber scoped to number | bigint | null.

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

Not applicable; this is a test coverage PR rather than a bug report. Source inspection verifies the helper contract and caller inputs, while targeted test/CI output is the relevant validation path.

Is this the best way to solve the issue?

Yes. Colocating narrow helper-boundary tests is the maintainable fix shape here; widening the helper signature or adding caller-level tests is not needed for the current contract.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P3: This is low-blast-radius infra test coverage with no runtime, config, storage-schema, dependency, or workflow changes.
  • 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 PR body includes terminal output for a helper probe and targeted Vitest run; the current head only removes an out-of-signature test case, and live CI type/lint checks succeeded.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body includes terminal output for a helper probe and targeted Vitest run; the current head only removes an out-of-signature test case, and live CI type/lint checks succeeded.
Evidence reviewed

PR surface:

Tests +41. Total +41 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 41 0 +41
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 41 0 +41

What I checked:

Likely related people:

  • masatohoshino: Current-main blame and merged PR metadata tie normalizeSqliteNumber to commit 888f399499c446a711832142b87a406cdf4cdc88, which added the helper and central SQLite caller files. (role: introduced helper; confidence: high; commits: 888f399499c4; files: src/infra/sqlite-number.ts, src/tasks/task-registry.store.sqlite.ts, src/plugin-state/plugin-state-store.sqlite.ts)
  • vincentkoc: Area history and shortlog show repeated prior work on task SQLite persistence, shared state, and related SQLite refactors around the files that now call the helper. (role: adjacent area contributor; confidence: medium; commits: e57b3618fc8d, fa5827079f72, 66413487c8de; files: src/tasks/task-registry.store.sqlite.ts, src/tasks/task-flow-registry.store.sqlite.ts, src/infra/sqlite-number.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.

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Jun 30, 2026
@dwc1997
dwc1997 force-pushed the fix/sqlite-number-tests branch from 63e2858 to 94c7829 Compare June 30, 2026 05:59
@clawsweeper clawsweeper Bot added 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: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Jun 30, 2026
@vincentkoc
vincentkoc merged commit 3669280 into openclaw:main Jul 1, 2026
112 of 118 checks passed
vincentkoc added a commit that referenced this pull request Jul 1, 2026
* 'main' of https://github.com/openclaw/openclaw: (29 commits)
  refactor(gateway): trim attach grant implementation
  feat(gateway): scoped attach grants for external MCP loopback clients
  fix(gateway): iOS Talk treats SecretRef-backed API keys as missing (#98210)
  test(infra): add unit tests for SQLite number normalization (#98009)
  test(config): add unit tests for resolveExecCommandHighlighting (#98087)
  test(utils): add unit tests for chunkItems (#98219)
  fix(core): propagate caller env PATHEXT through isExecutableFile on Windows (#98093)
  fix(matrix): guard JSON.parse against malformed homeserver response bodies (#97973)
  fix(sms): guard Twilio JSON.parse against malformed API response bodies (#97999)
  Add Swedish mobile app localization (#98043)
  fix(anthropic): surface Discord pre-tool commentary
  fix(tui): correct disconnect copy for device scope upgrades (#98144)
  chore(ui): refresh fa control ui locale
  chore(ui): refresh nl control ui locale
  chore(ui): refresh vi control ui locale
  chore(ui): refresh th control ui locale
  chore(ui): refresh pl control ui locale
  chore(ui): refresh uk control ui locale
  chore(ui): refresh id control ui locale
  chore(ui): refresh tr control ui locale
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 1, 2026
…#98009)

* test(infra): add unit tests for SQLite number normalization

* fix: remove undefined param test, not in function signature
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 1, 2026
* 'main' of https://github.com/openclaw/openclaw: (29 commits)
  refactor(gateway): trim attach grant implementation
  feat(gateway): scoped attach grants for external MCP loopback clients
  fix(gateway): iOS Talk treats SecretRef-backed API keys as missing (openclaw#98210)
  test(infra): add unit tests for SQLite number normalization (openclaw#98009)
  test(config): add unit tests for resolveExecCommandHighlighting (openclaw#98087)
  test(utils): add unit tests for chunkItems (openclaw#98219)
  fix(core): propagate caller env PATHEXT through isExecutableFile on Windows (openclaw#98093)
  fix(matrix): guard JSON.parse against malformed homeserver response bodies (openclaw#97973)
  fix(sms): guard Twilio JSON.parse against malformed API response bodies (openclaw#97999)
  Add Swedish mobile app localization (openclaw#98043)
  fix(anthropic): surface Discord pre-tool commentary
  fix(tui): correct disconnect copy for device scope upgrades (openclaw#98144)
  chore(ui): refresh fa control ui locale
  chore(ui): refresh nl control ui locale
  chore(ui): refresh vi control ui locale
  chore(ui): refresh th control ui locale
  chore(ui): refresh pl control ui locale
  chore(ui): refresh uk control ui locale
  chore(ui): refresh id control ui locale
  chore(ui): refresh tr control ui locale
  ...
chenyangjun-xy pushed a commit to chenyangjun-xy/openclaw that referenced this pull request Jul 1, 2026
…#98009)

* test(infra): add unit tests for SQLite number normalization

* fix: remove undefined param test, not in function signature
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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