Skip to content

refactor(reply): share usage-bar numeric coercion - #147863

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/usage-bar-numeric-coercion-20260914
Sep 14, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/usage-bar-numeric-coercion-20260914

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

This scoped refactor is explicitly requested by the maintainer as part of the approved code-maintenance deliverable, continuing after the prior triage closure.

Five usage-bar numeric formatters repeat the same empty-input guard, numeric conversion and finite-value check.

User Impact

Existing coercion, formatting and fallbacks stay unchanged. Booleans, whitespace and numeric strings keep their current handling; the inverse formatter still passes invalid values through. Missing-value fallback remains distinct from failed numeric formatting.

Why This Change Was Made

Share the existing numeric-input policy and reuse the canonical finite-number check. Keep formatter-specific output, precision validation and the separate meter normalization path intact.

Production: −13 lines. Tests: +34 lines.

Evidence

  • Personal review covered the complete translator, usage contract, actual reply usage-line caller, canonical numeric helper and barrel, public tests and relevant precision/meter history.
  • Thirteen new public cases cover all five formatters across ten input rows, alias-produced null/empty values and missing-versus-invalid pipeline behavior. Existing complete-footer coverage remains.
  • Signed head 7e5895a92cd28ebcc805b4acb7c77139e7e17536 passed local whitespace checks and the required P2 review with no actionable findings. The review sandbox exposed only the supplied diff; primary review supplied the full source, caller and dependency contracts. The staged classifier selected normal core lanes without executing them.
  • Reopened CI attempt 1 passed all 119 selected jobs, with 17 unselected skips and the required gate successful. Production/test types, lint, pinned formatting, build, dependency and boundary checks passed.
  • Actual translator execution passed all 38 cases, including the 13 new cases and existing full-footer/usage-contract coverage, with no target skips. The tested merge 48009cd4e67f9f54a977c828fb54a96850deb6b9 contains the exact reviewed source, tests and canonical helper. This reopened run reused that original merge checkout; it does not prove the newer current-main parent or resolve other PRs’ UI budget failures.
  • The latest full ClawSweeper review was refreshed at this exact head on 2026-09-14 at 07:05:56 UTC (Revision 2) and has no findings, security issues, Before merge items or Rank-up moves. Stale local dependencies were not used for runtime proof. No live UI/provider execution, performance gain or bundle reduction is claimed. This changes no provider protocol, request, config/default or public API.

@vincentkoc vincentkoc self-assigned this Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 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.

@vincentkoc
vincentkoc marked this pull request as ready for review September 14, 2026 04:12
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper review

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 3:05 AM ET / 07:05 UTC (Revision 2).

ClawSweeper review

What this changes

Shares numeric conversion across five usage-footer formatters and adds rendering tests that preserve their existing output and fallback behavior.

Merge readiness

✅ Ready for maintainer review

Keep open: the consolidation remains absent from current main, the updated maintainer-authored body establishes its maintenance purpose, and review found no actionable defect.

Priority: P3
Reviewed head: 7e5895a92cd28ebcc805b4acb7c77139e7e17536

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving refactor with useful output-level coverage and no actionable review findings.
Proof confidence 🌊 off-meta tidepool Not applicable: This MEMBER-authored internal refactor is exempt from the external-contributor proof gate and changes no authority boundary; renderer tests and the verified CI job provide supplemental validation.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This MEMBER-authored internal refactor is exempt from the external-contributor proof gate and changes no authority boundary; renderer tests and the verified CI job provide supplemental validation.
Evidence reviewed 7 items Introduced change preserves conversion semantics: The pinned merge-base-to-head patch consolidates the same null, undefined, empty-string, Number conversion, and finite-number checks. Inverse formatting retains invalid-value passthrough; precision validation and meter normalization remain unchanged.
Canonical helper contract: The imported workspace helper returns its input when Number.isFinite succeeds and otherwise returns undefined. Calling it after Number(value) preserves the previous predicate and conversion order. This is an OpenClaw workspace dependency; no Codex runtime or protocol dependency is involved.
Production entrypoint and output coverage: The reply usage-line owner invokes renderUsageBar with buildUsageContract. Added tests exercise that renderer’s public output for coercion, alias-produced empty values, and missing-versus-invalid pipelines; existing full-footer coverage remains.
Findings None None.
Security None None.

How this fits together

OpenClaw’s usage-footer renderer combines reply usage data with built-in or custom templates. Its numeric formatters turn token counts, costs, percentages, and durations into text appended to replies.

