test(cli): trim logs subprocess coverage#4919
Conversation
|
Warning Review limit reached
More reviews will be available in 31 minutes and 54 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Enterprise Run ID: 📒 Files selected for processing (3)
📝 WalkthroughWalkthroughThis PR refactors the sandbox logs action to accept injectable runtime dependencies instead of hard-coding process/spawn calls. A new ChangesSandbox Logs Dependency Injection & Testability
Sequence DiagramsequenceDiagram
participant Caller
participant showSandboxLogsWithDeps
participant DockerPreflight
participant AuditLogs
participant GatewayLogs
participant OpenShellLogs
participant Output
Caller->>showSandboxLogsWithDeps: (sandboxName, options, deps?)
showSandboxLogsWithDeps->>DockerPreflight: check if runtime is down
alt Runtime Down
DockerPreflight->>Output: print guidance
DockerPreflight->>Caller: exit(1)
else Runtime Healthy
showSandboxLogsWithDeps->>AuditLogs: enable audit logging
showSandboxLogsWithDeps->>GatewayLogs: probe gateway tail
showSandboxLogsWithDeps->>OpenShellLogs: probe OpenShell logs
GatewayLogs->>Output: merge stdout
OpenShellLogs->>Output: merge stdout
Output->>Caller: writeStdout result
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
E2E Advisor RecommendationRequired E2E: Dispatch hint: Auto-dispatched E2E: Full advisor summaryE2E Recommendation AdvisorBase: Required E2E
Optional E2E
New E2E recommendations
Dispatch hint
|
E2E Scenario Advisor RecommendationRequired scenario E2E: Dispatch required scenario E2E:
Full scenario advisor summaryE2E Scenario AdvisorBase: Required scenario E2E
Optional scenario E2E
Relevant changed files
|
PR Review AdvisorFindings: 0 needs attention, 0 worth checking, 0 nice ideas Consider writing more tests for
This is an automated advisory review. A human maintainer must make the final merge decision. |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
test/cli/logs.test.ts (1)
64-65: 💤 Low valueUnreachable exit statement in timeout test stub.
The
exit 0on line 65 is unreachable after the infinite loop on line 64. While this doesn't affect test behavior, removing it would make the stub's timeout-forcing intent clearer.♻️ Proposed cleanup
const setup = createLogsTestSetup("nemoclaw-cli-logs-openclaw-timeout-", [ 'if [ "$1" = "sandbox" ]; then', " while true; do :; done", - " exit 0", "fi", ]);🤖 Prompt for 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. In `@test/cli/logs.test.ts` around lines 64 - 65, The stub in the timeout test in test/cli/logs.test.ts contains an infinite loop string " while true; do :; done" followed by an unreachable " exit 0"; remove the unreachable " exit 0" entry (or replace the stub with a single infinite-loop command) so the intent of forcing a timeout is clear—look for the timeout test that builds the command array containing those two strings and update it to only include the infinite loop.
🤖 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.
Nitpick comments:
In `@test/cli/logs.test.ts`:
- Around line 64-65: The stub in the timeout test in test/cli/logs.test.ts
contains an infinite loop string " while true; do :; done" followed by an
unreachable " exit 0"; remove the unreachable " exit 0" entry (or replace the
stub with a single infinite-loop command) so the intent of forcing a timeout is
clear—look for the timeout test that builds the command array containing those
two strings and update it to only include the infinite loop.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Enterprise
Run ID: 610c8e93-4baf-4fa3-9d97-efb29a53b79e
📒 Files selected for processing (4)
src/commands/sandbox/logs.test.tssrc/lib/actions/sandbox/logs.test.tssrc/lib/actions/sandbox/logs.tstest/cli/logs.test.ts
Selective E2E Results — ✅ All requested jobs passedRun: 27105642903
|
|
Addressed the feedback comments in 88f83a1:
Verification:
The push hook also passed for the updated branch. |
Selective E2E Results — ✅ All requested jobs passedRun: 27107687337
|
## Summary This PR targets the next slow policy runtime bucket identified after #4919 by moving built-in `policy-add` / `policy-remove` confirmation coverage out of subprocess-heavy CLI harnesses and into same-process action tests. Custom preset `--from-file` / `--from-dir` subprocess coverage stays in `test/policies.test.ts` for a smaller, mechanical first step. ## Related Issue Part of #4892 ## Changes - Add `src/lib/actions/sandbox/policy-channel-policy.test.ts` with mocked same-process coverage for `addSandboxPolicy` and `removeSandboxPolicy` prompts, declined confirmation, dry-run, non-interactive mode, agent-specific preset filtering, and messaging validation guidance. - Remove the equivalent built-in policy-add/remove subprocess blocks from `test/policies.test.ts`, reducing the policy suite from 166 tests in the #4919 artifact to 144 tests in this full local run. - Ratchet `test/policies.test.ts` in `ci/test-file-size-budget.json` from 3143 lines to 2763 lines so it cannot silently grow back. - Leave custom preset `--from-file` / `--from-dir` subprocess coverage intact for a follow-up target. ## Type of Change - [x] Code change (feature, bug fix, or refactor) - [ ] Code change with doc updates - [ ] Doc only (prose changes, no code sample modifications) - [ ] Doc only (includes code sample changes) ## Verification - [x] `npx prek run --all-files` passes - [x] `npm test` passes - [x] Tests added or updated for new or changed behavior - [x] No secrets, API keys, or credentials committed - [ ] Docs updated for user-facing behavior changes - [ ] `npm run docs` builds without warnings (doc changes only) - [ ] Doc pages follow the [style guide](https://github.com/NVIDIA/NemoClaw/blob/main/docs/CONTRIBUTING.md) (doc changes only) - [ ] New doc pages include SPDX header and frontmatter (new pages only) --- Signed-off-by: Carlos Villela <cvillela@nvidia.com>
Summary
This PR targets the next slow CLI runtime bucket from #4892 by moving non-follow sandbox logs coverage out of subprocess-heavy CLI tests and into fast action/command unit tests. The public logs CLI smoke and follow/signal tests stay in
test/cli/logs.test.ts, while source selection, audit setup, degraded-source behavior, merged output, and Docker outage handling are covered through injected dependencies.Related Issue
Part of #4892
Changes
showSandboxLogsWithDepsso sandbox logs behavior can be tested with fake OpenShell, Docker, stdout, and exit dependencies.--tailand--sinceparser coverage intosrc/commands/sandbox/logs.test.ts.test/cli/logs.test.tsfrom 20 subprocess tests to 10 runtime smokes and shorten the remaining timeout/order waits.test/cli/logs.test.tsmoved from 17.95s / 20 tests to 5.66s / 10 tests; the focused 10-file hot set moved from 14.95s to 12.85s wall-clock.Type of Change
Verification
npx prek run --all-filespassesnpm testpassesnpm run docsbuilds without warnings (doc changes only)Signed-off-by: Carlos Villela cvillela@nvidia.com
Summary by CodeRabbit
Tests
Chores