Skip to content

📦🔥:read a lazy expectation without caching it - #95

Merged
openinf-commit-queue[bot] merged 1 commit into
mainfrom
claude/project-thread-2s9ymn-lazy-expectation
Oct 1, 2026
Merged

openinf-commit-queue[bot] merged 1 commit into
mainfrom
claude/project-thread-2s9ymn-lazy-expectation

Conversation

@DerekNonGeneric

@DerekNonGeneric DerekNonGeneric commented Oct 1, 2026 •

Copy link
Copy Markdown
Member

Requested by DerekNonGeneric

Before: getExpectation wrote a lazy expectation's result back over the function. That write threw a TypeError for a frozen validator. For any other validator, the message stayed at whatever the expectation said the first time it was read.

After: the function is called on every read and the validator is never modified.

How: the result goes into a local variable instead of being assigned back. A new test freezes a validator and changes the value its expectation describes. It fails on main and passes here.

Summary by CodeRabbit

  • Bug Fixes
    • Lazy expectations are now evaluated on each call, so updated values are reflected instead of a stale result being reused.
    • Retrieving an expectation no longer modifies the validator, avoiding errors with frozen validators.

getExpectation wrote a lazy expectation's result back over the
function. For a frozen validator that write threw a TypeError, and for
any other it pinned the message to whatever the expectation said the
first time. It now calls the function each time and writes nothing.

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

coderabbitai Bot commented Oct 1, 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: bf9ffc4c-351c-419e-b84f-95bfa0a02a11

📥 Commits

Reviewing files that changed from the base of the PR and between 45679ff and 1e71494.

📒 Files selected for processing (3)
  • .changeset/lazy-expectations-stay-lazy.md
  • packages/util-types/src/get-expectation.ts
  • packages/util-types/test/get-expectation.ts

Included review availability: This review used your included allowance. 3 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

getExpectation now evaluates function-valued expectations on each call without replacing the validator’s expectation. A test covers successive results with a frozen guard and confirms the original function remains assigned.

Changes

Lazy expectation evaluation

Layer / File(s) Summary
Evaluate expectations without mutation
packages/util-types/src/get-expectation.ts, packages/util-types/test/get-expectation.ts, .changeset/lazy-expectations-stay-lazy.md
getExpectation evaluates function-valued expectations into a local value. The test checks updated results across successive calls on a frozen guard and confirms the function remains unchanged. The changeset records a patch release.

Priority: ⬇️ Low

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

Change: Bug fix

Merge Risk: ⚪ Minimal · up to 1e714

Lazy expectations are evaluated on each read without changing the validator, and the added test covers changing results for a frozen guard. No actionable merge-blocking risk is evident.

🚥 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 summarizes the main change: reading a lazy expectation without caching its result. The emojis do not prevent the title from being specific and understandable.
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 1, 2026

Copy link
Copy Markdown
Member Author

@coderabbitai review


Generated by Claude Code

@coderabbitai

coderabbitai Bot commented Oct 1, 2026 •

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@DerekNonGeneric DerekNonGeneric added the 🚀 Status: Commit Queue Land this pull request when its checks pass label Oct 1, 2026 — with Claude
@openinf-commit-queue
openinf-commit-queue Bot merged commit 8177c45 into main Oct 1, 2026
12 checks passed
@openinf-commit-queue openinf-commit-queue Bot removed the 🚀 Status: Commit Queue Land this pull request when its checks pass label Oct 1, 2026
@openinf-commit-queue
openinf-commit-queue Bot deleted the claude/project-thread-2s9ymn-lazy-expectation branch October 1, 2026 01:48
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