flowchart LR
  A[Reply usage data] --> C[Usage footer renderer]
  B[Footer template] --> C
  C --> D[Shared numeric conversion]
  D --> E[Formatter output]
  E --> F[Reply footer text]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -13, Tests +34. Total +21 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 17 30 -13
Tests 1 34 0 +34
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 51 30 +21

Review metrics

None.

Technical review

Best possible solution:

Keep numeric input policy shared inside the renderer while preserving formatter-specific output, fallback handling, and separate meter normalization.

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

Not applicable: this PR consolidates existing behavior rather than reporting a defect; source comparison supports equivalent formatting semantics.

Is this the best way to solve the issue?

Yes: a private coercion helper reuses the existing finite-number predicate without changing public contracts or applying the formatters’ empty-value policy to meters.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal cleanup with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: This MEMBER-authored internal refactor is exempt from the external-contributor proof gate and changes no authority boundary; renderer tests and the verified CI job provide supplemental validation.

Evidence

What I checked:

  • Introduced change preserves conversion semantics: The pinned merge-base-to-head patch consolidates the same null, undefined, empty-string, Number conversion, and finite-number checks. Inverse formatting retains invalid-value passthrough; precision validation and meter normalization remain unchanged. (src/auto-reply/usage-bar/translator.ts:22, 7e5895a92cd2)
  • Canonical helper contract: The imported workspace helper returns its input when Number.isFinite succeeds and otherwise returns undefined. Calling it after Number(value) preserves the previous predicate and conversion order. This is an OpenClaw workspace dependency; no Codex runtime or protocol dependency is involved. (packages/normalization-core/src/number-coercion.ts:2, 7e5895a92cd2)
  • Production entrypoint and output coverage: The reply usage-line owner invokes renderUsageBar with buildUsageContract. Added tests exercise that renderer’s public output for coercion, alias-produced empty values, and missing-versus-invalid pipelines; existing full-footer coverage remains. (src/auto-reply/reply/agent-runner-usage-line.ts:90, 7e5895a92cd2)
  • Current-main necessity check: Fetched main still contains separate numeric conversion checks in the five formatters. The refactor therefore remains distinct; no merged replacement was established. No available local tag contains the PR head. (src/auto-reply/usage-bar/translator.ts:21, ff9aa365c8a4)
  • Discussion and review continuity: The earlier closure comment questioned sponsorship and characterization-test value. The captured updated body explicitly states a maintainer-requested maintenance deliverable, and the timeline records reopening. The previous review covered the same head and retained no findings or concrete rank-up moves. Live metadata confirms MEMBER authorship, assignment, and open state. (7e5895a92cd2)
  • Supplemental CI verification: GitHub confirms the linked checks-node-compact-large-10 job succeeded for the pinned head, including its Node test shard. The PR body reports 38 translator cases passing; this is test evidence, not live application proof. Local diff whitespace checking passed; no tests were executed during this read-only review. (src/auto-reply/usage-bar/translator.test.ts:63, 7e5895a92cd2)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Peter Lindsey: 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 (1 earlier review cycle)
  • reviewed 2026-09-14T04:23:04.900Z sha 7e5895a :: needs maintainer review before merge. :: none

@vincentkoc

Copy link
Copy Markdown
Member Author

Closing as standalone refactor-only work. Head 7e5895a92cd28ebcc805b4acb7c77139e7e17536 remains distinct from current main, but no user defect or sponsored deliverable requires this consolidation.

The new characterization matrix would also turn permissive JavaScript coercion details into maintained expectations without an established product contract.

