Skip to content

fix: address CodeRabbit review findings from v0.4.11 merge (#487) - #488

Merged
RetricSu merged 2 commits into
developfrom
agent/claude-bear/827dac50
Aug 3, 2026
Merged

fix: address CodeRabbit review findings from v0.4.11 merge (#487)#488
RetricSu merged 2 commits into
developfrom
agent/claude-bear/827dac50

Conversation

@humble-little-bear

Copy link
Copy Markdown
Collaborator

Fixes all 8 actionable CodeRabbit review comments from #487 (the v0.4.11 develop→master merge).

Changes

Logging (offckb logs)

  • logs script scanned only the last tail lines before filtering, so sparse ckb-script entries were usually missed → scan a 100× wider window, trim to tail after filtering (src/cmd/logs.ts)
  • Unknown log targets (e.g. offckb logs scrpit) silently fell back to the node log → now rejected with the accepted values (src/cmd/logs.ts)
  • followLogFile detected rotation only as a size decrease; a rotated-in file already larger than the old one was read from a stale offset → reset on inode change too, with the test now modeling real rotation (rename + larger replacement) (src/devnet/log-file.ts, tests/logs.test.ts)

Chain init

  • semver.gte('0.205.0-rc1', '0.205.0') is false, so 0.205.0 rc binaries had the Terminal RPC module stripped → use semver.satisfies(v, '>=0.205.0-0') (src/node/init-chain.ts)

ckb-tui install

  • A binary that lost its execute bit passed verification and failed later at spawn time → X_OK check on POSIX routes it into the reinstall path (src/tools/ckb-tui.ts)

RPC proxy

  • A failed proxy.log rollover (e.g. locked file on Windows) set size = -1 and dropped every later event → rollover failure now keeps appending and retries on the next event (src/tools/proxy-events.ts)
  • Batched JSON-RPC requests were never recorded (batched send_transaction txs lost), and missing/non-array params threw a TypeError misreported as a parse error → normalize payloads to an array, guard params (src/tools/proxy-events.ts)
  • ctx annotated as ProxyEventContext; --verbose now wires a debug-level sink so per-request "RPC Req" lines print during verbose runs (src/tools/rpc-proxy.ts, src/cmd/node.ts)

Tests

  • New/updated coverage: sparse-script tail scan, unknown-target rejection, inode rotation, 0.205.0 rc gating, execute-bit mismatch, rollover-failure append + retry, batch request handling, params guard
  • Full suite: 36 suites, 316 passed / 7 skipped (pre-existing), 0 failed; tsc --noEmit clean; build passes

🤖 Generated with Claude Code

- logs: scan a wider window before script-filtering the tail so sparse
  ckb-script entries are not missed; reject unknown log targets instead
  of silently falling back to node
- log-file: detect rotation by inode change in followLogFile, not only
  by size decrease; test rotation via rename + larger replacement file
- init-chain: accept CKB 0.205.0 prereleases for Terminal RPC gating via
  semver range '>=0.205.0-0'
- ckb-tui: treat a binary without the execute bit as a mismatch so it
  flows into the reinstall path (POSIX only)
- proxy-events: keep appending events when a proxy.log rollover fails
  and retry on the next event; normalize batch JSON-RPC request payloads
  and guard non-array send_transaction params
- rpc-proxy: annotate ctx as ProxyEventContext and wire --verbose to a
  debug-level sink so per-request lines print during verbose runs

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 35eafab5-53e5-4cd0-99f1-1a9786ff8530

📥 Commits

Reviewing files that changed from the base of the PR and between c759b19 and 1a25426.

📒 Files selected for processing (8)
  • .changeset/review-fixes-v0411.md
  • src/cli.ts
  • src/cmd/logs.ts
  • src/node/init-chain.ts
  • src/tools/proxy-events.ts
  • tests/init-chain.test.ts
  • tests/logs-command.test.ts
  • tests/proxy-events.test.ts
🚧 Files skipped from review as they are similar to previous changes (4)
  • src/node/init-chain.ts
  • tests/init-chain.test.ts
  • tests/logs-command.test.ts
  • src/tools/proxy-events.ts

📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes

    • Improved log tailing for sparse script logs and file rotation.
    • Invalid log targets and non-positive tail values now produce clear errors.
    • Fixed detection of CKB prerelease Terminal RPC support.
    • Prevented non-executable ckb-tui binaries from being accepted.
    • Improved proxy log rollover reliability.
    • Added support for batched RPC requests and clearer send_transaction warnings.
  • Enhancements

    • Verbose mode now includes detailed proxy request logging.

Walkthrough

The patch updates log validation and scanning, inode-based rotation handling, RPC proxy batching and rollover, verbose logging, Terminal RPC prerelease detection, and executable binary checks.

Changes

CLI fixes

Layer / File(s) Summary
Log scanning and rotation
src/cli.ts, src/cmd/logs.ts, src/devnet/log-file.ts, tests/logs-command.test.ts, tests/logs.test.ts
The CLI requires positive integer tails and rejects unknown explicit targets. Script logs scan beyond the raw tail window before filtering. File following resets state after inode changes.
RPC proxy requests and logging
src/tools/rpc-proxy.ts, src/tools/proxy-events.ts, src/cmd/node.ts, tests/proxy-events.test.ts
The proxy accepts verbose configuration, processes valid batch members, validates send_transaction parameters, and retries failed log rollover.
Version and binary compatibility
src/node/init-chain.ts, src/tools/ckb-tui.ts, tests/init-chain.test.ts, tests/ckb-tui-install.test.ts, .changeset/review-fixes-v0411.md
Terminal RPC detection accepts supported 0.205.0 prereleases. Non-Windows binaries must be executable. Tests and the patch changeset record these updates.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant nodeDevnet
  participant RPCProxy
  participant proxyEvents
  participant UnifiedLogger
  nodeDevnet->>RPCProxy: createRPCProxy(..., { verbose })
  RPCProxy->>UnifiedLogger: select debug sink when verbose
  RPCProxy->>proxyEvents: process single or batch request members
  proxyEvents->>UnifiedLogger: log requests and validation warnings
Loading

Possibly related PRs

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the pull request as fixes for the v0.4.11 merge findings.
Description check ✅ Passed The description directly explains the eight review fixes and identifies the affected behavior and tests.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/cmd/logs.ts`:
- Around line 37-39: Validate the parsed tail value before calculating
scanWindow in the logs command, rejecting zero (including -0) and any
non-positive value so script mode never reaches slice(-tail) with zero. Keep the
existing positive-tail behavior unchanged.

In `@src/node/init-chain.ts`:
- Around line 76-78: Update supportsTerminalRpcModule so newer Terminal RPC
prereleases, including versions with greater patch or minor values than
TERMINAL_RPC_MIN_CKB_VERSION, satisfy the minimum-version check. Adjust the
semver comparison to include prereleases across newer versions while preserving
the existing true behavior for null or invalid versions.

In `@src/tools/proxy-events.ts`:
- Around line 66-74: Update the rollover logic around the fs.rmSync and
fs.renameSync calls to preserve the existing `${filePath}.1` archive: move it to
a temporary path, attempt the active-log rename, and restore the archive when
that rename fails before retaining append behavior. Add a test covering
renameSync failing after the archive is successfully moved or removed, and
verify the prior archive remains intact.
- Around line 99-100: Update the batch iteration in the proxy event handling
flow around handleOneRequest to validate each member is a non-null object before
dispatching it, skip invalid members, and continue processing subsequent
requests. Add a batch test covering an invalid member before a valid
send_transaction request and verify the valid transaction is still recorded.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 5021b574-85d7-4da2-934b-4666f77366e7

📥 Commits

Reviewing files that changed from the base of the PR and between 51f437e and c759b19.

📒 Files selected for processing (13)
  • .changeset/review-fixes-v0411.md
  • src/cmd/logs.ts
  • src/cmd/node.ts
  • src/devnet/log-file.ts
  • src/node/init-chain.ts
  • src/tools/ckb-tui.ts
  • src/tools/proxy-events.ts
  • src/tools/rpc-proxy.ts
  • tests/ckb-tui-install.test.ts
  • tests/init-chain.test.ts
  • tests/logs-command.test.ts
  • tests/logs.test.ts
  • tests/proxy-events.test.ts

Comment thread src/cmd/logs.ts
Comment thread src/node/init-chain.ts Outdated
Comment thread src/tools/proxy-events.ts
Comment thread src/tools/proxy-events.ts
- logs: reject --tail 0/negative (slice(-0) dumped the whole filtered log)
- init-chain: includePrerelease so 0.205.1-rc1/0.206.0-rc1 pass the
  Terminal RPC minimum-version check
- proxy-events: preserve the previous proxy.log.1 archive when the
  active-log rename fails during rollover
- proxy-events: skip malformed JSON-RPC batch members instead of
  aborting the rest of the batch

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@RetricSu
RetricSu merged commit 852b68b into develop Aug 3, 2026
7 checks passed
@RetricSu
RetricSu deleted the agent/claude-bear/827dac50 branch August 3, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants