Skip to content

📦🔧:validate a declared constructor property - #112

Merged
openinf-commit-queue[bot] merged 1 commit into
mainfrom
claude/project-thread-hho3c3
Oct 5, 2026
Merged

openinf-commit-queue[bot] merged 1 commit into
mainfrom
claude/project-thread-hho3c3

Conversation

@DerekNonGeneric

@DerekNonGeneric DerekNonGeneric commented Oct 2, 2026 •

Copy link
Copy Markdown
Member

Requested by DerekNonGeneric · project thread

Before: hasInterface<{ constructor: number }>('X', { constructor: isNumber }) returned true for {}, because every constructor key in the validator map was skipped and {} inherits Object as its constructor.

After: a constructor the interface declares is validated like any other property, so {} fails and { constructor: 1 } passes.

How: the walk over the validator map now skips constructor only when it is a prototype's own back-reference to its class (proto.constructor.prototype === proto), which is what the skip was for when a class instance is used as the map. A regression test covers the case, and a patch changeset is included for @openinf/util-core.

CodeRabbit found this when it reviewed #106 after the merge, on the review-only replay in #109.

Refs: #106

Summary by CodeRabbit

  • Bug Fixes
    • hasInterface now validates declared constructor properties, rejecting objects that lack a required constructor value or provide one of the wrong type.

hasInterface skipped every "constructor" key in a validator map, so a
guard for { constructor: number } accepted {} on the strength of its
inherited Object constructor. Skip only a prototype's own back-reference
to its class, and validate a constructor the interface declares.

CodeRabbit raised this when it reviewed #106 after the merge.

Signed-off-by: Derek Lewis <DerekNonGeneric@inf.is>
Assisted-by: Claude-Code:claude-opus-5
Refs: #106
@coderabbitai

coderabbitai Bot commented Oct 2, 2026 •

Copy link
Copy Markdown

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Essentials

Run ID: 0ab2386b-04bd-4945-9073-3b833662483a

📥 Commits

Reviewing files that changed from the base of the PR and between 5f49a30 and 0a54b63.

📒 Files selected for processing (3)
  • .changeset/declared-constructor-validators.md
  • packages/util-core/src/guards/has-interface.ts
  • packages/util-core/test/guards/has-interface.ts

Included review availability: This review used your included allowance. 0 included reviews remain after this review. Your included PR review attempts over the past 7 days set your current allowance at 4 reviews per hour.


📝 Walkthrough

Walkthrough

hasInterface now includes declared constructor properties in validator collection while continuing to exclude the inherited constructor. A test covers missing and numeric constructor values, and a patch Changeset records the update.

Changes

Constructor validation

Layer / File(s) Summary
Collect declared constructor validators
packages/util-core/src/guards/has-interface.ts, packages/util-core/test/guards/has-interface.ts, .changeset/declared-constructor-validators.md
The prototype walk excludes a constructor only when its data value points back to the inspected prototype. The test checks that a missing numeric constructor property fails validation and a numeric value passes. The Changeset declares a patch for @openinf/util-core.

Priority: ⬇️ Low

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix · Severity of issue fixed: Low

Merge Risk: ⚪ Minimal · up to 0a54b

The change adds the intended constructor-property validation while retaining class-instance behavior; no actionable merge-blocking risk is established.

🚥 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 clearly describes the main change: validating a declared constructor property in hasInterface. The emojis add noise but do not make the title unclear or unrelated.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 functions across 2 files. (1 skipped: 1 …
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.
✨ Finishing Touches
📝 Generate docstrings
  • Commit to this branch
  • Create a new PR
🧪 Generate unit tests (beta)
  • Commit to this branch
  • Create a new PR
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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

@DerekNonGeneric DerekNonGeneric self-assigned this Oct 2, 2026
@DerekNonGeneric
DerekNonGeneric marked this pull request as ready for review October 2, 2026 06:20
@DerekNonGeneric DerekNonGeneric added the 🚀 Status: Commit Queue Land this pull request when its checks pass label Oct 5, 2026
@openinf-commit-queue
openinf-commit-queue Bot merged commit f236719 into main Oct 5, 2026
13 of 14 checks passed
@openinf-commit-queue openinf-commit-queue Bot removed the 🚀 Status: Commit Queue Land this pull request when its checks pass label Oct 5, 2026
@openinf-commit-queue
openinf-commit-queue Bot deleted the claude/project-thread-hho3c3 branch October 5, 2026 01:57
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