@vincentkoc vincentkoc closed this Sep 14, 2026
@vincentkoc vincentkoc reopened this Sep 14, 2026
@vincentkoc
vincentkoc merged commit e0d0536 into main Sep 14, 2026
458 checks passed
@vincentkoc
vincentkoc deleted the refactor/usage-bar-numeric-coercion-20260914 branch September 14, 2026 07:18
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 14, 2026
* commit '8e6fe8e02ddb51bfec4e80071f0f2adcae4cf098': (47 commits)
  refactor: simplify Gateway health response parsing (#147834)
  fix: avoid Gateway stalls when renaming sessions (#147869)
  refactor(plugins): reuse worker optional-method validation (#147925)
  refactor(infra): remove unreachable firewall diagnostic fallback (#147882)
  fix(ui): open attached automations from session hovercards (#147749)
  refactor(reply): share usage-bar numeric coercion (#147863)
  fix(doctor): report warnings for keyed agent configs (#123058)
  perf(plugins): reuse complete registry comparisons (#147893)
  fix(workboard): await lifecycle sweep completion in tests (#147950)
  fix: reduce stalls when browsing large session inventories (#147911)
  refactor(onboard): share custom model definition (#147915)
  feat(ios): collapse completed chat work above replies (#148002)
  fix(voice-call): retain state runtime for deferred streams (#147689)
  test(qa): compare Telegram entities semantically (#147752)
  fix(plugins): preserve runtime scope for deferred CLI actions (#147688)
  test(qa): keep Slack progress marker visible (#147748)
  test(qa): finish channel picker prompts (#147730)
  test(tui): handle auth restriction prompt (#147729)
  fix(qa): retain onboarding prompts across redraw bursts (#147687)
  fix(qa): seed Teams ambiguous timeout deterministically (#147686)
  ...
vincentkoc added a commit to SunnyShu0925/openclaw that referenced this pull request Sep 14, 2026
* commit '069710f909f0a7158777d0fc0bf1eab84e20c699': (45 commits)
  refactor(infra): consolidate update campaign reset ownership (openclaw#146555)
  refactor: simplify Gateway health response parsing (openclaw#147834)
  fix: avoid Gateway stalls when renaming sessions (openclaw#147869)
  refactor(plugins): reuse worker optional-method validation (openclaw#147925)
  refactor(infra): remove unreachable firewall diagnostic fallback (openclaw#147882)
  fix(ui): open attached automations from session hovercards (openclaw#147749)
  refactor(reply): share usage-bar numeric coercion (openclaw#147863)
  fix(doctor): report warnings for keyed agent configs (openclaw#123058)
  perf(plugins): reuse complete registry comparisons (openclaw#147893)
  fix(workboard): await lifecycle sweep completion in tests (openclaw#147950)
  fix: reduce stalls when browsing large session inventories (openclaw#147911)
  refactor(onboard): share custom model definition (openclaw#147915)
  feat(ios): collapse completed chat work above replies (openclaw#148002)
  fix(voice-call): retain state runtime for deferred streams (openclaw#147689)
  test(qa): compare Telegram entities semantically (openclaw#147752)
  fix(plugins): preserve runtime scope for deferred CLI actions (openclaw#147688)
  test(qa): keep Slack progress marker visible (openclaw#147748)
  test(qa): finish channel picker prompts (openclaw#147730)
  test(tui): handle auth restriction prompt (openclaw#147729)
  fix(qa): retain onboarding prompts across redraw bursts (openclaw#147687)
  ...
vincentkoc added a commit to nvtoroy/openclaw that referenced this pull request Sep 14, 2026
* commit '4ddb9ed21245eaca9f243e555a5ec070aaaf0dad': (113 commits)
  fix: avoid Gateway stalls when renaming sessions (openclaw#147869)
  refactor(plugins): reuse worker optional-method validation (openclaw#147925)
  refactor(infra): remove unreachable firewall diagnostic fallback (openclaw#147882)
  fix(ui): open attached automations from session hovercards (openclaw#147749)
  refactor(reply): share usage-bar numeric coercion (openclaw#147863)
  fix(doctor): report warnings for keyed agent configs (openclaw#123058)
  perf(plugins): reuse complete registry comparisons (openclaw#147893)
  fix(workboard): await lifecycle sweep completion in tests (openclaw#147950)
  fix: reduce stalls when browsing large session inventories (openclaw#147911)
  refactor(onboard): share custom model definition (openclaw#147915)
  feat(ios): collapse completed chat work above replies (openclaw#148002)
  fix(voice-call): retain state runtime for deferred streams (openclaw#147689)
  test(qa): compare Telegram entities semantically (openclaw#147752)
  fix(plugins): preserve runtime scope for deferred CLI actions (openclaw#147688)
  test(qa): keep Slack progress marker visible (openclaw#147748)
  test(qa): finish channel picker prompts (openclaw#147730)
  test(tui): handle auth restriction prompt (openclaw#147729)
  fix(qa): retain onboarding prompts across redraw bursts (openclaw#147687)
  fix(qa): seed Teams ambiguous timeout deterministically (openclaw#147686)
  refactor(mcp): load OAuth only when credentials are needed (openclaw#147884)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant