Skip to content

test: fn() wrapper and skillSource trust classification#367

Merged
anandgupta42 merged 1 commit intomainfrom
claude/test-fn-skillsource-20260322-session_01A73k9MRUmXYHgUNzd9oJKk
Mar 22, 2026
Merged

test: fn() wrapper and skillSource trust classification#367
anandgupta42 merged 1 commit intomainfrom
claude/test-fn-skillsource-20260322-session_01A73k9MRUmXYHgUNzd9oJKk

Conversation

@anandgupta42
Copy link
Contributor

What does this PR do?

Adds 12 new tests across two previously untested modules discovered during automated test-discovery reconnaissance.

1. fn() zod-validated function wrapper — src/util/fn.ts (5 new tests)

This utility wraps functions with zod schema validation and is imported in 10+ core modules including session management, permission evaluation, compaction, and project creation. Zero tests existed despite being a critical path dependency. New coverage includes:

  • Normal validated input passthrough
  • ZodError thrown on invalid input
  • .force() bypasses validation (used for internal trusted calls)
  • .schema exposes the original zod schema for introspection
  • Strict schemas reject unknown keys (validates real-world footgun where default zod strips extra keys silently)

2. skillSource() trust classification — src/cli/cmd/skill-helpers.ts (7 new tests)

This function determines whether a skill is classified as "builtin", "global", or "project" — a trust boundary that affects how skills are displayed and whether they receive elevated trust in the CLI. Zero tests existed. New coverage includes:

  • builtin: prefix correctly returns "builtin"
  • ~/.altimate/builtin/ path correctly returns "builtin"
  • ~/.claude/skills/, ~/.agents/skills/, ~/.altimate-code/skills/ all correctly return "global"
  • Arbitrary project paths correctly return "project"
  • Random paths with no skill directory match default to "project"

Tests use process.env.OPENCODE_TEST_HOME || os.homedir() to match the Global.Path.home getter behavior, ensuring deterministic results in both local and CI environments.

Type of change

  • New feature (non-breaking change which adds functionality)

Issue for this PR

N/A — proactive test coverage from automated test-discovery

How did you verify your code works?

bun test test/util/fn.test.ts              # 5 pass
bun test test/cli/skill.test.ts -t skillSource  # 7 pass

Checklist

  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

https://claude.ai/code/session_01A73k9MRUmXYHgUNzd9oJKk

Add 12 new tests for two previously untested modules:
- fn() zod-validated function wrapper (5 tests) — used in 10+ core modules
- skillSource() trust classification (7 tests) — determines skill provenance labels

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

https://claude.ai/code/session_01A73k9MRUmXYHgUNzd9oJKk
Copy link

@claude claude bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This repository is configured for manual code reviews. Comment @claude review to trigger a review.

@coderabbitai
Copy link

coderabbitai bot commented Mar 22, 2026

Warning

Rate limit exceeded

@anandgupta42 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 5 minutes and 38 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

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 have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: b5366270-d8ad-4b65-9e32-ea6de7e3c9cc

📥 Commits

Reviewing files that changed from the base of the PR and between 3ce1b78 and 1b77714.

📒 Files selected for processing (2)
  • packages/opencode/test/cli/skill.test.ts
  • packages/opencode/test/util/fn.test.ts
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/test-fn-skillsource-20260322-session_01A73k9MRUmXYHgUNzd9oJKk

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 and usage tips.

@anandgupta42 anandgupta42 merged commit fae97b0 into main Mar 22, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant