Skip to content

📝 Add docstrings to perf/drop-zod-settings-hot-path#42

Closed
coderabbitai[bot] wants to merge 1 commit into
perf/drop-zod-settings-hot-pathfrom
coderabbitai/docstrings/6946773
Closed

📝 Add docstrings to perf/drop-zod-settings-hot-path#42
coderabbitai[bot] wants to merge 1 commit into
perf/drop-zod-settings-hot-pathfrom
coderabbitai/docstrings/6946773

Conversation

@coderabbitai
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot commented May 22, 2026

Docstrings generation was requested by @unbraind.

The following files were modified:

  • src/core/store/settings-validator.ts
  • src/core/store/settings.ts
These files were ignored
  • tests/unit/settings-validator.spec.ts
These file types are not supported
  • .agents/pm/chores/pm-1nht.toon
  • .agents/pm/chores/pm-uzmf.toon
  • .agents/pm/chores/pm-why9.toon
  • .agents/pm/features/pm-e1va.toon
  • .agents/pm/features/pm-gt82.toon
  • .agents/pm/features/pm-rnpb.toon
  • .agents/pm/history/pm-1nht.jsonl
  • .agents/pm/history/pm-6blp.jsonl
  • .agents/pm/history/pm-e1va.jsonl
  • .agents/pm/history/pm-gt82.jsonl
  • .agents/pm/history/pm-kyd6.jsonl
  • .agents/pm/history/pm-ot8r.jsonl
  • .agents/pm/history/pm-rnpb.jsonl
  • .agents/pm/history/pm-uzmf.jsonl
  • .agents/pm/history/pm-why9.jsonl
  • .agents/pm/issues/pm-6blp.toon
  • .agents/pm/issues/pm-kyd6.toon
  • .agents/pm/issues/pm-ot8r.toon
  • CHANGELOG.md
  • package.json
ℹ️ Note

CodeRabbit cannot perform edits on its own pull requests yet.

Summary by Sourcery

Document core settings validation and normalization helpers to clarify behavior and outputs.

Documentation:

  • Add descriptive docstrings for numeric, literal, array, optional, and object validators in the settings validator module.
  • Document the settings validation entry point, item type normalization, settings merge, and settings read-with-metadata functions to explain their inputs, outputs, and side effects.

Docstrings generation was requested by @unbraind.

* #41 (comment)

The following files were modified:

* `src/core/store/settings-validator.ts`
* `src/core/store/settings.ts`
@coderabbitai coderabbitai Bot requested a review from unbraind May 22, 2026 15:55
@coderabbitai
Copy link
Copy Markdown
Author

coderabbitai Bot commented May 22, 2026

Important

Review skipped

This PR was authored by the user configured for CodeRabbit reviews. CodeRabbit does not review PRs authored by this user. It's recommended to use a dedicated user account to post CodeRabbit review feedback.

⚙️ Run configuration

Configuration used: Repository UI (base), Organization UI (inherited)

Review profile: CHILL

Plan: Pro

Run ID: 204aa9df-0643-4cbf-b847-7da4af91977e

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@sourcery-ai
Copy link
Copy Markdown

sourcery-ai Bot commented May 22, 2026

Reviewer's Guide

This PR adds detailed JSDoc-style docstrings to key validation and settings utilities, improving discoverability and clarifying semantics without changing runtime behavior.

File-Level Changes

Change Details Files
Document core primitive validators used by the settings validation pipeline.
  • Added a docstring to vNumber explaining numeric validation, integer/positive options, and returned Outcome shape.
  • Added a docstring to vLiteral describing literal-string validation and success/failure behavior.
  • Added a docstring to vArray clarifying array validation semantics and per-element checking.
  • Added a docstring to vOptional explaining how undefined is treated as an absent value and how the inner validator is invoked.
  • Added a docstring to vObject describing object-shape validation, field dropping, and failure conditions.
src/core/store/settings-validator.ts
Clarify higher-level settings validation and normalization behavior.
  • Expanded documentation for validateSettings to describe its role as the main entry point for validating raw settings and its success/failure result contract.
  • Documented normalizeItemTypeDefinitions including handling of undefined input, invalid definitions, case-insensitive deduplication, and sort order.
  • Documented mergeSettings to describe how validated settings are merged with defaults, governance knobs, and normalized nested sections.
  • Documented readSettingsWithMetadata to outline file discovery, validation/merge pipeline, and the structure of the returned metadata and warnings.
