Skip to content

fix(ci): repair source-shape checks - #2864

Merged
cv merged 1 commit into
mainfrom
fix/ci-source-shape-start-tests
May 1, 2026
Merged

fix(ci): repair source-shape checks#2864
cv merged 1 commit into
mainfrom
fix/ci-source-shape-start-tests

Conversation

@cv

@cv cv commented May 1, 2026

Copy link
Copy Markdown
Collaborator

Summary

Updates the CI regression tests that were failing on main by stubbing the new startup permission-normalization call in the Telegram diagnostics harness and replacing source-text assertions with behavioral coverage. This keeps the source-shape budget at zero while preserving coverage for the #2681 mutable-permissions contract.

Changes

  • Stub normalize_mutable_config_perms in the extracted pre-gateway startup test so the root entrypoint path no longer exits 127.
  • Rewrite test/repro-2681-group-writable.test.ts to exercise permission behavior through temporary shell execution and mocked unlockAgentConfig calls instead of asserting on Dockerfile/source strings.
  • Verify the behavioral tests cover group-write restoration, setgid directory handling, shields-up root-owned skip behavior, and shields-down OpenClaw modes.

Type of Change

  • 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

  • npx prek run --all-files passes
  • npm test passes
  • Tests added or updated for new or changed behavior
  • No secrets, API keys, or credentials committed
  • Docs updated for user-facing behavior changes
  • make docs builds without warnings (doc changes only)
  • Doc pages follow the style guide (doc changes only)
  • New doc pages include SPDX header and frontmatter (new pages only)

Signed-off-by: Carlos Villela cvillela@nvidia.com

Summary by CodeRabbit

Tests

  • Enhanced overall test coverage for configuration directory permission validation and enforcement mechanisms
  • Replaced static text-based validation with comprehensive dynamic runtime permission checks
  • Added thorough testing for group-write permission restoration across configuration files and directories
  • Improved validation of permission enforcement during agent configuration management and unlock operations
  • Strengthened verification of configuration directory state and file permissions during critical operational scenarios

@cv cv self-assigned this May 1, 2026
@coderabbitai

coderabbitai Bot commented May 1, 2026

Copy link
Copy Markdown
Contributor
📝 Walkthrough

Walkthrough

Test suite enhancements add a stubbed shell function injection into startup diagnostics and replace static regex-based tests with behavioral tests that validate runtime permission enforcement and chmod command execution on configuration directories.

Changes

Cohort / File(s) Summary
Test Updates
test/nemoclaw-start.test.ts, test/repro-2681-group-writable.test.ts
First file injects normalize_mutable_config_perms() stub into startup script to validate pre-gateway execution sequence. Second file replaces static regression tests with behavioral tests that execute permission normalization logic against temporary directories, validecting group-write and setgid bit restoration, chmod command effects, and shield state transitions via mocked stat calls and spawned Node processes.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~15 minutes

Poem

🐰 A stub hops in, a test does twirl,
Permissions checked in config swirl,
Runtime behavior now takes the stage,
Where chmod commands dance and gauge,
We validate what shields protect so tight!

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The PR title 'fix(ci): repair source-shape checks' is vague and does not clearly convey the main changes: adding a stubbed permission-normalization function and rewriting behavioral tests for mutable config permissions. Consider a more descriptive title like 'fix(ci): add permission normalization stub and rewrite config permission tests' to better reflect the actual changes.
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/ci-source-shape-start-tests

