Skip to content

feat(assertions): extend deterministic assertions#33

Open
quanticsoul4772 wants to merge 2 commits intoEvaliphy:mainfrom
quanticsoul4772:rawcell/extend-deterministic-assertions-27
Open

feat(assertions): extend deterministic assertions#33
quanticsoul4772 wants to merge 2 commits intoEvaliphy:mainfrom
quanticsoul4772:rawcell/extend-deterministic-assertions-27

Conversation

@quanticsoul4772
Copy link
Copy Markdown
Contributor

Summary

Resolves #27. Extends DeterministicMatcherChain with 7 new methods following the pattern established in #29.

⚠️ Dependency: This PR builds on #29 (deterministic assertions foundation). Merge #29 first, or review together.

Method Description
toNotContain(expected) Substring must NOT be present
toContainAll(expected[]) All substrings must be present
toContainAny(expected[]) At least one substring must be present
toMatchRegex(pattern) Value must match RegExp
toHaveMinLength(min) Length ≥ min
toHaveMaxLength(max) Length ≤ max
toHaveLengthBetween(min, max) Length in [min, max]

All methods return DeterministicAssertionResult and throw DeterministicAssertionError on failure.

Test plan

  • 14 new test cases pass (pnpm run test)
  • TypeScript compiles without errors (pnpm run lint)

🤖 Generated with Claude Code

rawcell-agent and others added 2 commits April 18, 2026 16:01
Establishes the deterministicExpect() API and toContain reference
implementation as described in issue Evaliphy#26.

New module: packages/assertions/src/deterministic/

- types.ts — DeterministicAssertionResult interface
  {passed, score, reason, message, assertionName, type, durationMs}
- DeterministicAssertionError.ts — extends Error with structured
  formatting showing caller message, assertion name, expected, received
- expect.ts — deterministicExpect(value, message?) entry point
  returning DeterministicMatcherChain; toContain(expected) sync impl

Key properties:
- Fully synchronous — no async, no LLM client, no judge config
- Throws DeterministicAssertionError on failure (caught by engine)
- Result shape matches DeterministicAssertionResult contract
- Named deterministicExpect to coexist alongside existing LLM expect()

tests/deterministic.test.ts — 8 tests covering:
- passing result shape and fields
- durationMs present
- optional message forwarding
- throws DeterministicAssertionError on failure
- error.result shape on failure
- error message contains expected/received/caller-message
- error.name === 'DeterministicAssertionError'

Fixes Evaliphy#26

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Adds 7 new methods to DeterministicMatcherChain:
- toNotContain(expected) — substring absence check
- toContainAll(expected[]) — all substrings must be present
- toContainAny(expected[]) — at least one substring must be present
- toMatchRegex(pattern) — RegExp match
- toHaveMinLength(min) — length >= min
- toHaveMaxLength(max) — length <= max
- toHaveLengthBetween(min, max) — min <= length <= max

Each method follows the existing toContain pattern: returns
DeterministicAssertionResult, throws DeterministicAssertionError on
failure. Tests added for all 7 methods (pass + throw cases).

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 18, 2026

Someone is attempting to deploy a commit to the priyanshus's projects Team on Vercel.

A member of the Team first needs to authorize it.

@priyanshus
Copy link
Copy Markdown
Collaborator

Its depended on other PR #29 Keeping it on hold.

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.

[Assertions] Extend deterministic assertions

2 participants