src/core/store/settings-validator.ts
src/core/store/settings.ts

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

Copy link
Copy Markdown

@sourcery-ai sourcery-ai Bot left a comment

Choose a reason for hiding this comment

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

Hey - I've found 1 issue, and left some high level feedback:

  • The docstring for mergeSettings is very detailed and enumerates many specific fields; consider shortening this to a high-level description to avoid the comment drifting out of sync as new sections are added or existing ones change.
  • In normalizeItemTypeDefinitions, the docstring mentions dropping invalid definitions—verify that normalizeItemTypeDefinition actually signals invalid entries in a way that leads to them being dropped, or adjust the wording to more precisely describe the current behavior.
Prompt for AI Agents
Please address the comments from this code review:

## Overall Comments
- The docstring for `mergeSettings` is very detailed and enumerates many specific fields; consider shortening this to a high-level description to avoid the comment drifting out of sync as new sections are added or existing ones change.
- In `normalizeItemTypeDefinitions`, the docstring mentions dropping invalid definitions—verify that `normalizeItemTypeDefinition` actually signals invalid entries in a way that leads to them being dropped, or adjust the wording to more precisely describe the current behavior.

## Individual Comments

### Comment 1
<location path="src/core/store/settings-validator.ts" line_range="178-180" />
<code_context>
+ * The input must be a non-null, non-array object. Each key in `shape` is validated against the corresponding value from the input; if any check fails, validation fails. Optional checks that return `undefined` cause the key to be omitted from the output. Any keys not listed in `shape` are dropped.
+ *
+ * @param shape - A record mapping object keys to `Check` validator functions that validate and transform each field
+ * @returns An `Outcome` with `{ ok: true, value: Record<string, unknown> }` containing only successfully validated keys, or `FAIL` if the input is not an object or any field check fails
+ */
 function vObject(shape: Record<string, Check>): Check {
</code_context>
<issue_to_address>
**suggestion:** Avoid referencing the internal `FAIL` constant in the public-facing JSDoc return description.

Referencing `FAIL` here exposes an internal detail that callers don’t need. Please describe the failure case in terms of the public return shape instead (e.g. “or `{ ok: false }` if the input is not an object or any field check fails”).

```suggestion
 * @param shape - A record mapping object keys to `Check` validator functions that validate and transform each field
 * @returns An `Outcome` with `{ ok: true, value: Record<string, unknown> }` containing only successfully validated keys, or `{ ok: false }` if the input is not an object or any field check fails
 */
```
</issue_to_address>

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

Comment on lines +178 to +180
* @param shape - A record mapping object keys to `Check` validator functions that validate and transform each field
* @returns An `Outcome` with `{ ok: true, value: Record<string, unknown> }` containing only successfully validated keys, or `FAIL` if the input is not an object or any field check fails
*/
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

suggestion: Avoid referencing the internal FAIL constant in the public-facing JSDoc return description.

Referencing FAIL here exposes an internal detail that callers don’t need. Please describe the failure case in terms of the public return shape instead (e.g. “or { ok: false } if the input is not an object or any field check fails”).

Suggested change
* @param shape - A record mapping object keys to `Check` validator functions that validate and transform each field
* @returns An `Outcome` with `{ ok: true, value: Record<string, unknown> }` containing only successfully validated keys, or `FAIL` if the input is not an object or any field check fails
*/
* @param shape - A record mapping object keys to `Check` validator functions that validate and transform each field
* @returns An `Outcome` with `{ ok: true, value: Record<string, unknown> }` containing only successfully validated keys, or `{ ok: false }` if the input is not an object or any field check fails
*/

@unbraind unbraind deleted the branch perf/drop-zod-settings-hot-path May 22, 2026 16:36
@unbraind unbraind closed this May 22, 2026
@unbraind unbraind deleted the coderabbitai/docstrings/6946773 branch May 22, 2026 20:16
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.

1 participant