Review rate limit: 9/10 reviews remaining, refill in 6 minutes.

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@test/nemoclaw-start.test.ts`:
- Line 1433: The test currently stubs normalize_mutable_config_perms() with a
log string but never asserts it ran; update the startup-order expectation set to
include "ORDER:normalize" (the output from normalize_mutable_config_perms) at
the correct position before the gateway/configure expectations so the test fails
if the pre-gateway block stops invoking normalize_mutable_config_perms; locate
the stubbed function name normalize_mutable_config_perms and add
"ORDER:normalize" into the sequence of expected log entries/assertions that
verify startup order.

In `@test/repro-2681-group-writable.test.ts`:
- Around line 57-69: The test currently fakes root uid but still calls the real
stat, making normalize_mutable_config_perms() take the shields-up fast path on
runners that created the temp tree as root; update the spawnSync bash script
(the array passed to spawnSync in the test) to also stub stat to report a
non-root owner (similar to how the shields-up case stubs stat to "root") so
normalize_mutable_config_perms() exercises the chmod/find path. Specifically,
inside the command sequence used by the test (the block that defines id() and
calls normalize_mutable_config_perms), add a stat() shim that intercepts the
same stat invocation used by the code under test (stat -c '%U' "$config_dir")
and returns a non-root username (e.g., "notroot") while delegating other stat
calls to command stat "$@"; keep references to normalize_mutable_config_perms
and normalizeMutableConfigPermsFor so the change is made in the same spawnSync
command payload.
🪄 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: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 87e50d53-d671-4659-bce7-e01cf89a273e

📥 Commits

Reviewing files that changed from the base of the PR and between 37d6d6a and aee0ca7.

📒 Files selected for processing (2)
  • test/nemoclaw-start.test.ts
  • test/repro-2681-group-writable.test.ts

: 'id() { if [ "${1:-}" = "-u" ]; then printf "0"; elif [ "${1:-}" = "-g" ]; then printf "0"; else command id "$@"; fi; }',
'emit_sandbox_sourced_file() { local target="$1"; cat > "$target"; chmod 444 "$target"; }',
'verify_config_integrity_if_locked() { echo "ORDER:verify"; }',
'normalize_mutable_config_perms() { echo "ORDER:normalize"; }',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Assert the normalization step instead of only stubbing it.

Adding the stub fixes the 127 path, but the harness still never checks that normalize_mutable_config_perms actually ran. If the pre-gateway block stops invoking it, this test will keep passing. Please assert ORDER:normalize in the later startup-order expectation set, ideally before the gateway/configure steps.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/nemoclaw-start.test.ts` at line 1433, The test currently stubs
normalize_mutable_config_perms() with a log string but never asserts it ran;
update the startup-order expectation set to include "ORDER:normalize" (the
output from normalize_mutable_config_perms) at the correct position before the
gateway/configure expectations so the test fails if the pre-gateway block stops
invoking normalize_mutable_config_perms; locate the stubbed function name
normalize_mutable_config_perms and add "ORDER:normalize" into the sequence of
expected log entries/assertions that verify startup order.

Comment on lines +57 to +69
const result = spawnSync(
"bash",
[
"-c",
[
"set -euo pipefail",
'id() { if [ "${1:-}" = "-u" ]; then printf "0"; else command id "$@"; fi; }',
normalizeMutableConfigPermsFor(configDir),
"normalize_mutable_config_perms",
].join("\n"),
],
{ encoding: "utf-8", timeout: 5000 },
);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Make the “restores group-write” test independent of the runner’s file ownership.

This harness fakes id -u=0 but still uses the real stat -c '%U' "$config_dir". On any CI/container that creates the temp tree as root, normalize_mutable_config_perms() will take the shields-up fast path and skip the chmod/find calls, so this test becomes environment-dependent. Stub stat here to report a non-root owner, the same way the shields-up case stubs it to root.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@test/repro-2681-group-writable.test.ts` around lines 57 - 69, The test
currently fakes root uid but still calls the real stat, making
normalize_mutable_config_perms() take the shields-up fast path on runners that
created the temp tree as root; update the spawnSync bash script (the array
passed to spawnSync in the test) to also stub stat to report a non-root owner
(similar to how the shields-up case stubs stat to "root") so
normalize_mutable_config_perms() exercises the chmod/find path. Specifically,
inside the command sequence used by the test (the block that defines id() and
calls normalize_mutable_config_perms), add a stat() shim that intercepts the
same stat invocation used by the code under test (stat -c '%U' "$config_dir")
and returns a non-root username (e.g., "notroot") while delegating other stat
calls to command stat "$@"; keep references to normalize_mutable_config_perms
and normalizeMutableConfigPermsFor so the change is made in the same spawnSync
command payload.

@cv
cv enabled auto-merge (squash) May 1, 2026 22:57
@cv
cv requested review from brandonpelfrey and cjagwani May 1, 2026 22:58
@cv
cv merged commit 2ebc0d9 into main May 1, 2026
18 of 19 checks passed
@cv
cv deleted the fix/ci-source-shape-start-tests branch May 27, 2026 21:16
@wscurran wscurran added the bug-fix PR fixes a bug or regression label Jun 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug-fix PR fixes a bug or regression

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants