Skip to content

[rig-sampler] feat(s): add s.integer schema helper#25

Merged
pelikhan merged 1 commit into
mainfrom
rig-sampler/06-list-source-files-884c25d8f878f835
Jul 23, 2026
Merged

[rig-sampler] feat(s): add s.integer schema helper#25
pelikhan merged 1 commit into
mainfrom
rig-sampler/06-list-source-files-884c25d8f878f835

Conversation

@github-actions

Copy link
Copy Markdown
Contributor

Sample run: 06-list-source-files.ts

The stub runner executed sample 06 successfully in a single turn — no repair loops. The sample outputs { summary: s.string }, a single-field object wrapping a string summary of the repository's TypeScript source files.

What the run revealed

While sample 06 itself ran cleanly, reviewing the broader set of samples (e.g. 03-diagnose-test-failure.ts with confidence: s.number, 41-parse-coverage.ts) reveals a gap: the harness has no way to express integer constraints. When agents return counts, line numbers, or coverage percentages as whole numbers, s.number accepts floats silently. A model that returns 1.5 for a turn count passes validation today, and the caller gets a float where an integer was intended.

Change

Added s.integer — an IntegerSchema with type: "integer" — following the exact same SchemaHelperFactory pattern as s.number:

  • New type IntegerSchema = { type: "integer"; description?: string }
  • s.integer helper, callable as bare value or s.integer("description")
  • JSON Schema serialization: emits { "type": "integer" } (standard JSON Schema integer type)
  • Validation: rejects non-integers via Number.isInteger(), so 1.5 now fails with a clear expected integer message instead of silently passing
  • InferSchema<IntegerSchema> maps to TypeScript number (no narrower integer type in TS)
  • Constraint updated: createTypedPrimitiveSchema generic constraint widened to include IntegerSchema

Tests added

Three new tests in src/rig.test.ts:

  • toJsonSchema coverage for s.integer and s.integer("description")
  • Validation accepts whole numbers
  • Validation rejects floats with a helpful error message

Generated by Daily Rig Sampler · 106.4 AIC · ⌖ 8.71 AIC · ⊞ 5.2K ·

Adds IntegerSchema type and s.integer helper following the same
SchemaHelperFactory pattern as s.number. Serializes to
{"type":"integer"} in JSON Schema and validates with
Number.isInteger(), rejecting floats at the validation layer.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@pelikhan
pelikhan marked this pull request as ready for review July 23, 2026 07:37
@pelikhan
pelikhan merged commit ba93d0b into main Jul 23, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant