Skip to content

fix(policy): ignore dotfile presets from directories#2525

Closed
WuKongAI-CMU wants to merge 2 commits intoNVIDIA:mainfrom
WuKongAI-CMU:fix/policy-from-dir-ignore-dotfiles
Closed

fix(policy): ignore dotfile presets from directories#2525
WuKongAI-CMU wants to merge 2 commits intoNVIDIA:mainfrom
WuKongAI-CMU:fix/policy-from-dir-ignore-dotfiles

Conversation

@WuKongAI-CMU
Copy link
Copy Markdown
Contributor

@WuKongAI-CMU WuKongAI-CMU commented Apr 27, 2026

Summary

  • Ignore hidden dotfile YAML entries when applying custom presets from a directory.
  • Keep explicit --from-file behavior unchanged for users who pass a hidden file directly.

Addresses one hardening item from #2521.

Test plan

  • npm run build:cli
  • npm run typecheck:cli
  • npm test -- test/policies.test.ts -t="--from-dir skips hidden dotfile yaml presets"
  • git diff --check

Summary by CodeRabbit

  • Bug Fixes

    • The policy-add --from-dir command now ignores hidden dotfiles (those beginning with a dot) when loading YAML policies, ensuring only visible configuration files are applied.
  • Tests

    • Added an integration test verifying hidden YAML presets are skipped and only visible presets are loaded.

Directory-based custom preset loading should mirror normal directory scans by ignoring hidden dotfiles such as .draft.yaml. This keeps --from-dir focused on intentionally selected visible preset files.

Constraint: Preserve sorted application order and first-failure abort semantics for visible YAML files.

Rejected: Filter dotfiles inside loadPresetFromFile | single-file loading should still honor an explicit user path.

Confidence: high

Scope-risk: narrow

Tested: npm run build:cli

Tested: npm run typecheck:cli

Tested: npm test -- test/policies.test.ts -t='--from-dir skips hidden dotfile yaml presets'

Tested: git diff --check
@copy-pr-bot
Copy link
Copy Markdown

copy-pr-bot Bot commented Apr 27, 2026

This pull request requires additional validation before any workflows can run on NVIDIA's runners.

Pull request vetters can view their responsibilities here.

Contributors can view more details about this message here.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 27, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Enterprise

Run ID: 489bc394-394d-4790-9677-77fc02f1a45e

📥 Commits

Reviewing files that changed from the base of the PR and between d98a483 and 0ba31e8.

📒 Files selected for processing (2)
  • src/nemoclaw.ts
  • test/policies.test.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/nemoclaw.ts

📝 Walkthrough

Walkthrough

The policy-add --from-dir behavior was changed to ignore hidden dot-prefixed files when loading YAML/YML presets; help text and the directory-reading filter were updated, and a new integration test verifies hidden files are skipped.

Changes

Cohort / File(s) Summary
CLI Command Implementation
src/nemoclaw.ts
Filter directory entries to exclude names starting with . before matching .yaml/.yml; update help text to state only non-hidden YAML/YML files are applied.
Integration Test
test/policies.test.ts
Add test that creates real.yaml and .bad.yaml in a temp dir, runs policy-add --from-dir --yes, and asserts only real.yaml is loaded (dotfile ignored).

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐰 In burrows of code I quietly peep,
I skip the dot-files hiding deep.
One real preset hops into the light,
The shadowed .bad stays out of sight.
Hooray for tidy configs—soft and neat! 🥕

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(policy): ignore dotfile presets from directories' directly and accurately describes the main change: modifying the policy-add --from-dir behavior to ignore hidden dot-prefixed files.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests

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

@wscurran wscurran added dependencies Pull requests that update a dependency file enhancement: policy labels Apr 27, 2026
@wscurran
Copy link
Copy Markdown
Contributor

✨ Thanks for submitting this pull request that proposes a way to ignore hidden dotfile YAML entries when applying custom presets from a directory.


Related open issues:

@brandonpelfrey brandonpelfrey enabled auto-merge (squash) April 28, 2026 17:32
@brandonpelfrey
Copy link
Copy Markdown
Collaborator

@WuKongAI-CMU please add DCO sign-off for this change

ericksoa added a commit that referenced this pull request Apr 29, 2026
Replays the approved functional change from @WuKongAI-CMU in #2525 onto
current main.

Original PR:
- #2525 by @WuKongAI-CMU

Behavior:
- `policy-add --from-dir` ignores hidden dotfile YAML entries while
still applying non-hidden `.yaml`/`.yml` files in lexicographic order.
- Explicit `policy-add --from-file .hidden.yaml` behavior is unchanged
because the `--from-file` path is not filtered.

Replacement rationale:
- #2525 was already approved but is currently blocked by branch/process
state.
- This PR carries the same functional change forward on a clean replay
branch so it can be validated and merged without waiting on the original
branch update.

Validation:
- `git diff --check` passed.
- `npm test -- test/policies.test.ts -t="--from-dir skips hidden dotfile
yaml presets"` passed after installing dependencies and rebuilding the
CLI.
- GitHub checks are being monitored before merge.

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
@ericksoa
Copy link
Copy Markdown
Contributor

Thanks @WuKongAI-CMU for the contribution here. The functional change from this PR has now been replayed and merged via #2679 because #2525 was blocked by branch/process state.

The merged change preserves the behavior proposed here: policy-add --from-dir skips hidden dotfile YAML entries while explicit --from-file behavior remains unchanged.

Closing this PR as superseded by #2679.

@ericksoa ericksoa closed this Apr 29, 2026
auto-merge was automatically disabled April 29, 2026 14:38

Pull request was closed

DemianHeyGen pushed a commit to DemianHeyGen/NemoClaw that referenced this pull request Apr 30, 2026
Replays the approved functional change from @WuKongAI-CMU in NVIDIA#2525 onto
current main.

Original PR:
- NVIDIA#2525 by @WuKongAI-CMU

Behavior:
- `policy-add --from-dir` ignores hidden dotfile YAML entries while
still applying non-hidden `.yaml`/`.yml` files in lexicographic order.
- Explicit `policy-add --from-file .hidden.yaml` behavior is unchanged
because the `--from-file` path is not filtered.

Replacement rationale:
- NVIDIA#2525 was already approved but is currently blocked by branch/process
state.
- This PR carries the same functional change forward on a clean replay
branch so it can be validated and merged without waiting on the original
branch update.

Validation:
- `git diff --check` passed.
- `npm test -- test/policies.test.ts -t="--from-dir skips hidden dotfile
yaml presets"` passed after installing dependencies and rebuilding the
CLI.
- GitHub checks are being monitored before merge.

Signed-off-by: Aaron Erickson <aerickson@nvidia.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dependencies Pull requests that update a dependency file enhancement: policy

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants