Skip to content

Take LibStringSet from rain.deploy - #136

Closed
thedavidmeister wants to merge 5 commits into
mainfrom
2026-09-15-string-set
Closed

thedavidmeister wants to merge 5 commits into
mainfrom
2026-09-15-string-set

Conversation

@thedavidmeister

@thedavidmeister thedavidmeister commented Sep 15, 2026

Copy link
Copy Markdown
Contributor

What

LibStringSet.holds, membership over a string[], and its twelve tests. Both
arrive from rain.deploy, which is where they were written and is not where they
belong.

Why

Nothing about whole-string membership is deploy-specific. It landed in
rain.deploy as a test helper, was promoted into that repo's source tree when one
caller needed it, and has stayed there ever since as the only file in it with no
deploy semantics.

The org already has this shape. LibParseStackName in rainlang walks a linked
list comparing name fingerprints, on the stated grounds that n is small so a
linear walk is cheap. holds is that argument with the truncation and the bloom
filter removed, for a caller that wants a yes or no rather than an index. The
character-mask primitives here answer a different question again, which is what
class a single byte is in; the readme's line about avoiding in-memory sets and
loops is about that, not about collections.

The consumer side follows once this releases: rain.deploy pins rain-string,
imports from here, and deletes its copy.

QA

  • Discriminating tests: the twelve in test/src/lib/LibStringSet.t.sol, run here
    at 12 passed, 0 failed. Each takes a concrete list and needle whose answer
    comes from the definition of membership, not from the loop that implements it:
    a match at every index, a single element list, a miss, an empty haystack, a
    prefix and an extension and a same-length difference and a case change, a
    difference past the first EVM word, the empty string as an ordinary member,
    equality by value rather than by memory identity, and a match that later
    misses do not undo.
  • Mutations applied: the five that survived rain.deploy's suite before these
    tests existed, each killed by them. Compare by length instead of by hash,
    killed by the whole-content case. Compare only the first word, killed by the
    beyond-one-word case. Return true on an empty haystack, killed by the empty
    case. Start the loop at index one, killed by the every-index case. Return
    false on a match and keep scanning, killed by the later-misses case.
  • Oracle: the library NatSpec, which defines holds as whether the list
    contains the string, by hash over the whole content, with order not fixed.
    Expected values are written out per case rather than computed by the same
    expression the library uses.
  • Category check: this is a relocation plus the coverage that was written for
    it. The library is byte-identical to the one in rain.deploy; the tests are the
    ones from Test LibStringSet.holds membership directly rain.deploy#175, which closes unmerged in favour of
    this.

🤖 Generated with Claude Code

https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN

Summary by CodeRabbit

  • New Features

    • Added string collection membership checking based on exact full-string equality.
    • Supports empty strings, case-sensitive comparisons, long strings, and order-independent matching.
  • Tests

    • Added comprehensive coverage for matches, misses, empty collections, value equality, and edge cases.

Whole-string membership over a list is not deploy machinery. It landed there as
a test helper and was promoted into that repo's source tree for one caller.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
@coderabbitai

coderabbitai Bot commented Sep 15, 2026

Copy link
Copy Markdown

Review Change StackReview Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 36b519fd-d505-4832-9001-ce8dd6d08960

📥 Commits

Reviewing files that changed from the base of the PR and between 060dbfa and 14a6f07.

📒 Files selected for processing (2)
  • src/lib/LibStringSet.sol
  • test/src/lib/LibStringSet.t.sol

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


Walkthrough

Changes

String membership

Layer / File(s) Summary
Membership contract and validation
src/lib/LibStringSet.sol, test/src/lib/LibStringSet.t.sol
Adds the internal LibStringSet.holds function. It compares keccak256 hashes for each haystack element and returns on the first match. Tests cover full-string equality, empty values, ordering, misses, and fuzz cases.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Refactor

Merge Risk: ⚪ Minimal · up to e4800

The string membership utility is ready to merge with no identified current-head risk.

🚥 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 identifies the main change: moving LibStringSet from rain.deploy. It is concise and related to the pull request objectives, although it does not name rain.string as the destination.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 0…
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch 2026-09-15-string-set

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.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
The audited stack-name lookup cannot take a string, and a hand port of its
technique failed its own tests. What moves is the code that has been running.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V8ViHcKLVk2YoS2joH4HdN
@thedavidmeister

Copy link
Copy Markdown
Contributor Author

Closing unmerged: the relocation is no longer the answer. rain.deploy deleted LibStringSet outright in rainlanguage/rain.deploy#210 and uses LibMemoryKV directly, so there is nothing to relocate. The reusable piece landed as has in rainlanguage/rain.lib.memkv#28.

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.

2 participants